flexlm 라이선스 모니터링 스크립트

#!/usr/bin/perl

use strict;
use Switch;

my $lmutil = ‘/APP/abaqus/License/lmutil’;

sub usage {
print <<_END_USAGE_;
This utility uses the ‘lmutil’ application to gather information from FlexLM.
You must have ‘lmutil’ installed and accessible. This utility only returns
either the number of issued licenses or the number of licenses in use.

Usage:
lmstat.pl -H <hostname> -p <port> -f <feature> (–issued|–used)
-H <hostname>
The hostname or IP address of the license server

-p <port>
The port number for the license you want to gather information for.

-f <feature>
Feature name

(–issued|–used)
Specify which statistic you want want information for.

_END_USAGE_
exit;
}

if ($ARGV[0] eq ‘–help’) {
usage();
}

# Get configuration information for the running of this script
my ($hostname, $port, $feature, $stat);
while (my $s = shift(@ARGV)) {
switch($s) {
case “-H” { $hostname = shift(@ARGV); }
case “-p” { $port = shift(@ARGV); }
case “-f” { $feature = shift(@ARGV); }
case “–issued” { $stat = ‘issued’; }
case “–used” { $stat = ‘used’; }
else { print “INVALID SYNTAX\n\n”; usage(); }
}
}

my $lmstat_out = `$lmutil lmstat -f $feature -c $port\@$hostname`;

my $value = “”;
foreach my $line (split(“\n”, $lmstat_out)) {
if ($line =~ /Users of \Q$feature\E:.+Total of ([0-9]+) licenses? issued;\s+Total of ([0-9]+) licenses? in use/) {
switch ($stat) {
case “issued” { $value = $1; }
case “used” { $value = $2; }
}
}
}

# We do this because we can’t seem to trigger on ‘nodata’
if ($stat eq ‘issued’ && $value eq ”) {
# If we’re looking for how many licenses are issued and we got nothing,
# then return a value of ‘0’. Keep the blank (error) for used licenses.
$value = 0;
}

print “$value\n”;

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...