Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
Directory
Gidy
byGidy, October 11, 2016
I changed the function to generates also performance data. Also i changed the lmstat perameter -A to -a
sub owc_stat {
my $lmstat_output = shift;
my $output;
# Split the lines of $lmstat_output at the newlines.
my @lmstat_lines = split /
/, $lmstat_output;
my $red_flag = 0;
my $yellow_flag = 0;
my $yellow_feats = [];
my $features = 0;
my $performanceData = "|";
for (@lmstat_lines)
{
if ($features eq 0)
{
$red_flag ++ if ((/[Cc]annot/)||(/[Uu]nable/)||(/refused/)||(/down/)||(/[Ww]in[sS]ock/));
}
else
{
if (/Users of (.*): .* of ([0-9]+) .* issued; .* of ([0-9]+) .* use/)
{
my $available_licenses = $2 - $3;
if ($available_licenses eq 0)
{
$yellow_flag ++;
push @$yellow_feats, $1;
}
}
}
#Create Perfromance Data
if (/Users of (.*): .* of ([0-9]+) .* issued; .* of ([0-9]+) .* use/)
{
my $tempPerfDat={};
$performanceData.="$1=$3;;;0;$2 ";
}
#if ($curfile =~ /.+_[0-9]{4}.([a-zA-Z]{3,4}).Z$/)
$features ++ if (/Feature usage info:/)||(/Users of features served by $vendor:/);
}
if ($red_flag > 0)
{
$output = "FLEXlm CRITICAL: License Server Down or Unreachable.";
}
elsif ($yellow_flag > 0)
{
$output = "FLEXlm WARNING: Maximum Usage Warning for Features: ";
for my $feat (@$yellow_feats)
{
$output .= $feat . " ";
}
}
else
{
$output = "FLEXlm OK: Server is up. All Modules/Features Available.";
}
$output.=$performanceData;
$output .= "
";
return ($output);
}
sub owc_stat {
my $lmstat_output = shift;
my $output;
# Split the lines of $lmstat_output at the newlines.
my @lmstat_lines = split /
/, $lmstat_output;
my $red_flag = 0;
my $yellow_flag = 0;
my $yellow_feats = [];
my $features = 0;
my $performanceData = "|";
for (@lmstat_lines)
{
if ($features eq 0)
{
$red_flag ++ if ((/[Cc]annot/)||(/[Uu]nable/)||(/refused/)||(/down/)||(/[Ww]in[sS]ock/));
}
else
{
if (/Users of (.*): .* of ([0-9]+) .* issued; .* of ([0-9]+) .* use/)
{
my $available_licenses = $2 - $3;
if ($available_licenses eq 0)
{
$yellow_flag ++;
push @$yellow_feats, $1;
}
}
}
#Create Perfromance Data
if (/Users of (.*): .* of ([0-9]+) .* issued; .* of ([0-9]+) .* use/)
{
my $tempPerfDat={};
$performanceData.="$1=$3;;;0;$2 ";
}
#if ($curfile =~ /.+_[0-9]{4}.([a-zA-Z]{3,4}).Z$/)
$features ++ if (/Feature usage info:/)||(/Users of features served by $vendor:/);
}
if ($red_flag > 0)
{
$output = "FLEXlm CRITICAL: License Server Down or Unreachable.";
}
elsif ($yellow_flag > 0)
{
$output = "FLEXlm WARNING: Maximum Usage Warning for Features: ";
for my $feat (@$yellow_feats)
{
$output .= $feat . " ";
}
}
else
{
$output = "FLEXlm OK: Server is up. All Modules/Features Available.";
}
$output.=$performanceData;
$output .= "
";
return ($output);
}