Anna, and All actual here how I modified your script.
Basicly I put a do loop around Anna version that parses a config file: params.lm. This is a list we use for an existing flexlm tracker.
With entries that look like:
'MATLAB_7.0_mysys 1700 at mysys'
Ok I've not the time to explain in detail but here are the key point ${LMSTATDIR}/lmstat -a -c $LIC Where $LIC is the last field on the line
I actually use the first field as $MACHINE and parse out the licencesname from $MACHINE into TEST TEST is very important as this sets the column name which MUST match the graph!
The very bad part of my scheme is if I want graphs I need for each license type MATLAB Maple LSF etc add/add-on 3 lines
trends="................LSF= GRAPHS="..............LSF" NCV_LSF="*:GAUGE"
Since my user are used to seeing a table formated like:
MATLAB_7.0_mysys today# thisweeks# lastweek# .....
I set up pseudo hosts like: 0.0.0.0 MATLAB_7.0_mysys # noconn TRENDS=:*,MATLAB:MATLAB|MATLAB1
So the hobbit page looks like: MATLAB info trends
MATLAB_7.0_mysys dot dot dot
You got to make your graphs defs too (MATLAB MATLAB1)
#!/usr/bin/bash
$Id: flexlm,v 1.10 2008-06-20 12:54:42 annaj Exp $
##################################################################
flexlm client module for Hobbit 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 Hobbit.
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.
##################################################################
while read L
do
set $L
MACHINE=$1
LIC=$2
TEST=echo $MACHINE | awk -F_ '{print $1}'
LMSTATDIR="/sw/matlab7.1/etc/"
#LMSTATDIR="/home/www/lmstat/"
LICENSEGREP="\: \(Total of"
for testing out of Hobbit environment
if [ -z "$EGREP" ]; then EGREP="/bin/egrep" fi
if [ -z "$SED" ]; then SED="/bin/sed" fi #SED="/usr/local/bin/sed" #if [ -z "$AWK" ]; then #AWK="/usr/bin/awk" #fi
AWK="/usr/local/bin/awk"
if [ -z "$LMSTATDIR" ]; then LMSTATDIR="/sw/matlab7.1/etc/"
LMSTATDIR="/opt/matlab/etc"
fi
if [ -z "$LICENSEGREP" ]; then LICENSEGREP="Total of" fi
TEST=echo $MACHINE | $AWK -F_ '{print $1}'
The license manager has a component that is
used to deliver output to a file
( ${LMSTATDIR}/lmstat -a -c $LIC ) > /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.
(
#echo $TEST >/tmp/lic.txt$$
echo $L >/tmp/lic.txt$$
echo "" >>/tmp/lic.txt$$
$EGREP "${LICENSEGREP}" |
$SED 's/://' |
$AWK '{printf "M%.19s : %d \n %.19s : %d \n", $3, $6, $3, $11 }'
#$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 Hobbit monitor.
UPTEST=cat /tmp/flexlm.txt$$ | $EGREP ".*: UP.*$v.*"
#UPTEST=cat /tmp/flexlm.txt | $EGREP ".*MLM: UP.*$"
#LOOK OUT the below LICSERVTEST IS a single line!
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 Hobbit Monitor.
$BB $BBDISP "status $MACHINE.$TEST $COLOUR date $SSTATUS
${FLEXLMSTATE} "
fi rm /tmp/flexlm.txt$$ rm /tmp/lic.txt$$ done < params.lm