FLEXlm Template and Script - Server_Script format

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

FLEXlm Template and Script - Server_Script format

Post by super-hornet »

This script/template allow to "plot" FLEXlm license usage.
I was inspired by "pvenezia" who wrote a FLEXlm license usages using Perl script.
http://forums.cacti.net/viewtopic.php?t ... ght=flexlm

This script run on server_script format. It is written in php. No php dependencies is required for what I know.

This script was a strip down version of a more complex script that I am using in my workplace.

This is the first release version. Please let me know if there is any bug in the script.
This script/library was writtent and test in Linux. Not sure whether will run on Windows.
It is exported using cacti 0.8.7b.

Release Version: 1.0
Date: August 20, 2008, 17:58pm
Created by: Ching Hock Tay

PHP scripts function/purpose
----------------------------
array_to_file.php = Library to write array to file.
flexlm_function.php = Library to access FLEXlm's lmstat.
flexlm_poller_config.php = Configuration file for flexlm_poller.php
flexlm_poller.php = FLEXlm poller itself. Periodically run by cron.d
flexlm_server_config.php = FLEXlm Server Configuration file.
ss_flexlm_lmstat_query.php = Server script file for cacti.

Cron.d
--------
flexlm_poller = Default to run on every 3 minutes.

Server Script's XML file
-----------------------
flexlm_lmstat.xml = Server Script file for cacti to run/access.

Instruction
-----------
Import data query, data_template and graph_templates.
Place all PHP scripts in cacti's script directory. Place the "flexlm_lmstat.xml" in cacti's resource/script_server.
Modify "flexlm_poller_config.php" and "flexlm_server_config.php" to your environment settings.
Modify "flexlm_poller" to your environment and the correct user. Remember that the user must have the write permission to cacti's scripts path.
Place the "flexlm_poller" to the /etc/cron.d path.
Configure cacti for new device. Enter as per normal system but with the follow configuration:
Hostname = FLEXlm license server hostname.
Select SNMP v1.0.
Remove SNMP community name.
Enter the FLEXlm port (e.g. 5280 for Cadence) into the SNMP port instead.

Note: It is possible to assign the result output file to /tmp path but by doing so, require to change "flexlm_poller_config.php" and "ss_flexlm_lmstat_query.php" file.


How it works
------------
flexlm_poller will run on every 3 minutes (depend on the cron configuration). It will poll whatever FLEXlm license servers that is defined in "flexlm_server_config.php". After query all the lmstat result, the contents/result is written to a text file defined by "flexlm_poller_config.php". The format of this result is in php format. When cacti poller is running, the poller will call "ss_flexlm_lmstat_query.php" and this file will "include" the result file. From there, it will display/return back the result to cacti.

The purpose of doing so (include) is to speed up the FLEXlm query during cacti's polling.


SH
Attachments
FLEXlm_License_Usage_ImportThisToCacti.zip
Extract to a directory and import it to cacti.
(6.58 KiB) Downloaded 602 times
FLEXlm_License_Usage_RequiredScripts.zip
Extract to a directory and copy the correct pat.h
(5.97 KiB) Downloaded 670 times
ReadMe.txt
ReadMe.txt = Same content in this post.
(2.82 KiB) Downloaded 690 times
wazoqaz
Posts: 15
Joined: Wed May 24, 2006 9:40 am
Location: md, us
Contact:

Post by wazoqaz »

super-hornet

Can you please explain the advantages/differences between your version and the one by pvenezia. I'm currently using that one, and I was wondering what I might gain/lose by migrating to your solution.

Thanks in advance,
--ken
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Post by super-hornet »

wazoqaz's version
Require Tie:ShareLite and IPC:ShareLite library for Perl. Depend on what OS u using.. sometime u can't find a ready made version. You end up compiling from source code.
Recently I found out somehow the Sharelite will crash in openSUSE 11.0
Both poller and query must run in the same system due to it make use of Sharelite.
Slower than PHP in Server Script mode.
The original version required u to modify the data source if your quantity licenses greater than 100.

This version
Faster.
It is possible to have poller and query running on different system. So long as the query system can see the result file.
Should not have any dependency problem. So long as u have PHP running, it should be sufficient.
I do not restrict the total number of licenses.
Some licenses has RESERVATION and it can capture it (I haven't really test it in this version)

This version is slightly different (not really compatible) to wazoqaz's version. Maybe when I have freetime (and mood :) ), I try to come out a compatible version. (Compatible in the sense that can reuse back your existing configuration).

If u want to use this version, my recommendation is that u create another set of devices just to run this script. In this way, u will not destroy your existing version.

SH
Jagy
Posts: 10
Joined: Tue Nov 11, 2008 8:05 am

Post by Jagy »

how to resolve this one warning:
PHP Notice: Undefined variable: port in /var/www/cacti/scripts/flexlm_poller_config.php on line 11
PHP Notice: Undefined variable: server in /var/www/cacti/scripts/flexlm_poller_config.php on line 11
igladm
Posts: 2
Joined: Thu Dec 04, 2008 4:22 am
Location: Villarceaux

Doesn't have a rrd data file

Post by igladm »

Hi all,

As for Jagy, i've the same warning when launching my flexlm_lmstat deamon.

Following the instruction, i've imported the templates under cacti, created a graph, but i do not have a rrd data file.

Cacti said that he can't fing the xxxx.rrd file. So i can't have any graphs.

Any help are welcome...


Cheers

Gerald :wink:
isse
Posts: 16
Joined: Tue Nov 25, 2008 5:50 am

Post by isse »

Will this work if cacti is running on windows?
If so can someone post a quick guide...

Thanks

/Niklas
User avatar
pirx
Cacti User
Posts: 199
Joined: Tue Feb 10, 2004 10:08 am
Location: Esslingen, Germany

Re: FLEXlm Template and Script - Server_Script format

Post by pirx »

I try to use the plugin, but no rrd files are generated. A verbose query shows the licenses (with some errors).

Code: Select all

Data Query Debug Information
+ Running data query [26].
+ Found type = '6 '[script query].
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php -q /usr/share/cacti/site/scripts/ss_flexlm_lmstat_query.php smtca00084 27000 index'
+ Executing script query '/usr/bin/php -q /usr/share/cacti/site/scripts/ss_flexlm_lmstat_query.php smtca00084 27000 query feature'
+ Found item [feature=' Missing argument 5 for ss_flexlm_lmstat_query() in /usr/share/cacti/site/scripts/ss_flexlm_lmstat_query.php on line 23'] index: Warning
+ Found item [feature='DSDD_MANAGER'] index: DSDD_MANAGER
+ Found item [feature='MODEL_COMPARE'] index: MODEL_COMPARE
+ Found item [feature='TL_ASAP2'] index: TL_ASAP2
+ Found item [feature='TL_AUTOSAR30'] index: TL_AUTOSAR30
+ Found item [feature='TL_AUTOSAR_SWC'] index: TL_AUTOSAR_SWC
+ Found item [feature='TL_BASE'] index: TL_BASE
+ Found item [feature='TL_CG_BETA'] index: TL_CG_BETA
+ Found item [feature='TL_MLCUR14'] index: TL_MLCUR14
+ Found item [feature='TL_MLCUR14SP3'] index: TL_MLCUR14SP3
+ Found item [feature='TL_MLCUR2006A'] index: TL_MLCUR2006A
+ Found item [feature='TL_MLCUR2007A'] index: TL_MLCUR2007A
+ Found item [feature='TL_MLCUR2008'] index: TL_MLCUR2008
+ Found item [feature='TL_MLCUR2009A'] index: TL_MLCUR2009A
+ Found item [feature='TL_TGTSIM'] index: TL_TGTSIM
+ Executing script query '/usr/bin/php -q /usr/share/cacti/site/scripts/ss_flexlm_lmstat_query.php smtca00084 27000 query vendor'
+ Found item [vendor=' Missing argument 5 for ss_flexlm_lmstat_query() in /usr/share/cacti/site/scripts/ss_flexlm_lmstat_query.php on line 23'] index: Warning
+ Found item [vendor=''] index: DSDD_MANAGER:DSPACE
+ Found item [vendor=''] index: MODEL_COMPARE:DSPACE
+ Found item [vendor=''] index: TL_ASAP2:DSPACE
+ Found item [vendor=''] index: TL_AUTOSAR30:DSPACE
+ Found item [vendor=''] index: TL_AUTOSAR_SWC:DSPACE
+ Found item [vendor=''] index: TL_BASE:DSPACE
+ Found item [vendor=''] index: TL_CG_BETA:DSPACE
+ Found item [vendor=''] index: TL_MLCUR14:DSPACE
+ Found item [vendor=''] index: TL_MLCUR14SP3:DSPACE
+ Found item [vendor=''] index: TL_MLCUR2006A:DSPACE
+ Found item [vendor=''] index: TL_MLCUR2007A:DSPACE
+ Found item [vendor=''] index: TL_MLCUR2008:DSPACE
+ Found item [vendor=''] index: TL_MLCUR2009A:DSPACE
+ Found item [vendor=''] index: TL_TGTSIM:DSPACE
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/flexlm_lmstat.xml'

flexlm_lmstat_result.php

Code: Select all

<?php
$servers=array();
$servers["smtca00084"]=array(0=>"27000",1=>"27001");
$servers_flexlm_vendor=array();
$servers_flexlm_vendor["smtca00084"]=array(27000=>"DSPACE:",27001=>"isograph");
$flexlm_licenses=array();
$flexlm_licenses["smtca00084"]=array();
$flexlm_licenses["smtca00084"][0]="27000";
$flexlm_licenses["smtca00084"][1]="27001";
$flexlm_licenses["smtca00084"][27000]=array();
$flexlm_licenses["smtca00084"][27000]["DSDD_MANAGER"]=array("total"=>"2","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["MODEL_COMPARE"]=array("total"=>"1","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_ASAP2"]=array("total"=>"2","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_AUTOSAR30"]=array("total"=>"1","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_AUTOSAR_SWC"]=array("total"=>"1","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_BASE"]=array("total"=>"2","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_CG_BETA"]=array("total"=>"2","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_MLCUR14"]=array("total"=>"4","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_MLCUR14SP3"]=array("total"=>"4","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_MLCUR2006A"]=array("total"=>"4","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_MLCUR2007A"]=array("total"=>"4","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_MLCUR2008"]=array("total"=>"4","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_MLCUR2009A"]=array("total"=>"4","inuse"=>"0");
$flexlm_licenses["smtca00084"][27000]["TL_TGTSIM"]=array("total"=>"1","inuse"=>"0");
$flexlm_licenses["smtca00084"][27001]=array();
$flexlm_licenses["smtca00084"][27001]["FTP"]=array("total"=>"2","inuse"=>"0");
Any idea what to look for?
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Re: FLEXlm Template and Script - Server_Script format

Post by super-hornet »

Hi all

I notice my old scripts got some minor warning errors but didn't have the time to fix it.
Anyway, here is a quick fix that I done. It should be working. Let me know how.
The changes so far are:
1. Fixed/Change the poller's configuration file.
2. Fixed/Change the poller file.
3. U do not required the "flexlm_function.php" file anymore. I merge it into the main poller file.

Things u need to do is:
Update the "flexlm_poller_config.php" on the correct location of your "lmutil".
E.g. if your lmutil is at "/usr/bin/lmutil", then u change the config file of:
$lmutil = "/usr/local/sbin/lmutil";
to
$lmutil = "/usr/bin/lmutil";

Oh.. to make this thing work in Windows, u just have to make sure the directory slash is correct.

U need a cron job to run the poller. Usually every 3minutes should be enough.
The cron job will run the "flexlm_poller.php" and it will write the result back to where the "flexlm_poller.php" is... like in /usr/share/cacti/script" (if that is your cacti directory). Thus, in your cron job, if u are using root to write, then make sure it has permission to write into there.

Here u go. Overwrite your existing/old file with this one. U do not required to import again.

EDIT:
here is the cron job example that was including in the original/1st release:
*/3 * * * * root cd /usr/share/cacti/scripts; php flexlm_poller.php > /dev/null 2>&1
Notice I set every 3 minutes and it will be run by root. Thus, root must has permission to write into the directory...in this case, /usr/share/cacti/scripts. That is where the script located.

SH
Attachments
FLEXlm_License_Usage_RequiredScripts_Fixes_Jan20_2011_0946.zip
(4.21 KiB) Downloaded 339 times
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Re: FLEXlm Template and Script - Server_Script format

Post by super-hornet »

Here is the brief explanation how it work:
flexlm_poller.php is the one that query the FLEXlm licenses using lmutil.
That file is run using cron job (u can also run it manually to test it) in around 3 minutes (Why 3 minutes will explain later).
That script required lmutil to run...and the location of the lmutil is indicated in the "flexlm_poller_config.php" file.
Which server (FLEXlm license server) to query is indicated in "flexlm_server_config.php".
Therefore, u need to update "flexlm_server_config.php" to indicate where is your FLEXlm license server.
The result from lmstat query (from "flexlm_poller.php") is written a file called "flexlm_lmstat_result.php".
If u open the "flexlm_lmstat_result.php" file, u should see something like this:

=========
<?php
$servers=array();
$servers["hydrogen"]=array(0=>"1700",1=>"1717",2=>"2131",3=>"5280");
$servers_flexlm_vendor=array();
$servers_flexlm_vendor["hydrogen"]=array(1700=>"Atrenta Spyglass",1717=>"Mentor",2131=>"SPECMAN",5280=>"CADENCE Enterprise");
$flexlm_licenses=array();
$flexlm_licenses["hydrogen"]=array();
$flexlm_licenses["hydrogen"][0]="1700";
$flexlm_licenses["hydrogen"][1]="1717";
$flexlm_licenses["hydrogen"][2]="2131";
$flexlm_licenses["hydrogen"][3]="5280";
$flexlm_licenses["hydrogen"][5280]=array();
$flexlm_licenses["hydrogen"][5280]["Adv_Encrypt_Std_64bit"]=array("total"=>"16","inuse"=>"0");
$flexlm_licenses["hydrogen"][5280]["Affirma_AMS_distrib_processing"]=array("total"=>"32","inuse"=>"0");
$flexlm_licenses["hydrogen"][5280]["Affirma_NC_Simulator"]=array("total"=>"16","inuse"=>"0");
$flexlm_licenses["hydrogen"][5280]["Affirma_RF_IC_package_modeler"]=array("total"=>"16","inuse"=>"0");
$flexlm_licenses["hydrogen"][5280]["Affirma_advanced_analysis_env"]=array("total"=>"16","inuse"=>"0");
...
...
$flexlm_licenses["hydrogen"][5280][41000]=array("total"=>"16","inuse"=>"0");
?>
==============

If u do not get any array("total"=>"16","inuse"=>"0"), that mean your "flexlm_server_config.php" settings are wrong whereby lmstat unable to query it.

Now, why 3 minutes? Because our cacti is 5minutes query (normally). Querying FLEXlm license server...if you have a lot of servers, it will take quite a lot of time to complete.
If u set to poll every 5 minutes, then the result that the cacti plot may not be that accurate.

After that, your cacti will run the "script server" script of "ss_flexlm_lmstat_query.php".
This script will read the config file of "flexlm_poller.php" to know where is the result file and the filename.
It then open the "flexlm_lmstat_result.php" file to read the content and reply accordingly to cacti.

SH
isse
Posts: 16
Joined: Tue Nov 25, 2008 5:50 am

Re: FLEXlm Template and Script - Server_Script format

Post by isse »

Hi, thanks for the update and info,
I tried this on a windows machine but cant get it to work, the instructions are a little confusing.

I have configred the poller settings and server settings, and when i try running the poller manualy it creates the poller result file.
But it only contains the info from server settings.

It´s a little unclear exactly what you need to configure in the php files and how everything relates.
Especialy the server-settings.
Im trying to use this with autodesk flexlm servers.
Thanks
/ISSE
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Re: FLEXlm Template and Script - Server_Script format

Post by super-hornet »

Hi isse

If u manually run the poller and there is no error, and the result file do have your server, that mean the configuration is almost correct :)

Make sure your system that run the poller can access/run the "lmutil". I not sure about Windows's version of FLEXlm's lmutil but I believe it should be the same as Linux/UNIX type.

First, u make sure your poller system can query your AutoDesk's license server using lmutil. Make sure it can query by hostname. If the poller unable to query it, what u get in the result file is just the server info.

SH
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Re: FLEXlm Template and Script - Server_Script format

Post by super-hornet »

Assuming your AutoDesk license server's hostname is called "helium".
Assuming u configured your AutoDesk license server of using port "1700"
Again, assuming u want to identify your AutoDesk FLEXlm by the name of "AutoDesk AutoCAD".

So, your "flexlm_server_config.php" will be like this:

<?php
$servers["helium"] = array("1700");

$servers_flexlm_vendor["helium"] = array(
"1700" => "AutoDesk AutoCAD",
);

?>


In your Windows (poller) system, u should be able to run this:
C:\FLEXlm\lmutil lmstat -a -c 1700@helium
and it should return all the licenses info.

If the above lmutil lmstat command is wrong (For Windows), please let me know.



For the "flexlm_poller_config.php" setting,
Assuming your cacti is in "C:\www\cacti", and your FLEXlm's lmutil is in "C:\FLEXlm, then the setting will be:
<?php
$lmutil = "C:\FLEXlm\lmutil"; // Location of your lmutil
$flexlm_result = "flexlm_lmstat_result.php"; // The result filename and its location.
# OR u can try this:
# $flexlm_result = "C:\www\cacti\scripts\flexlm_lmstat_result.php"; // The result filename and its location.


$total_license = "total";
$license_in_used = "inuse";

$lmstat = $lmutil . " lmstat -a -c %port%@%server%";
?>
isse
Posts: 16
Joined: Tue Nov 25, 2008 5:50 am

Re: FLEXlm Template and Script - Server_Script format

Post by isse »

Thanks man, really apriciate taking your time to help.
With that help i could understand how to configre the server settings and now it runs perfect!
I have created a task that runs the poller and that works fine also, it creates the result file and it has all my 4 ports on the flexlm server listed with all the applications and packages that are included in those.

So accourding to your instruction readme, i need to add the flexlm server in cacti and change the snmp port to the flexlm port, but i have several ports, do i need to add one device per port for this server then ?

Thanks
/Isse
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Re: FLEXlm Template and Script - Server_Script format

Post by super-hornet »

Each FLEXlm license server consists of a few ports. But to query the FLEXlm info, u only need to query a specific port of that lmgrd's port....which is the main port.

Open up your FLEXlm's license file (or use the Windows's FLEXlm manager). You should able to find the main port.

Each FLEXlm license server uses an individual port. Two different FLEXlm license cannot share the same port.

One server (or 3 clustered server) can host multiple FLEXlm license server. Take example,
Lets say you have 2 servers that are called "hydrogen" and "helium".
In "helium", u have 2 FLEXlm license server daemon running. (or host 2 FLEXlm license server). Those 2 FLEXlm license servers are:
1. AutoDesk AutoCAD...which assuming u configured as port 1700
2. Mathworks Matlab...which assuming u configured as port 2700.

In your "hydrogen" server, u have another 2 FLEXlm daemon running..and lets assuming it is:
1. CADENCE...which assuming u configured as port 5280
2. Synopsys...which assuming u configured as port 1717

So, your "flexlm_server_config.php" will be like this:
<?php
$servers["helium"] = array("1700", "2700");
$servers["hydrogen"] = array("5280", "1717");

$servers_flexlm_vendor["helium"] = array(
"1700" => "AutoDesk AutoCAD",
"2700" => "Mathworks Matlab",
);
$servers_flexlm_vendor["hydrogen"] = array(
"5280" => CADENCE",
"1717" => "Synopsys",
);

?>
super-hornet
Cacti User
Posts: 175
Joined: Sun May 27, 2007 5:42 pm

Re: FLEXlm Template and Script - Server_Script format

Post by super-hornet »

Oops! Oh.. u are asking on how to add the server in the cacti! Misread your post :)
Anyway, the above explain on how to add multiple server so that the poller can query it.

In your cacti, each FLEXlm license server daemon that u want to query, u assume it is like a system u want to monitor.

So lets say your "helium" server has 2 FLEXlm license server daemon u want to monitor...and that is:
1. AutoDesk AutoCAD on port 1700
2. Mathworks Matlab on port 2700

So, in your cacti, u add new system to monitor with:
host description = AutoDesk AutoCAD.
hostname = helium.
SNMP port = 1700
Choose whatever license features of AutoDesk AutoCAD that you want to monitor and plot the graphs on each features.

Then, create another system again with:
host description = Mathwork Matlab.
hostname = helium.
SNMP port = 2700
Choose whatever license features of Mathwork Matlab that you want to monitor and plot the graphs on each features.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests