LSF Matlab ELIM
Jump to navigation
Jump to search
#!/usr/bin/perl
#######################################################
#
# Basic FLEXlm license monitoring script
# Platform Computing, Inc
# This is an example and unsupported. You need to modify
# to run in your environment
#
#######################################################
@featurelist = ( "MATLAB" );
%featurehash = ("MATLAB" => "matlab");
$| = 1; # flush output buffer
$featurecnt = 0;
foreach $name (@featurelist) {
$featurecnt++;
};
while (1) {
@input = ();
$outstring = "";
$avail_lics = 0;
$licserverstatus = 0;
if ( $ENV{LSF_MASTER} eq Y ) {
# modify the location of where lmstat is and where your license server(s) are
open(OUTPUT, '/usr/local/LSF/7.0/linux2.6-glibc2.3-x86_64/etc/lmstat -c \
27010@rhrcsque1:27010@rhrcsque2:27010@acamar \
-f MATLAB |') or $licserverstatus = 1;
if ( $licserverstatus == 0 ) {
while (<OUTPUT>) {
chomp;
if ($_ =~ /Users of/) {
push(@input, $_);
}
}
close(OUTPUT);
foreach $name (@featurelist) {
$avail_lics = &LicCnt;
$outstring .= %featurehash->{$name}." ".$avail_lics." ";
};
print "$featurecnt $outstring\n";
}
else {
close(OUTPUT);
foreach $name (@featurelist) {
$avail_lics = &LicCnt;
$outstring .= %featurehash->{$name}." "."-9999"." ";
};
print "$featurecnt $outstring\n";
}
}
else {
foreach $name (@featurelist) {
$outstring .= %featurehash->{$name}." "."0"." ";
};
print "$featurecnt $outstring\n";
}
sleep(15);
}
sub LicCnt {
my $issued = 0;
my $used = 0;
my $available = 0;
foreach $line (@input) {
if ($line =~ /Users of ${name}.+Total of (\d+).+Total of (\d+)/) {
$issued = ($issued + $1);
$used = ($used + $2);
}
}
$available = $issued - $used;
return($available);
}