Flexnet License Monitoring With rrdtool - Page 2

4. Creating the graphs

The graphs could easily be created with the help of the rrdcgi program, which is in the rrdtool package. Creation is then only done on demand to save CPU cycles, you have to create some CGI scripts with special RRD:: tags, which are interpreted by rrdcgi.

My CGI script looks like:

#!/usr/bin/rrdcgi

<HTML>
<HEAD><TITLE>Prod1 License Usage</TITLE></HEAD>
<BODY>
<H1>Prod1 License Usage at <RRD::TIME::NOW '%a, %d %b %Y %H:%M'></H1>
<P></P>

<P>
<RRD::GRAPH /var/www/rrd/CL.png
        --imginfo '<IMG SRC=/rrd/%s>'
        -s -24hours -w 600 -h 200 -W gbi@localhost@localdomain
        -v "Licenses used" --lazy
        --title "Users of CL"
        -l 0 -Y
        DEF:value=/var/rrd/CL.rrd:value:MAX
        DEF:total=/var/rrd/CL.rrd:total:MAX
        AREA:value#660000
        LINE3:total#FF00FF>

</P>
</BODY>
</HTML>

For details see the manpages of rrdcgi and rrdgraph.

This is an example of a wellknown MRTG-style graph:

Daily license usage

Not much going on here.

The script above was my first, simple approach. The idea was to implement a set of scripts for every product and for different periods, one for daily, one for weekly one for monthly and one for yearly overviews. But this leads to a flood of scripts being nearly identical. After another look into the documentation of rrdcgi another possibility was found, leading to a solution with one script per product and radiobuttons for interactive selection of the timeperiod of interest. The script looks like:

#!/usr/bin/rrdcgi

<HTML>
<HEAD><TITLE>Prod1 License Usage</TITLE></HEAD>
<H1>Prod1 License Usage at <RRD::TIME::NOW '%a, %d %b %Y %H:%M'></H1>

<H2>Time period</H2>
<FORM><INPUT NAME=period TYPE=RADIO Value=24hours> Daily,
        <INPUT NAME=period TYPE=RADIO VALUE=7days> Weekly,
        <INPUT NAME=period TYPE=RADIO VALUE=1month> Monthly,
        <INPUT NAME=period TYPE=RADIO VALUE=1year> Yearly.
        <INPUT TYPE=SUBMIT></FORM>

<BODY>
<P></P>

<P>
<RRD::GRAPH /var/www/rrd/CL-<RRD::CV period>.png
        --imginfo '<IMG SRC=/rrd/%s>'
        -s -<RRD::CV period> -w 600 -h 200 
        -W [email protected]
        -v "Licenses used" --lazy
        --title "Users of CL"
        -l 0 -Y
        DEF:value=/var/rrd/CL.rrd:value:MAX
        DEF:total=/var/rrd/CL.rrd:total:MAX
        AREA:value#660000
        LINE3:total#FF00FF>
</P>

</BODY>
</HTML>

The radiobuttons above the graphs for selecting the timeperiod look like:

Radiobuttons

 

5. Creation of the rrd databases

There is one topic I have not mentioned so far, how the rrd databases are created. I have used, you sense it, another script. It looks like:

#!/usr/bin/python
# Script to create all rrd dbs for all instances of licenses 
# in a mrtg compatible fashion


import sys, string, rrdtool

search = [ { 'term':"Users of CL:", 'val':10, 'max':5, 'db':'CL' },
           { 'term':"Users of xyzabc:", 'val':10, 'max':5, 'db':'xyzabc' },
           { 'term':"Users of qwerty:", 'val':10, 'max':5, 'db':'qwerty' } ]


for x in search:

      rrdtool.create( '/var/rrd/' + x[ 'db' ] + '.rrd', '-s 300', \
	'DS:value:GAUGE:600:U:U', 'DS:total:GAUGE:600:U:U', \
        'RRA:MAX:0.5:1:600', 'RRA:MAX:0.5:6:700', 'RRA:MAX:0.5:24:775', \
	'RRA:MAX:0.5:288:797' )

Of course you have to adjust this to your needs.

 

6. Another CGI script

To further ease the handling of the Flexnet system and the users who need to lease a license to do their work, another CGI script was created. It is used to show who has leased how much licenses, it is only the output of "lmutil lmstat -a", but without logging in into a system where lmutil is installed. But be aware, this may collide with privacy protection in your enterprise, because personal informations are free accessible. So you may have to protect running this script with some authentication mechanism, but this topic is not covered in this tutorial.

The script is again a dash script as the one in chapter 2, you can query more than one product on more than one server, if implemented accordingly. It is also a so called here-script, which is a special, rarely used kind of shellscript. Again feel free to adjust to your needs:

#!/bin/dash

case $1 in
        prod1)          PORT=27000; PROD="Prod1";;
        prod2)          PORT=27002; PROD="Prod2";;
        prod3)          PORT=27042; PROD="Prod3";;
        *|prod4)        PORT=27001; PROD="Prod4";;
esac

echo Content-type: text/html
echo ""

/bin/cat << EOM
<HTML>
<HEAD><TITLE>Licensestate $PROD</TITLE>
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="cache-control" CONTENT="no-cache">
</HEAD>
<BODY bgcolor="#cccccc" text="#000000">
<HR SIZE=5>
<H1>Licensestate $PROD</H1>
<TD WIDTH=30%>
</P>
</TD>
<HR SIZE=5>
<P>
<PRE>
EOM

/usr/local/bin/lmutil lmstat -c $PORT@LICENSESERVER -a

/bin/cat << EOM
</PRE>
</SMALL>
<P>
<HR SIZE=3>
<P STYLE="margin-bottom: 0in"><A HREF="mailto:[email protected]"><SPAN STYLE="text-decoration: none"><FONT SIZE=4 STYLE="font-size: 16pt"><FONT FACE="URW Chancery L">GBi</FONT></FONT></SPAN></A></P>
<P STYLE="margin-bottom: 0in; font-weight: medium; text-decoration: none">
<FONT FACE="Nimbus Roman No9 L, serif"><FONT SIZE=4>14.6.2010</FONT></FONT>

</BODY>
</HTML>
EOM

Simply copy this script into the cgi-bin directory of your webserver (/usr/lib/cgi-bin in my case), make it world read- and executable, do not forget to load the CGI module of your webserver (if it has one, or it is not loaded already), and you are ready to take off. The output looks like:

License state

This script is called in your webbrowser with a URL like:

http://server/cgi-bin/licstate.cgi?prod2

So you can select one of several products simply by supplying a "command line parameter" to the CGI script.

By supplying a script like this one to the users of products where available licenses tend to be nearly maxed out all the time, it is easy that the users handle their issues regarding license usage among themselves, and there is no need for the administrator to be involved at all ;-).

 

7. URLs

Share this page:

0 Comment(s)