[mrtg] WxGoos-1 & MRTG

McDonald, Dan Dan.McDonald at austinenergy.com
Thu Jun 5 15:03:33 CEST 2008


On Wed, 2008-06-04 at 13:05 -0400, Wixted, Joe wrote:

> I’m using routers2 as my front end…  If you have questions or
> improvements, let me know!

We deployed a number of probes from a couple of vendors, but eventually
settled on the IT watchdogs.  They have had a couple of bugs where
sometimes you would need to poll the OID with an instance, and sometimes
without an instance.  That bug came and went through a number of
versions, so I wrote this template to figure it all out for me.  It's
currently generating working configs for 91 probes.

The template is attached.
-- 
Daniel J McDonald, CCIE #2495, CISSP #78281, CNX
Austin Energy
http://www.austinenergy.com

-------------- next part --------------
$head_lines .= <<ECHO
#.....................................................................
ECHO
;

my ($target_name, $tid, $hid);
my ($hostoid) = snmpget($router_connect,'sysObjectID');
if ($hostoid eq "1.3.6.1.4.1.3854.1.2.2.1.1") {
	snmpMIB_to_OID("/usr/share/snmp/mibs/sa.mib");
	my (@temp) = snmpwalk($router_connect,'hhmsSensorArrayTempOnline');
	foreach my $tempi (@temp) {
		if ($tempi =~ /(\d):1/) {
			$tid = $1;
			$target_name=$router_name.".temp.".$tid;
$target_lines .= <<TEMP
Target[$target_name]: hhmsSensorArrayTempDegree.$tid&hhmsSensorArrayTempDegree.$tid:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: temp
bb*yellow[$target_name]: 83
bb*red[$target_name]: 88
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 185
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe temperature gauge
YLegend[$target_name]: degrees F
ShortLegend[$target_name]: F
PageTop[$target_name]: <H1>Temperature</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
TEMP
;
		}
	}
	my (@hum) = snmpwalk($router_connect,'hhmsSensorArrayHumidityOnline');
	foreach my $humi (@hum) {
		if ($humi =~ /(\d):1/) {
			$hid = $1;
			$target_name=$router_name.".hum.".$hid;
$target_lines .= <<HUMIDITY
Target[$target_name]: hhmsSensorArrayHumidityPercent.$hid&hhmsSensorArrayHumidityPercent.$hid:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: humidity
bb*yellow[$target_name]: 17:80
bb*red[$target_name]: 12:85
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe humidity gauge
YLegend[$target_name]: relative humidity
ShortLegend[$target_name]: %
PageTop[$target_name]: <H1>Humidity</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
HUMIDITY
;
		}
	}
}
elsif ($hostoid eq '1.3.6.1.4.1.13045.1.1') {
	snmpMIB_to_OID("/usr/share/snmp/mibs/sh2.mib");
	my (@sensors) = snmpwalk($router_connect,'SH2SensorType');
	foreach my $sens (@sensors) {
		if ($sens =~ /(\d+):Temp/) {
			my $sid = $1;
			my $target_name = $router_name . ".temp." . $sid;
$target_lines .= <<TEMP2
Target[$target_name]: SH2SensorCurrentValue.$sid&SH2SensorCurrentValue.$sid:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: temp
bb*yellow[$target_name]: 83
bb*red[$target_name]: 88
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 185
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe temperature gauge
YLegend[$target_name]: degrees F
ShortLegend[$target_name]: F
PageTop[$target_name]: <H1>Temperature</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
TEMP2
;
		}
		elsif ($sens =~ /(\d+):Hum/) {
			my $sid = $1;
			my $target_name = $router_name . ".hum." . $sid;
$target_lines .= <<HUMIDITY2
Target[$target_name]: SH2SensorCurrentValue.$sid&SH2SensorCurrentValue.$sid:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: humidity
bb*yellow[$target_name]: 17:80
bb*red[$target_name]: 12:85
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe humidity gauge
YLegend[$target_name]: relative humidity
ShortLegend[$target_name]: %
PageTop[$target_name]: <H1>Humidity</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
HUMIDITY2
;
		}
	};
}	
elsif (($hostoid eq '1.3.6.1.4.1.901.1')  or ($hostoid eq '1.3.6.1.4.1.17373')) {
# IT Watchdog probe

	snmpMIB_to_OID("/usr/share/snmp/mibs/itw_mib.mib");
# Check if WaLK hack is required
my $oldwarn = $SNMP_Session::suppress_warnings;
$SNMP_Session::suppress_warnings = 1;
my ($testtemp) = snmpget($router_connect,'climateTempC.1');
my $wdi = '.1';
my $wdp = '';
if ($SNMP_Session::errmsg =~ /noSuchName/i) {
	$wdi = '';
	$wdp = 'WaLK';
} 
$SNMP_Session::suppress_warnings = $oldwarn;
my $target_name = $router_name . ".temp"; 
$target_lines .= <<TEMP3
Target[$target_name]: ${wdp}climateTempC${wdi}&${wdp}climateTempC${wdi}:$router_connect * 9 / 5 + 32
bb*host[$target_name]: $router_name
bb*svc[$target_name]: temp
bb*yellow[$target_name]: 83
bb*red[$target_name]: 88
routers.cgi*InSummary[$target_name]: yes
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 185
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe temperature gauge
YLegend[$target_name]: degrees F
ShortLegend[$target_name]: F
PageTop[$target_name]: <H1>Temperature</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
TEMP3
;
$target_name = $router_name . ".hum";
$target_lines .= <<HUMIDITY3
Target[$target_name]: ${wdp}climateHumidity${wdi}&${wdp}climateHumidity${wdi}:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: humidity
bb*yellow[$target_name]: 17:80
bb*red[$target_name]: 12:85
routers.cgi*InSummary[$target_name]: yes
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe humidity gauge
YLegend[$target_name]: relative humidity
ShortLegend[$target_name]: %
PageTop[$target_name]: <H1>Humidity</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
HUMIDITY3
;
$target_name = $router_name . ".air";
$target_lines .= <<AIRFLOW3
Target[$target_name]: ${wdp}climateAirflow${wdi}&${wdp}climateAirflow${wdi}:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: airflow
bb*yellow[$target_name]: 1:99
bb*red[$target_name]: 0:100
routers.cgi*InSummary[$target_name]: yes
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe airflow gauge
PageTop[$target_name]: <H1>Airflow</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
AIRFLOW3
;
$target_name = $router_name . ".light";
$target_lines .= <<LIGHT3
Target[$target_name]: ${wdp}climateLight${wdi}&${wdp}climateLight${wdi}:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: light
bb*yellow[$target_name]: 1:99
bb*red[$target_name]: 0:100
routers.cgi*InSummary[$target_name]: yes
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe Light gauge
PageTop[$target_name]: <H1>Light</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
LIGHT3
;
$target_name = $router_name . ".sound";
$target_lines .= <<SOUND3
Target[$target_name]: ${wdp}climateSound${wdi}&${wdp}climateSound${wdi}:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: sound
bb*yellow[$target_name]: 1:99
bb*red[$target_name]: 0:100
routers.cgi*InSummary[$target_name]: yes
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe sound gauge
PageTop[$target_name]: <H1>Sound</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
SOUND3
;
# check for a water probe
$target_name = $router_name . ".water";
my ($io3val) = snmpget($router_connect,'climateIO3.1');
if ($io3val > 0) {
$target_lines .= <<WATER
Target[$target_name]: climateIO3.1&climateIO3.1:$router_connect
bb*host[$target_name]: $router_name
bb*svc[$target_name]: water
bb*yellow[$target_name]: 50:101
bb*red[$target_name]: 40:102
routers.cgi*InSummary[$target_name]: yes
routers.cgi*Options[$target_name]: nototal
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: 100
RouterUptime[$target_name]: $router_connect
Options[$target_name]: Gauge noi
Title[$target_name]: Probe water gauge
PageTop[$target_name]: <H1>Water</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
WATER
;
};

}
else { print "The OID is $hostoid\n"; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.oetiker.ch/pipermail/mrtg/attachments/20080605/64106df7/attachment.bin 


More information about the mrtg mailing list