#!/bin/sh
# $Id: flexlm,v 1.10 2008-06-20 12:54:42 annaj Exp $
##################################################################
# #
# flexlm client module for Xymon monitor V 1.0 #
# #
# Copyright (C) 2008 Anna Jonna Armannsdottir #
# #
# Actually this is after the recipie given in: #
# http://www.hswn.dk/hobbit/help/howtograph.html #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful,#
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public #
# License along with this program; if not, write to the #
# Free Software Foundation, Inc., 51 Franklin Street, #
# Fifth Floor, Boston, MA 02110-1301, USA. #
# #
# This file is to be installed on each client that is to be #
# monitored for Flex License Manager. #
# The link above says it all, but here is a quick install: #
# Find the directory where the program lmstat is. Change the #
# variable LMSTATDIR below to that directory. That is the only #
# thing a user needs to change in this script. Copy this #
# script to ~hobbit/client/ext/ #
# and make it executable for Xymon. #
# #
# For testing and verifying: Run the script in a shell and #
# check that the output is in /tmp/lic.txt #
# #
# In the file: #
# ~hobbit/client/etc/clientlaunch.cfg #
# Add the following section: #
# [flexlminfo] #
# ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg #
# CMD $HOBBITCLIENTHOME/ext/flexlm #
# INTERVAL 5m #
# #
# This is all that needs to be done on the client side. #
# #
##################################################################
#
LMSTATDIR="/opt/matlab/etc"
LICENSEGREP="\: \(Total of"
# ": (Total of"
# "\: \(Total of"
# "Total of"
# for testing out of Xymon environment
if [ -z "$EGREP" ]; then
EGREP="/bin/egrep"
fi
if [ -z "$SED" ]; then
SED="/bin/sed"
fi
if [ -z "$AWK" ]; then
AWK="/usr/bin/awk"
fi
if [ -z "$LMSTATDIR" ]; then
LMSTATDIR="/opt/matlab/etc"
fi
if [ -z "$LICENSEGREP" ]; then
LICENSEGREP="Total of"
fi
# The license manager has a component that is
# used to deliver output to a file
(
${LMSTATDIR}/lmstat -a
) > /tmp/flexlm.txt
# The output from the license manager is
# searched for lines that count actual license
# usage. The result is delivered in /tmp/lic.txt file.
(
$EGREP "${LICENSEGREP}" | \
$SED 's/://' | \
$AWK '{printf "%.19s : %d \n", $3, $11 }'
)< /tmp/flexlm.txt > /tmp/lic.txt
# The actual state of the license manager is checked
# and prepared as part of report to Xymon monitor.
UPTEST=`cat /tmp/flexlm.txt | $EGREP ".*MLM: UP.*$"`
LICSERVTEST=`cat /tmp/flexlm.txt | $EGREP ".*license server UP.*$" | $SED 's/://' | $AWK '{printf "%s\n", $1 }'`
if [ -n "$BB" ]; then
if [ -n "$UPTEST" ]; then
SSTATUS="Licenses OK"
COLOUR="green"
FLEXLMSTATE=`cat /tmp/lic.txt`
if [ -n "$LICSERVTEST" ]; then
SSTATUS="Licenses on $LICSERVTEST OK"
fi
else
SSTATUS="DOWN"
COLOUR="red"
FLEXLMSTATE=`cat /tmp/flexlm.txt`
fi
# Finally, the gathered information is sent to the Xymon Monitor.
$BB $BBDISP "status $MACHINE.flexlm $COLOUR `date` $SSTATUS
${FLEXLMSTATE}
"
fi