FLEXlm Template and Script - Server_Script format

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

Moderators: Developers, Moderators

sky_qwienz
Posts: 7
Joined: Thu Feb 10, 2011 9:00 pm

Re: FLEXlm Template and Script - Server_Script format

Post by sky_qwienz »

hi... im having some problem in my license server

in my lmgrd-poller.pl....

have an error which is :-

Can't locate Tie/ShareLite.pm @INC (@INC contains : usr/lib64/perl5/5.85/x86_64_linux-thread-multi usr/lib/perl5....................) at usr/local/sbin/lmgrd-poller.pl at line 6
BEGIN FAILED--compilation aborted at usr/local/sbin/lmgrd-poller.pl line 6


what is the key of tie sharelite?
what is the mode of tie sharelite?

pliz help me :wink:
Attachments
error-synopsys.png
error-synopsys.png (111.01 KiB) Viewed 4984 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 »

hi... im having some problem in my license server

in my lmgrd-poller.pl....

have an error which is :-

Can't locate Tie/ShareLite.pm...
U must be posting on the wrong thread. The one u are using is using the perl version. It is not for this version.

The reason I wrote this script (using PHP) is because of the above problem of dependency of multiple perl libraries required to run the perl version.

U either use the perl version (but for your case, u need to install the required perl libraries) or use this PHP version.

SH
noum
Posts: 3
Joined: Tue Feb 15, 2011 12:23 pm

Re: FLEXlm Template and Script - Server_Script format

Post by noum »

Hi super-hornet,

thanks for your scripts. they will be useful for me if they'll working in my case. I explain:
after installing them in my cacti server (nb: i've checked the files permissions files, defined the poller's cron, and modify the scripts with my flexlm servers, lmutil path), hosts graphs that i've created return '-nan' values instead of data. In the poller's log, CACTI2RRD updates in the rrd files with values.(inuse and total data are correctly returned by the data query ss_flexlm....)

And at the end, graphs are empty (-nan values)

do you already seen that kind of problem.

thanks in advance

PS : is there a re-index method particular? i've set to 'none' or 'Uptime to Backwards' to my hosts without results. (my version of cacti is 0.8.7g)
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 »

Check your poller (from cron) result file (the "flexlm_lmstat_result.php" file). Open it and see the contents.
If there is a result, then your cron and poller section is working.

U should have something like your license's feature, the total value and the inused valued.

If your poller result is working (the "flexlm_lmstat_result.php" file has the values), then I suspect it is the same old bug of 0.8.7g whereby, when u import the templates, the "<", ">" and the "|" value did not get import in.

Check your "Console->Collection Methods->Data Queries" and look for the "FLEXlm License Usage".

When u click on it, I suspect it may tell u the missing XML file due to missing "<>" field.

Under the "XML Path", u should have something like this:
<path_cacti>/resource/script_server/flexlm_lmstat.xml |host_hostname| |host_snmp_port|

If not, then just add the missing "<, > and |" characters.

SH
sky_qwienz
Posts: 7
Joined: Thu Feb 10, 2011 9:00 pm

Re: FLEXlm Template and Script - Server_Script format

Post by sky_qwienz »

hello...

but can i have to download required perl lib likes perl-xml_parser or perl-mysql or another perl???

can i have a link that to download required perl that can solve my problem which is cannot locate tie sharelite??

pliz help me..this script lmgrd-poller have problem...i dont know how to link from license server to cacti...

*require help :roll:
noum
Posts: 3
Joined: Tue Feb 15, 2011 12:23 pm

Re: FLEXlm Template and Script - Server_Script format

Post by noum »

hi,

here my results :
super-hornet wrote:Check your poller (from cron) result file (the "flexlm_lmstat_result.php" file). Open it and see the contents.
If there is a result, then your cron and poller section is working.
i have results. here a sample

Code: Select all

$flexlm_licenses["dfs03.domain"]=array();
$flexlm_licenses["dfs03.domain"][0]="1055";
$flexlm_licenses["dfs03.domain"][1]="1999";
$flexlm_licenses["dfs03.domain"][2]="27000";
$flexlm_licenses["dfs03.domain"][3]="27500";
$flexlm_licenses["dfs03.domain"][4]="28000";
$flexlm_licenses["dfs03.domain"][1055]=array();
$flexlm_licenses["dfs03.domain"][1055]["aa_ds"]=array("total"=>"50","inuse"=>"0");
$flexlm_licenses["dfs03.domain"][1055]["aa_mcad"]=array("total"=>"50","inuse"=>"0");
$flexlm_licenses["dfs03.domain"][1055]["aa_t_i"]=array("total"=>"50","inuse"=>"4");
super-hornet wrote:
U should have something like your license's feature, the total value and the inused valued.

If your poller result is working (the "flexlm_lmstat_result.php" file has the values), then I suspect it is the same old bug of 0.8.7g whereby, when u import the templates, the "<", ">" and the "|" value did not get import in.

Check your "Console->Collection Methods->Data Queries" and look for the "FLEXlm License Usage".

When u click on it, I suspect it may tell u the missing XML file due to missing "<>" field.

Under the "XML Path", u should have something like this:
<path_cacti>/resource/script_server/flexlm_lmstat.xml |host_hostname| |host_snmp_port|

If not, then just add the missing "<, > and |" characters.
Under the "XML Path", i have this string : <path_cacti>/resource/script_server/flexlm_lmstat.xml
(cacti says that xml is found)
there are no '|host_hostname| |host_snmp_port|' at the end of the string
super-hornet wrote:
SH
to help you, here a sample of cacti's log :

Code: Select all

02/16/2011 05:20:02 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /var/www/cacti-0.8.7g/rra/dfs03_-_ansys_total_317.rrd --template inuse:total 1297873202:4:50
02/16/2011 05:20:02 PM - CMDPHP: Poller[0] Host[35] DS[317] SERVER: /var/www/cacti-0.8.7g/scripts/ss_flexlm_lmstat_query.php ss_flexlm_lmstat_query dfs03.domain 1055 get inuse aa_t_i, output: 4
02/16/2011 05:20:02 PM - PHPSVR: Poller[0] DEBUG: PID[29977] CTR[7] INC: 'ss_flexlm_lmstat_query.php' FUNC: 'ss_flexlm_lmstat_query' PARMS: 'dfs03.domain 1055 get inuse aa_t_i'
02/16/2011 05:20:02 PM - PHPSVR: Poller[0] DEBUG: PID[29977] CTR[6] RESPONSE:''
02/16/2011 05:20:02 PM - CMDPHP: Poller[0] Host[35] DS[317] SERVER: /var/www/cacti-0.8.7g/scripts/ss_flexlm_lmstat_query.php ss_flexlm_lmstat_query dfs03.domain 1055 get total aa_t_i, output: 50
02/16/2011 05:20:02 PM - PHPSVR: Poller[0] DEBUG: PID[29977] CTR[6] INC: 'ss_flexlm_lmstat_query.php' FUNC: 'ss_flexlm_lmstat_query' PARMS: 'dfs03.domain 1055 get total aa_t_i' 
also here a sample of the rrdtool fetch command on the rrd file :

Code: Select all

cactiuser@dsi-fxlm:/var/www/cacti-0.8.7g/rra$ rrdtool fetch dfs03_-_ansys_total_317.rrd AVERAGE
                          total               inuse

1297787400: -nan -nan
1297787760: -nan -nan
1297788120: -nan -nan
1297788480: -nan -nan
1297788840: -nan -nan
1297789200: -nan -nan
1297789560: -nan -nan
1297789920: -nan -nan
1297790280: -nan -nan
1297790640: -nan -nan
1297791000: -nan -nan
1297791360: -nan -nan
1297791720: -nan -nan
1297792080: -nan -nan
1297792440: -nan -nan
1297792800: -nan -nan
1297793160: -nan -nan
1297793520: -nan -nan
...

1297870920: -nan -nan
1297871280: -nan -nan
1297871640: -nan -nan
1297872000: -nan -nan
1297872360: -nan -nan
1297872720: -nan -nan
1297873080: -nan -nan       <<< from the rrdtool update sample below, there is no value 1297873202:4:50 in the file
1297873440: -nan -nan
1297873800: -nan -nan
....

is it due to to step value (you set it at 60), the other rras are set to 300 (they have working graphs with values)??

thanks for your answers.

mnpg
noum
Posts: 3
Joined: Tue Feb 15, 2011 12:23 pm

Re: FLEXlm Template and Script - Server_Script format

Post by noum »

Hi super-hornet,

forget my questions.

It's works!
sky_qwienz
Posts: 7
Joined: Thu Feb 10, 2011 9:00 pm

Re: FLEXlm Template and Script - Server_Script format

Post by sky_qwienz »

hello...

i want to ask...

how to turn off selinux? somebody please help me. tq.

i will appreciated it. :roll:
sky_qwienz
Posts: 7
Joined: Thu Feb 10, 2011 9:00 pm

Re: FLEXlm Template and Script - Server_Script format

Post by sky_qwienz »

hello superhonet..

I want to ask u about this script...

how to find flexlm_lmstat_result.php ???

Is this file generate itself ?? the file that you have given don't have this file.....

Can you help me? for your information, my cacti is in FreeBSD Unix and I don't use etc/cron.d but I'm using etc/periodic/daily to run it...

Hope u can help me :) :)
dmcritchie
Posts: 1
Joined: Fri Apr 29, 2011 1:48 pm

Re: FLEXlm Template and Script - Server_Script format

Post by dmcritchie »

Hi Super-Hornet,

Thanks for the very useful scripts. I think though that the code is incorrect for the RESERVATION case in flexlm_poller.php:

Code: Select all

else if ( eregi(" RESERVATION", $line ) ){
	$data_exists_flag = TRUE;
	$featureflag = 0; $userflag = 1;
	if ($specialflag == 1)
		$flexlm_licenses[$server][$port][$feature][$license_in_used] += $out[1];
}
In this case, $out[1] is not assigned a proper value. That is, there would be a value left over from a previous preg_match(), but it would always be assigned the value "Users of", which I'm sure is not what you intended. I'm guessing that you meant to pass $out as a 3rd argument to eregi(), and that the regular expression should be more complex and have a parenthesized clause in it. But since I have no examples of the RESERVATION feature in action, I don't know what the lmstat output would look like in this case.

I know you wrote earlier that you had not tested this feature, but wondered if you knew what the lmstat output should look like.

Thanks,
Dennis
coiter
Posts: 2
Joined: Mon Sep 07, 2015 6:31 am

Re: FLEXlm Template and Script - Server_Script format

Post by coiter »

Are there any updates to this script or newer versions that can handle this?

im not able to create the RRD files due to the trailing slash on the debug info, but i can confirm it pulls info from flex server, and is able to create the graphs based on details pulled from the flexlm server.

its just the create debug that fails, being new to cacti and this is a 4 year old script i might be missing something.

Data Source Debug
/usr/bin/rrdtool create \
/usr/share/cacti/rra/autocad_total_11.rrd \
--step 300 \
DS:total:GAUGE:600:0:U \
DS:inuse:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797 \
marcelolemos
Posts: 1
Joined: Wed Jan 31, 2018 12:45 pm

Re: FLEXlm Template and Script - Server_Script format

Post by marcelolemos »

I found a issue to run flexlm_poller.php on PHP 7 environment.

The error was:
PHP Fatal error: Uncaught Error: Call to undefined function eregi() in /usr/share/cacti/site/scripts/flexlm_poller.php_bkp:46
Stack trace:
#0 {main}
thrown in /usr/share/cacti/site/scripts/flexlm_poller.php_bkp on line 46
An the problem was on eregi php function that is deprecated on PHP7.

So I just replaced this function to preg_match and made some changes on expression and the new code is:

Code: Select all

<?php
/*
  Cacti query script. Poll FLEXlm licenses usage and write to file.
  Description: Poll FLEXlm licenses usage and write to file.
  Version, Date: Ver 3.11, Build 06. Jan 19, 2011, 17:10pm
  Version, Date: Ver 3.1, Aug 20, 2008, 16:29pm
  Created by: Ching Hock Tay
*/

include "flexlm_server_config.php";         // This is the FLEXlm server configuration.
include "flexlm_poller_config.php";         // This is the configuration file.
include "array_to_file.php";                // Library to write back to file.

$flexlm_licenses = $servers;

foreach ($servers as $server => $ports) {
	foreach ($ports as $port) {
		$data_exists_flag = FALSE;
		$lmstat_result = get_lmstat($server, $port, $lmstat);

		$featureflag = 0; $userflag = 0; $specialflag = 0; $feature = "unknown";
		$usedcounter = 0; $counter = 0;
		foreach ($lmstat_result as $line) {
			if ( preg_match('/(Users of) (.*):\s+(\(Uncounted, node-locked\))/i', $line, $out) && !preg_match("/No such feature exists/i", $line) ) {
				$data_exists_flag = TRUE;
				// Users of certitude-simulation:  (Uncounted, node-locked)
				// New feature found. Special feature "Uncounted, node-locked"
				$featureflag = 1; $specialflag = 1; $userflag = 0;
				$feature = $out[2]; $total = 0; $inuse = 0;
				// Initialize array.
				$flexlm_licenses[$server][$port][$feature] = array();
				$flexlm_licenses[$server][$port][$feature][$total_license] = $total;
				$flexlm_licenses[$server][$port][$feature][$license_in_used] = $inuse;
			}
			else if ( preg_match('/(Users of) (.*):\s+(\(Total of) (\d+) (.*) (Total of) (\d+) /i', $line, $out) && !preg_match("/No such feature exists/i", $line) ) {
				$data_exists_flag = TRUE;
				// Users of STSEAT11:  (Total of 92 licenses issued;  Total of 91 licenses in use)
				// New feature found. Normal feature.
				$featureflag = 1; $specialflag = 0; $userflag = 0;
				$feature = $out[2]; $total = $out[4]; $inuse = $out[7];
				// Initialize array.
				$flexlm_licenses[$server][$port][$feature] = array();
				$flexlm_licenses[$server][$port][$feature][$total_license] = $total;
				$flexlm_licenses[$server][$port][$feature][$license_in_used] = $inuse;
			}
			else if ( preg_match("/, start/i", $line ) ) {
				$data_exists_flag = TRUE;
				if ($specialflag == 1)
					$flexlm_licenses[$server][$port][$feature][$license_in_used] += 1;
			}
			else if ( preg_match("/ RESERVATION/i", $line ) ){
				$data_exists_flag = TRUE;
				$featureflag = 0; $userflag = 1;
				if ($specialflag == 1)
					$flexlm_licenses[$server][$port][$feature][$license_in_used] += $out[1];
			}
		} // foreach ($lmstat_result as $line)
		
		if ($data_exists_flag == TRUE) {
		  ksort($flexlm_licenses[$server][$port]);
		}
	} // foreach (array_keys($servers[$server]) as $port)
} // foreach ($servers as $server)


// Write result to file in order for flexlm_query to query on.
$file=fopen($flexlm_result,"w");
fwrite($file,"<?php\r\n");
set_array_to_file($file,$servers,"\$servers");
set_array_to_file($file,$servers_flexlm_vendor,"\$servers_flexlm_vendor");
set_array_to_file($file,$flexlm_licenses,"\$flexlm_licenses");
fwrite($file,"?>");

function get_lmstat($server, $port, $lmstat) {
  $lmstat = str_replace("%port%", $port, $lmstat);
  $lmstat = str_replace("%server%", $server, $lmstat);

  $filehandle = popen($lmstat, "r");
  $hugearray = array();

  if ($filehandle) {
    while ( !feof($filehandle) ) {
      $buffer = trim( fgets($filehandle, 4096) );
      if ( ($buffer == "\n") || ($buffer == "") ){
	continue;
      }
      $hugearray[] = $buffer;
    }
  }
  pclose($filehandle);
  return $hugearray;
}

?>
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests