(notes added by Steve S)
This Host template also adds extended directives for the Big Brother agent - if you don't use Big Brother you can safely ignore these as the template will still work correctly.
It requires you to have the MIBs
ups.mib,
LIEBERT_GP_REG.MIB and
LIEBERT_GP_POWER.MIB installed in /usr/share/snmp/mibs for it to work correctly.
Code:
$head_lines .= <<ECHO
#.....................................................................
ECHO
;
my $target_name=$router_name.".min";
my ( $maxmins, $maxsec, $absmin, $yellowvolts, $redvolts, $absvolts, @basis );
snmpMIB_to_OID("/usr/share/snmp/mibs/ups.mib");
snmpMIB_to_OID("/usr/share/snmp/mibs/LIEBERT_GP_REG.MIB");
snmpMIB_to_OID("/usr/share/snmp/mibs/LIEBERT_GP_POWER.MIB");
my ($model) = snmpget($router_connect,"upsIdentModel.0");
my ($version) = snmpget($router_connect,"upsIdentAgentSoftwareVersion.0");
push @basis, 'upsEstimatedMinutesRemaining.0';
push @basis, 'upsConfigInputVoltage.0';
push @basis, 'upsConfigOutputVoltage.0';
push @basis, 'upsInputNumLines.0';
push @basis, 'upsOutputNumLines.0';
push @basis, 'upsConfigOutputFreq.0';
push @basis, 'upsConfigOutputVA.0' if $model !~ /Nfinity/;
#push @basis, 'lgpPwrLineMeasurementVoltsLL.3.1' if $model !~ /Nfinity/ and $version !~ /^(1|2.0)/;
my ($remain,$volts,$ovolts,$ilines,$olines,$freq,$va)=
snmpget($router_connect,@basis);
my ($two,$two6k);
($two) = snmpget($router_connect,"lgpPwrLineMeasurementVoltsLL.3.1") if $version !~ /^[12]/;
($two6k) = snmpget($router_connect,"lgpPwrLineMeasurementVolts.3.1") if $version !~ /^1/;
if ($model =~ /Nfinity/ and not defined($va)) {
$va =20000;
}
if (defined($two)) {
$volts = $two;
$ovolts =$two;
$ilines = 1;
$olines = 1;
} elsif (defined($two6k)) {
$volts = $two6k;
$ovolts = $two6k;
$ilines = 1;
$olines = 1;
} elsif ($model =~ /GXT2-6000RT208/) {
$volts=208;
$ovolts=120;
$ilines = 1;
$olines = 1;
}
if ($remain) {
$maxmins = int($remain / .9);
$maxsec = $maxmins * 60;
$absmin = $remain * 10;
}
else {
$maxmins= 510;
$maxsec= $maxmins * 60;
$absmin = 1000;
}
if ($volts) {
if ($volts != $ovolts) {
$yellowvolts = int($volts/1.10) . ":" . int($volts/.9)
. ":" . int($ovolts/1.10) . ":" . int($ovolts/.9);
$redvolts = int($volts/1.2) . ":" . int($volts/.8)
. ":" . int($ovolts/1.20) . ":" . int($ovolts/.8);
$absvolts = $volts*2;
}
else {
$yellowvolts = int($volts/1.10) . ":" . int($volts/.9);
$redvolts = int($volts/1.2) . ":" . int($volts/.8);
$absvolts = $volts*2;
}
}
else {
$volts=120;
$yellowvolts = "114:126";
$redvolts = "109:135";
$absvolts= 240;
}
$target_lines .= <<MINUTES
Target[$target_name]: upsEstimatedMinutesRemaining.0&upsEstimatedMinutesRemaining.0:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: upsmin
bb*yellow[$target_name]: 60:$absmin
bb*red[$target_name]: 30:$absmin
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $maxmins
AbsMax[$target_name]: $absmin
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: UPS Estimated Run Time
YLegend[$target_name]: minutes
ShortLegend[$target_name]: m
LegendI[$target_name]: remaining
PageTop[$target_name]: <H1>UPS Estimated Run-Time</H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
MINUTES
;
$target_name=$router_name.".sec";
$target_lines .= <<SECONDS
#.....................................................................
Target[$target_name]: upsSecondsOnBattery.0&upsSecondsOnBattery.0:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: upsrun
bb*yellow[$target_name]: 300
bb*red[$target_name]: 600
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $maxsec
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: UPS Actual Run Time
YLegend[$target_name]: seconds
ShortLegend[$target_name]: s
LegendI[$target_name]: run time
PageTop[$target_name]: <H1>UPS Actual Time on Battery</H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
SECONDS
;
my $i = 0;
while ( ++$i le $ilines) {
$target_name=$router_name.".volt";
my $phase = '';
$target_name=$router_name.".volt.".$i if $ilines > 1;
$phase = "Phase # $i" if $ilines > 1;
my $custtarg = <<STANDARD
Target[$target_name]: upsInputVoltage.$i&upsOutputVoltage.$i:$router_connect
STANDARD
;
if (defined($two) ) {
$custtarg =<<NEWMIB
Target[$target_name]: lgpPwrLineMeasurementVoltsLL.1.1&lgpPwrLineMeasurementVoltsLL.3.1:$router_connect
NEWMIB
;
} elsif (defined($two6k)) {
$custtarg =<<6KMIB
Target[$target_name]: lgpPwrLineMeasurementVolts.1.1&lgpPwrLineMeasurementVolts.3.1:$router_connect
6KMIB
;
}
$target_lines .= <<VOLTAGE
#.....................................................................
$custtarg
bb*host[$target_name]: $router_name
bb*svc[$target_name]: voltage
bb*yellow[$target_name]: $yellowvolts
bb*red[$target_name]: $redvolts
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $volts
AbsMax[$target_name]: $absvolts
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge
Title[$target_name]: UPS Voltages $phase
YLegend[$target_name]: volts
ShortLegend[$target_name]: vac
LegendI[$target_name]: input
LegendO[$target_name]: output
PageTop[$target_name]: <H1>UPS Voltages $phase </H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
VOLTAGE
;
}
($volts) = snmpget($router_connect,'upsBatteryVoltage.0');
if ($volts) {
$yellowvolts = int($volts/10.5) . ":" . int($volts/9.5);
$redvolts = int($volts/11) . ":" . int($volts/9);
$absvolts = int($volts/7);
$volts = int($volts/10);
}
else {
$volts=55;
$yellowvolts = "52:57";
$redvolts = "48:60";
$absvolts= 80;
}
$target_name=$router_name.".batt";
$target_lines .= <<BATTERY
#.....................................................................
Target[$target_name]: upsBatteryVoltage.0&upsBatteryVoltage.0:$router_connect / 10
bb*host[$target_name]: $router_name
bb*svc[$target_name]: voltage
bb*red[$target_name]: $redvolts
bb*yellow[$target_name]: $yellowvolts
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $volts
AbsMax[$target_name]: $absvolts
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: UPS Battery Voltage
YLegend[$target_name]: volts
ShortLegend[$target_name]: vdc
LegendI[$target_name]: battery level
PageTop[$target_name]: <H1>UPS Battery Voltage</H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
BATTERY
;
if (($version !~ /^(1|2.0)/) and ($model !~ /Npower/)) {
$target_name=$router_name.".current";
my $redcurrent = int($va/1.1);
my $yelcurrent = int($va/1.6);
$target_lines .= <<CURRENT
#.....................................................................
Target[$target_name]: lgpPwrMeasurementPointApparentPower.3&lgpPwrMeasurementPointApparentPower.3:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: current
bb*yellow[$target_name]: $yelcurrent
bb*red[$target_name]: $redcurrent
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $va
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: UPS Current
YLegend[$target_name]: va
ShortLegend[$target_name]: va
LegendI[$target_name]: input
LegendO[$target_name]: output
PageTop[$target_name]: <H1>UPS Current </H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
CURRENT
;
} else {
$i = 0;
while (++$i le $ilines) {
my $addgraph;
$target_name=$router_name.".current";
my $redcurrent = int($va/1.1);
my $yelcurrent = int($va/1.6);
my $multgraph = $target_name;
my $phase = '';
$target_name=$router_name.".current.".$i if $ilines > 1;
$phase = "Phase # $i" if $ilines > 1;
$addgraph = "routers.cgi*Graph[$target_name]: $multgraph total"
if $ilines > 1;
my $custarget = <<TARSINGLE
Target[$target_name]: upsOutputVoltage.$i&upsOutputVoltage.$i:$router_connect
* upsOutputCurrent.$i&upsOutputCurrent.$i:$router_connect / 10
TARSINGLE
;
$custarget = <<TARMULTIPLE
Target[$target_name]: upsInputVoltage.$i&upsOutputVoltage.$i:$router_connect
* upsInputCurrent.$i&upsOutputCurrent.$i:$router_connect / 10
TARMULTIPLE
if $ilines > 1;
my $noi ='';
$noi = 'noi' if $ilines >1;
$target_lines .= <<CURRENT
#.....................................................................
$custarget
bb*host[$target_name]: $router_name
bb*svc[$target_name]: current
bb*yellow[$target_name]: $yelcurrent
bb*red[$target_name]: $redcurrent
routers.cgi*Options[$target_name]: nototal
$addgraph
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $va
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge $noi
Title[$target_name]: UPS Current $phase
YLegend[$target_name]: va
ShortLegend[$target_name]: va
LegendI[$target_name]: input
LegendO[$target_name]: output
PageTop[$target_name]: <H1>UPS Current $phase </H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
CURRENT
;
}
}
$target_name=$router_name.".freq";
$freq = $freq / 10;
my $freqlow = $freq - .4;
my $freqyel = $freq - .2;
my $freqhigh = $freq + .4;
my $freqyeh = $freq + .2;
my $freqmax = int($freq /.9);
$target_lines .= <<FREQ
#.....................................................................
Target[$target_name]: upsOutputFrequency.0&upsOutputFrequency.0:$router_connect / 10
bb*host[$target_name]: $router_name
bb*svc[$target_name]: freq
bb*red[$target_name]: $freqlow:$freqhigh
bb*yellow[$target_name]: $freqyel:$freqyeh
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $freq
AbsMax[$target_name]: $freqmax
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: UPS Frequency
YLegend[$target_name]: Hertz
ShortLegend[$target_name]: Hz
LegendI[$target_name]: Frequency
PageTop[$target_name]: <H1>UPS Output Frequency</H1>
<TABLE>
<TR><TD>System:</TD><TD>$sysname </TD></TR>
<TR><TD>Location:</TD><TD>$syslocation </TD></TR>
</TABLE>
FREQ
;
$target_name=$router_name.".source";
$target_lines .= <<SOURCE
#.....................................................................
Target[$target_name]: upsOutputSource.0&upsOutputSource.0:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: source
bb*red[$target_name]: 2.1:3.9
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 7
AbsMax[$target_name]: 10
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Output Source
YLegend[$target_name]: Source
ShortLegend[$target_name]: Source
LegendI[$target_name]: Source
PageTop[$target_name]: <H1>UPS Output Source</H1>
<TABLE>
<tr><td>1</td><td>Other</td>
<tr><td>2</td><td>None</td>
<tr><td>3</td><td>Normal</td>
<tr><td>4</td><td>Bypass</td>
<tr><td>5</td><td>Battery</td>
<tr><td>6</td><td>Booster</td>
<tr><td>7</td><td>Reducer</td>
</TABLE>
SOURCE
;