From: <buc...@us...> - 2008-11-07 00:25:52
|
Revision: 90 http://devmon.svn.sourceforge.net/devmon/?rev=90&view=rev Author: buchanmilne Date: 2008-11-07 00:25:45 +0000 (Fri, 07 Nov 2008) Log Message: ----------- Fix segfault in hobbitd_rrd caused by do_devmon.c and data with spaces in repeater names Modified Paths: -------------- trunk/extras/do_devmon.c trunk/extras/hobbit-4.2.0-devmon-complete.patch Modified: trunk/extras/do_devmon.c =================================================================== --- trunk/extras/do_devmon.c 2008-09-04 08:15:59 UTC (rev 89) +++ trunk/extras/do_devmon.c 2008-11-07 00:25:45 UTC (rev 90) @@ -63,6 +63,7 @@ devmon_params[numds+2] = xstrdup(columns[numds]); numds++; } + dbgprintf("Found %d DS definitions\n",numds); devmon_params[numds+2] = rra1; devmon_params[numds+3] = rra2; devmon_params[numds+4] = rra3; @@ -72,8 +73,13 @@ if (devmon_tpl == NULL) devmon_tpl = setup_template(devmon_params); goto nextline; } - dbgprintf("Found %d DS definitions\n",numds); + dbgprintf("Found %d columns in devmon rrd data\n",columncount); + if (columncount > 2) { + dbgprintf("Skipping line, found %d (max 2) columns in devmon rrd data, space in repeater name?\n",columncount); + goto nextline; + } + /* Now we should be on to values: * eth0.0 4678222:9966777 */ Modified: trunk/extras/hobbit-4.2.0-devmon-complete.patch =================================================================== --- trunk/extras/hobbit-4.2.0-devmon-complete.patch 2008-09-04 08:15:59 UTC (rev 89) +++ trunk/extras/hobbit-4.2.0-devmon-complete.patch 2008-11-07 00:25:45 UTC (rev 90) @@ -94,9 +94,9 @@ /* CGI params */ static char *hostname = NULL; ---- hobbit-4.2.0/hobbitd/rrd/do_devmon.c.orig 2008-04-03 11:02:48.000000000 +0200 -+++ hobbit-4.2.0/hobbitd/rrd/do_devmon.c 2008-02-01 09:11:17.000000000 +0200 -@@ -0,0 +1,104 @@ +--- hobbit-4.2.0/hobbitd/rrd/do_devmon.c.orig 2008-11-07 02:20:09.000000000 +0200 ++++ hobbit-4.2.0/hobbitd/rrd/do_devmon.c 2008-11-07 02:19:23.000000000 +0200 +@@ -0,0 +1,110 @@ +/*----------------------------------------------------------------------------*/ +/* Hobbit RRD handler module for Devmon */ +/* */ @@ -162,6 +162,7 @@ + devmon_params[numds+2] = xstrdup(columns[numds]); + numds++; + } ++ dbgprintf("Found %d DS definitions\n",numds); + devmon_params[numds+2] = rra1; + devmon_params[numds+3] = rra2; + devmon_params[numds+4] = rra3; @@ -171,8 +172,13 @@ + if (devmon_tpl == NULL) devmon_tpl = setup_template(devmon_params); + goto nextline; + } -+ dbgprintf("Found %d DS definitions\n",numds); + ++ dbgprintf("Found %d columns in devmon rrd data\n",columncount); ++ if (columncount > 2) { ++ dbgprintf("Skipping line, found %d (max 2) columns in devmon rrd data, space in repeater name?\n",columncount); ++ goto nextline; ++ } ++ + /* Now we should be on to values: + * eth0.0 4678222:9966777 + */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <buc...@us...> - 2009-04-01 15:59:26
|
Revision: 129 http://devmon.svn.sourceforge.net/devmon/?rev=129&view=rev Author: buchanmilne Date: 2009-04-01 15:59:17 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Hobbit rrd collector - always call setup_template, so varying numbers of DSs work Modified Paths: -------------- trunk/extras/do_devmon.c trunk/extras/hobbit-4.2.0-devmon-complete.patch Modified: trunk/extras/do_devmon.c =================================================================== --- trunk/extras/do_devmon.c 2009-04-01 12:38:40 UTC (rev 128) +++ trunk/extras/do_devmon.c 2009-04-01 15:59:17 UTC (rev 129) @@ -70,7 +70,7 @@ devmon_params[numds+5] = rra4; devmon_params[numds+6] = NULL; - if (devmon_tpl == NULL) devmon_tpl = setup_template(devmon_params); + devmon_tpl = setup_template(devmon_params); goto nextline; } Modified: trunk/extras/hobbit-4.2.0-devmon-complete.patch =================================================================== --- trunk/extras/hobbit-4.2.0-devmon-complete.patch 2009-04-01 12:38:40 UTC (rev 128) +++ trunk/extras/hobbit-4.2.0-devmon-complete.patch 2009-04-01 15:59:17 UTC (rev 129) @@ -94,8 +94,8 @@ /* CGI params */ static char *hostname = NULL; ---- hobbit-4.2.0/hobbitd/rrd/do_devmon.c.orig 2008-11-07 02:20:09.000000000 +0200 -+++ hobbit-4.2.0/hobbitd/rrd/do_devmon.c 2008-11-07 02:19:23.000000000 +0200 +--- hobbit-4.2.0/hobbitd/rrd/do_devmon.c.orig 2009-04-01 17:55:12.000000000 +0200 ++++ hobbit-4.2.0/hobbitd/rrd/do_devmon.c 2009-04-01 17:55:06.000000000 +0200 @@ -0,0 +1,110 @@ +/*----------------------------------------------------------------------------*/ +/* Hobbit RRD handler module for Devmon */ @@ -108,7 +108,7 @@ +/* */ +/*----------------------------------------------------------------------------*/ + -+static char devmon_rcsid[] = "$Id $"; ++static char devmon_rcsid[] = "$Id: do_devmon.c 97 2008-12-07 20:02:02Z buchanmilne $"; + +int do_devmon_rrd(char *hostname, char *testname, char *msg, time_t tstamp) +{ @@ -169,7 +169,7 @@ + devmon_params[numds+5] = rra4; + devmon_params[numds+6] = NULL; + -+ if (devmon_tpl == NULL) devmon_tpl = setup_template(devmon_params); ++ devmon_tpl = setup_template(devmon_params); + goto nextline; + } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dba...@us...> - 2009-09-11 07:52:01
|
Revision: 148 http://devmon.svn.sourceforge.net/devmon/?rev=148&view=rev Author: dbaldwin Date: 2009-09-11 07:51:41 +0000 (Fri, 11 Sep 2009) Log Message: ----------- add templatebuilder.pl to extras with README Added Paths: ----------- trunk/extras/templatebuilder.README trunk/extras/templatebuilder.pl Added: trunk/extras/templatebuilder.README =================================================================== --- trunk/extras/templatebuilder.README (rev 0) +++ trunk/extras/templatebuilder.README 2009-09-11 07:51:41 UTC (rev 148) @@ -0,0 +1,154 @@ +To run: +./templatebuilder.pl [snmpargs...] <host> <oid> +e.g. +./templatebuilder.pl -cpublic -v2c localhost enterprises + +* runs snmpwalk over the MIB tree (needs MIB files installed) +* translates symbolic and numeric correspondences +* displays values found from host MIB agent +* generates barebones of oids, transforms and thresholds. + +A work in progress... + +$ ./templatebuilder.pl localhost ifTable +snmpwalk -OE localhost ifTable +ifIndex : .1.3.6.1.2.1.2.2.1.1 : branch +RFC1213-MIB::ifIndex.1 (.1.3.6.1.2.1.2.2.1.1.1) = INTEGER: 1 +RFC1213-MIB::ifIndex.2 (.1.3.6.1.2.1.2.2.1.1.2) = INTEGER: 2 +RFC1213-MIB::ifIndex.3 (.1.3.6.1.2.1.2.2.1.1.3) = INTEGER: 3 +RFC1213-MIB::ifIndex.4 (.1.3.6.1.2.1.2.2.1.1.4) = INTEGER: 4 +ifDescr : .1.3.6.1.2.1.2.2.1.2 : branch +RFC1213-MIB::ifDescr.1 (.1.3.6.1.2.1.2.2.1.2.1) = STRING: "lo" +RFC1213-MIB::ifDescr.2 (.1.3.6.1.2.1.2.2.1.2.2) = STRING: "eth0" +RFC1213-MIB::ifDescr.3 (.1.3.6.1.2.1.2.2.1.2.3) = STRING: "eth1" +RFC1213-MIB::ifDescr.4 (.1.3.6.1.2.1.2.2.1.2.4) = STRING: "sit0" +ifType : .1.3.6.1.2.1.2.2.1.3 : branch + ## Values: other(1), regular1822(2), hdh1822(3), ddn-x25(4), rfc877-x25(5), ethernet-csmacd(6), iso88023-csmacd(7), iso88024-tokenBus(8), iso88025-tokenRing(9), iso88026-ma +n(10), starLan(11), proteon-10Mbit(12), proteon-80Mbit(13), hyperchannel(14), fddi(15), lapb(16), sdlc(17), ds1(18), e1(19), basicISDN(20), primaryISDN(21), propPointToPoint +Serial(22), ppp(23), softwareLoopback(24), eon(25), ethernet-3Mbit(26), nsip(27), slip(28), ultra(29), ds3(30), sip(31), frame-relay(32) +ifTypeTxt : SWITCH : {ifType} 1=other,2=regular1822,3=hdh1822,4=ddn-x25,5=rfc877-x25,6=ethernet-csmacd,7=iso88023-csmacd,8=iso88024-tokenBus,9=iso88025-tokenRin +g,10=iso88026-man,11=starLan,12=proteon-10Mbit,13=proteon-80Mbit,14=hyperchannel,15=fddi,16=lapb,17=sdlc,18=ds1,19=e1,20=basicISDN,21=primaryISDN,22=propPointToPointSerial,2 +3=ppp,24=softwareLoopback,25=eon,26=ethernet-3Mbit,27=nsip,28=slip,29=ultra,30=ds3,31=sip,32=frame-relay +RFC1213-MIB::ifType.1 (.1.3.6.1.2.1.2.2.1.3.1) = INTEGER: softwareLoopback(24) +RFC1213-MIB::ifType.2 (.1.3.6.1.2.1.2.2.1.3.2) = INTEGER: ethernet-csmacd(6) +RFC1213-MIB::ifType.3 (.1.3.6.1.2.1.2.2.1.3.3) = INTEGER: ethernet-csmacd(6) +RFC1213-MIB::ifType.4 (.1.3.6.1.2.1.2.2.1.3.4) = INTEGER: 131 +ifMtu : .1.3.6.1.2.1.2.2.1.4 : branch +RFC1213-MIB::ifMtu.1 (.1.3.6.1.2.1.2.2.1.4.1) = INTEGER: 16436 +RFC1213-MIB::ifMtu.2 (.1.3.6.1.2.1.2.2.1.4.2) = INTEGER: 1500 +RFC1213-MIB::ifMtu.3 (.1.3.6.1.2.1.2.2.1.4.3) = INTEGER: 1500 +RFC1213-MIB::ifMtu.4 (.1.3.6.1.2.1.2.2.1.4.4) = INTEGER: 1480 +ifSpeed : .1.3.6.1.2.1.2.2.1.5 : branch +RFC1213-MIB::ifSpeed.1 (.1.3.6.1.2.1.2.2.1.5.1) = Gauge32: 10000000 +RFC1213-MIB::ifSpeed.2 (.1.3.6.1.2.1.2.2.1.5.2) = Gauge32: 1000000000 +RFC1213-MIB::ifSpeed.3 (.1.3.6.1.2.1.2.2.1.5.3) = Gauge32: 0 +RFC1213-MIB::ifSpeed.4 (.1.3.6.1.2.1.2.2.1.5.4) = Gauge32: 0 +ifPhysAddress : .1.3.6.1.2.1.2.2.1.6 : branch +RFC1213-MIB::ifPhysAddress.1 (.1.3.6.1.2.1.2.2.1.6.1) = "" +RFC1213-MIB::ifPhysAddress.2 (.1.3.6.1.2.1.2.2.1.6.2) = Hex-STRING: 00 16 35 5B 89 60 +RFC1213-MIB::ifPhysAddress.3 (.1.3.6.1.2.1.2.2.1.6.3) = Hex-STRING: 00 16 35 5B 89 5F +RFC1213-MIB::ifPhysAddress.4 (.1.3.6.1.2.1.2.2.1.6.4) = Hex-STRING: 00 00 00 00 89 5F +ifAdminStatus : .1.3.6.1.2.1.2.2.1.7 : branch + ## Values: up(1), down(2), testing(3) +ifAdminStatusTxt : SWITCH : {ifAdminStatus} 1=up,2=down,3=testing +RFC1213-MIB::ifAdminStatus.1 (.1.3.6.1.2.1.2.2.1.7.1) = INTEGER: up(1) +RFC1213-MIB::ifAdminStatus.2 (.1.3.6.1.2.1.2.2.1.7.2) = INTEGER: up(1) +RFC1213-MIB::ifAdminStatus.3 (.1.3.6.1.2.1.2.2.1.7.3) = INTEGER: down(2) +RFC1213-MIB::ifAdminStatus.4 (.1.3.6.1.2.1.2.2.1.7.4) = INTEGER: down(2) +ifOperStatus : .1.3.6.1.2.1.2.2.1.8 : branch + ## Values: up(1), down(2), testing(3) +ifOperStatusTxt : SWITCH : {ifOperStatus} 1=up,2=down,3=testing +RFC1213-MIB::ifOperStatus.1 (.1.3.6.1.2.1.2.2.1.8.1) = INTEGER: up(1) +RFC1213-MIB::ifOperStatus.2 (.1.3.6.1.2.1.2.2.1.8.2) = INTEGER: up(1) +RFC1213-MIB::ifOperStatus.3 (.1.3.6.1.2.1.2.2.1.8.3) = INTEGER: down(2) +RFC1213-MIB::ifOperStatus.4 (.1.3.6.1.2.1.2.2.1.8.4) = INTEGER: down(2) +ifInOctets : .1.3.6.1.2.1.2.2.1.10 : branch +RFC1213-MIB::ifInOctets.1 (.1.3.6.1.2.1.2.2.1.10.1) = Counter32: 1747840320 +RFC1213-MIB::ifInOctets.2 (.1.3.6.1.2.1.2.2.1.10.2) = Counter32: 1897765870 +RFC1213-MIB::ifInOctets.3 (.1.3.6.1.2.1.2.2.1.10.3) = Counter32: 0 +RFC1213-MIB::ifInOctets.4 (.1.3.6.1.2.1.2.2.1.10.4) = Counter32: 0 +ifInUcastPkts : .1.3.6.1.2.1.2.2.1.11 : branch +RFC1213-MIB::ifInUcastPkts.1 (.1.3.6.1.2.1.2.2.1.11.1) = Counter32: 369931020 +RFC1213-MIB::ifInUcastPkts.2 (.1.3.6.1.2.1.2.2.1.11.2) = Counter32: 3742681648 +RFC1213-MIB::ifInUcastPkts.3 (.1.3.6.1.2.1.2.2.1.11.3) = Counter32: 0 +RFC1213-MIB::ifInUcastPkts.4 (.1.3.6.1.2.1.2.2.1.11.4) = Counter32: 0 +ifInDiscards : .1.3.6.1.2.1.2.2.1.13 : branch +RFC1213-MIB::ifInDiscards.1 (.1.3.6.1.2.1.2.2.1.13.1) = Counter32: 0 +RFC1213-MIB::ifInDiscards.2 (.1.3.6.1.2.1.2.2.1.13.2) = Counter32: 498 +RFC1213-MIB::ifInDiscards.3 (.1.3.6.1.2.1.2.2.1.13.3) = Counter32: 0 +RFC1213-MIB::ifInDiscards.4 (.1.3.6.1.2.1.2.2.1.13.4) = Counter32: 0 +ifInErrors : .1.3.6.1.2.1.2.2.1.14 : branch +RFC1213-MIB::ifInErrors.1 (.1.3.6.1.2.1.2.2.1.14.1) = Counter32: 0 +RFC1213-MIB::ifInErrors.2 (.1.3.6.1.2.1.2.2.1.14.2) = Counter32: 0 +RFC1213-MIB::ifInErrors.3 (.1.3.6.1.2.1.2.2.1.14.3) = Counter32: 0 +RFC1213-MIB::ifInErrors.4 (.1.3.6.1.2.1.2.2.1.14.4) = Counter32: 0 +ifOutOctets : .1.3.6.1.2.1.2.2.1.16 : branch +RFC1213-MIB::ifOutOctets.1 (.1.3.6.1.2.1.2.2.1.16.1) = Counter32: 1747842686 +RFC1213-MIB::ifOutOctets.2 (.1.3.6.1.2.1.2.2.1.16.2) = Counter32: 538554096 +RFC1213-MIB::ifOutOctets.3 (.1.3.6.1.2.1.2.2.1.16.3) = Counter32: 0 +RFC1213-MIB::ifOutOctets.4 (.1.3.6.1.2.1.2.2.1.16.4) = Counter32: 0 +ifOutUcastPkts : .1.3.6.1.2.1.2.2.1.17 : branch +RFC1213-MIB::ifOutUcastPkts.1 (.1.3.6.1.2.1.2.2.1.17.1) = Counter32: 369931052 +RFC1213-MIB::ifOutUcastPkts.2 (.1.3.6.1.2.1.2.2.1.17.2) = Counter32: 2398891222 +RFC1213-MIB::ifOutUcastPkts.3 (.1.3.6.1.2.1.2.2.1.17.3) = Counter32: 0 +RFC1213-MIB::ifOutUcastPkts.4 (.1.3.6.1.2.1.2.2.1.17.4) = Counter32: 0 +ifOutDiscards : .1.3.6.1.2.1.2.2.1.19 : branch +RFC1213-MIB::ifOutDiscards.1 (.1.3.6.1.2.1.2.2.1.19.1) = Counter32: 0 +RFC1213-MIB::ifOutDiscards.2 (.1.3.6.1.2.1.2.2.1.19.2) = Counter32: 0 +RFC1213-MIB::ifOutDiscards.3 (.1.3.6.1.2.1.2.2.1.19.3) = Counter32: 0 +RFC1213-MIB::ifOutDiscards.4 (.1.3.6.1.2.1.2.2.1.19.4) = Counter32: 0 +ifOutErrors : .1.3.6.1.2.1.2.2.1.20 : branch +RFC1213-MIB::ifOutErrors.1 (.1.3.6.1.2.1.2.2.1.20.1) = Counter32: 0 +RFC1213-MIB::ifOutErrors.2 (.1.3.6.1.2.1.2.2.1.20.2) = Counter32: 0 +RFC1213-MIB::ifOutErrors.3 (.1.3.6.1.2.1.2.2.1.20.3) = Counter32: 0 +RFC1213-MIB::ifOutErrors.4 (.1.3.6.1.2.1.2.2.1.20.4) = Counter32: 0 +ifOutQLen : .1.3.6.1.2.1.2.2.1.21 : branch +RFC1213-MIB::ifOutQLen.1 (.1.3.6.1.2.1.2.2.1.21.1) = Gauge32: 0 +RFC1213-MIB::ifOutQLen.2 (.1.3.6.1.2.1.2.2.1.21.2) = Gauge32: 0 +RFC1213-MIB::ifOutQLen.3 (.1.3.6.1.2.1.2.2.1.21.3) = Gauge32: 0 +RFC1213-MIB::ifOutQLen.4 (.1.3.6.1.2.1.2.2.1.21.4) = Gauge32: 0 +ifSpecific : .1.3.6.1.2.1.2.2.1.22 : branch +RFC1213-MIB::ifSpecific.1 (.1.3.6.1.2.1.2.2.1.22.1) = OID: SNMPv2-SMI::zeroDotZero +RFC1213-MIB::ifSpecific.2 (.1.3.6.1.2.1.2.2.1.22.2) = OID: SNMPv2-SMI::zeroDotZero +RFC1213-MIB::ifSpecific.3 (.1.3.6.1.2.1.2.2.1.22.3) = OID: SNMPv2-SMI::zeroDotZero +RFC1213-MIB::ifSpecific.4 (.1.3.6.1.2.1.2.2.1.22.4) = OID: SNMPv2-SMI::zeroDotZero + +oids file:: +ifIndex : .1.3.6.1.2.1.2.2.1.1 : branch +ifDescr : .1.3.6.1.2.1.2.2.1.2 : branch +ifType : .1.3.6.1.2.1.2.2.1.3 : branch +ifMtu : .1.3.6.1.2.1.2.2.1.4 : branch +ifSpeed : .1.3.6.1.2.1.2.2.1.5 : branch +ifPhysAddress : .1.3.6.1.2.1.2.2.1.6 : branch +ifAdminStatus : .1.3.6.1.2.1.2.2.1.7 : branch +ifOperStatus : .1.3.6.1.2.1.2.2.1.8 : branch +ifInOctets : .1.3.6.1.2.1.2.2.1.10 : branch +ifInUcastPkts : .1.3.6.1.2.1.2.2.1.11 : branch +ifInDiscards : .1.3.6.1.2.1.2.2.1.13 : branch +ifInErrors : .1.3.6.1.2.1.2.2.1.14 : branch +ifOutOctets : .1.3.6.1.2.1.2.2.1.16 : branch +ifOutUcastPkts : .1.3.6.1.2.1.2.2.1.17 : branch +ifOutDiscards : .1.3.6.1.2.1.2.2.1.19 : branch +ifOutErrors : .1.3.6.1.2.1.2.2.1.20 : branch +ifOutQLen : .1.3.6.1.2.1.2.2.1.21 : branch +ifSpecific : .1.3.6.1.2.1.2.2.1.22 : branch + +transforms file:: +ifTypeTxt : SWITCH : {ifType} 1=other,2=regular1822,3=hdh1822,4=ddn-x25,5=rfc877-x25,6=ethernet-csmacd,7=iso88023-csmacd,8=iso88024-tokenBus,9=iso88025-tokenRin +g,10=iso88026-man,11=starLan,12=proteon-10Mbit,13=proteon-80Mbit,14=hyperchannel,15=fddi,16=lapb,17=sdlc,18=ds1,19=e1,20=basicISDN,21=primaryISDN,22=propPointToPointSerial,2 +3=ppp,24=softwareLoopback,25=eon,26=ethernet-3Mbit,27=nsip,28=slip,29=ultra,30=ds3,31=sip,32=frame-relay +ifAdminStatusTxt : SWITCH : {ifAdminStatus} 1=up,2=down,3=testing +ifOperStatusTxt : SWITCH : {ifOperStatus} 1=up,2=down,3=testing + +thresholds file:: +ifTypeTxt : green : iso88024-tokenBus|iso88025-tokenRing : +ifTypeTxt : yellow : other|regular1822|hdh1822|ddn-x25|rfc877-x25|ethernet-csmacd|iso88023-csmacd|iso88026-man|starLan|proteon-10Mbit|proteon-80Mbit|hyperchannel|fddi| +lapb|sdlc|ds1|e1|basicISDN|primaryISDN|propPointToPointSerial|ppp|softwareLoopback|eon|ethernet-3Mbit|nsip|slip|ultra|ds3|sip|frame-relay : +ifTypeTxt : red : : +ifAdminStatusTxt : green : : +ifAdminStatusTxt : yellow : up|down|testing : +ifAdminStatusTxt : red : : +ifOperStatusTxt : green : : +ifOperStatusTxt : yellow : up|down|testing : +ifOperStatusTxt : red : : + Added: trunk/extras/templatebuilder.pl =================================================================== --- trunk/extras/templatebuilder.pl (rev 0) +++ trunk/extras/templatebuilder.pl 2009-09-11 07:51:41 UTC (rev 148) @@ -0,0 +1,99 @@ +#!/usr/bin/perl -w + +use strict; +use Data::Dumper; + +$|=1; + +my $snmpargs = ""; +while(scalar @ARGV > 2) { + $snmpargs .= (shift) . " "; +} +my $host = shift || "localhost"; +my $base = shift || "ifTable"; + +my %trans = (); +my %enum = (); +my @walkproc= (); + +sub OIDNumLookup { + my ($mib,$var,$tail) = @_; + if($tail =~ /^\..+$/) { + return $trans{"${mib}::$var"}.$tail; + } else { + return $trans{"${mib}::$var$tail"}; + } +} + +print "snmpwalk $snmpargs -OE $host $base\n"; +my @walk = `snmpwalk $snmpargs -OE $host $base`; +chomp @walk; +#print Dumper @walk; +my $c = -1; +foreach my $l (@walk) { + if(my ($mib,$var,$tail) = ($l =~ /^([^:]+)::([^.]+)(.*) = /)) { + $trans{"${mib}::$var"} = ""; +# $trans{"${mib}::$var$tail"} = ""; + if($l =~ /= INTEGER: .*\(\d+\)$/) { + $enum{"${mib}::$var"} = ""; + } + push @walkproc,($l); + $c++; + } else { + $walkproc[$c] .= "\n$l"; + } +} +my @keylist = sort grep !/\./,keys %trans; +#print Dumper @keylist; +my $transcmd = "snmptranslate -On ".join " ",@keylist; +my @translist = `$transcmd`; +chomp @translist; +#print Dumper @translist; +for(my $i=0;$i<=$#keylist;$i++) { + $trans{$keylist[$i]} = $translist[2*$i]; +} +my @enumlist = keys %enum; +$transcmd = "snmptranslate -Tp ".join " ",@enumlist; +@translist = grep / (EnumVal|Values:) /,`$transcmd`; +chomp @translist; +for(my $i=0;$i<=$#enumlist;$i++) { + $enum{$enumlist[$i]} = $translist[1+2*$i]; + $enum{$enumlist[$i]} =~ s/^\s+//; +} +my %varprint; +my %enumprint; +my @oidprint = (); +my @transformprint = (); +my @threshprint = (); +foreach my $l (@walkproc) { + my ($mib,$var,$tail,$rest) = ($l =~ /^([^:]+)::([^.]+)(.*)( = .*)$/s); + $tail ||= ""; + #printf ("mib: %s var: %s tail: %s rest: $rest\n",$mib,$var,$tail,$rest); + unless( defined $varprint{"${mib}::$var"} ) { + print "$var\t: ".$trans{"${mib}::$var"}."\t: branch\n"; + print "$var\t: ".$trans{"${mib}::$var"}.".0\t: leaf\n" if $tail eq ".0"; + push @oidprint,("$var\t: ".$trans{"${mib}::$var"}."\t: branch\n"); + push @oidprint,("$var\t: ".$trans{"${mib}::$var"}.".0\t: leaf\n") if $tail eq ".0"; + } + $varprint{"${mib}::$var"} = 1; + if($l =~ /= INTEGER: .*\(\d+\)$/) { + unless( $enumprint{"${mib}::$var"} ) { + printf " ## %s\n",$enum{"${mib}::$var"}; + my $el = $enum{"${mib}::$var"}; + $el =~ s/^\s*Values:\s*//; + my @elv = map {s/^(.*)\((\-?\d+)\)/$2=$1/; $_;} split /,\s*/,$el; + my @thv = map {s/^(.*)\(\-?\d+\)/$1/; $_;} split /,\s*/,$el; + #@elv =~ s/^(.*)\((\d+)\)/$2=$1/; + printf "${var}Txt\t: SWITCH\t: {$var} %s\n",join ",",@elv; + push @transformprint, (sprintf "${var}Txt\t: SWITCH\t: {$var} %s\n",join ",",@elv); + push @threshprint, (sprintf "${var}Txt\t: green : %s\t:\n",join "|",grep /(ok|good|online|closed|locked)/i,@thv); + push @threshprint, (sprintf "${var}Txt\t: yellow : %s\t:\n",join "|",grep !/(ok|good|online|closed|locked|fail|degrade|offline)/i,@thv); + push @threshprint, (sprintf "${var}Txt\t: red : %s\t:\n",join "|",grep /(fail|degrade|offline)/i,@thv); + } + $enumprint{"${mib}::$var"} = 1; + } + print "${mib}::$var$tail (".OIDNumLookup($mib,$var,$tail).")$rest\n"; +} +print "\noids file::\n",@oidprint; +print "\ntransforms file::\n",@transformprint; +print "\nthresholds file::\n",@threshprint; Property changes on: trunk/extras/templatebuilder.pl ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <buc...@us...> - 2011-05-13 11:24:33
|
Revision: 231 http://devmon.svn.sourceforge.net/devmon/?rev=231&view=rev Author: buchanmilne Date: 2011-05-13 11:24:27 +0000 (Fri, 13 May 2011) Log Message: ----------- Add initial devmongraphtitle script (using older Xymon::Client interface), and commented usage example in devmon-graph.cfg Modified Paths: -------------- trunk/extras/devmon-graph.cfg Added Paths: ----------- trunk/extras/devmongraphtitle.pl Modified: trunk/extras/devmon-graph.cfg =================================================================== --- trunk/extras/devmon-graph.cfg 2011-04-04 12:17:05 UTC (rev 230) +++ trunk/extras/devmon-graph.cfg 2011-05-13 11:24:27 UTC (rev 231) @@ -1,6 +1,7 @@ [if_load] FNPATTERN if_load.(.*).rrd TITLE Network Traffic + #TITLE exec:$BBHOME/ext/devmongraphtitle.pl YAXIS Bits/second DEF:in@RRDIDX@=@RRDFN@:ds0:AVERAGE CDEF:inbytes@RRDIDX@=in@RRDIDX@,8,* Added: trunk/extras/devmongraphtitle.pl =================================================================== --- trunk/extras/devmongraphtitle.pl (rev 0) +++ trunk/extras/devmongraphtitle.pl 2011-05-13 11:24:27 UTC (rev 231) @@ -0,0 +1,36 @@ +#!/usr/bin/perl +# Script to get the interface name from the current devmon if_load test +# to use as dynamic graph title command (see hobbitgraph.cfg(5)) +# Copyright (c) Buchan Milne <bg...@st...> 2009 +# License GPLv2 + +use strict; +use warnings; +use Xymon::Client; + +my $hostname = shift || ""; +my $graphinstance = shift || ""; +my $period = shift||""; +my @files = @ARGV; + +my $intdesc; + +if (@files gt 1 or @files eq 0) { + print "Network Traffic $period\n"; + exit 0 +} +my ($testname,$intname) = split(/\./,$files[0],3); +$intname =~ s/_/\//g if ($intname); + +my $bb=Xymon::Client->new; +my $result = $bb->hobbitdlog("$hostname.$testname"); + +while (<$result>) { + chomp; + if (m(^<tr><td>$intname ([^<]+)?<\/td><td>)) { + $intdesc = $1; + print "Network Traffic on $intname ($intdesc) $period\n"; + exit 0; + } +} +print "Network Traffic on $intname $period\n"; Property changes on: trunk/extras/devmongraphtitle.pl ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <buc...@us...> - 2013-03-02 09:20:38
|
Revision: 243 http://devmon.svn.sourceforge.net/devmon/?rev=243&view=rev Author: buchanmilne Date: 2013-03-02 09:20:30 +0000 (Sat, 02 Mar 2013) Log Message: ----------- Add a script with sudo rules and a hobbitlaunch config file to restart devmon if it is purple Added Paths: ----------- trunk/extras/restart-devmon-if-purple trunk/extras/restart-devmon-if-purple.cfg trunk/extras/xymon-control-devmon.sudoers Added: trunk/extras/restart-devmon-if-purple =================================================================== --- trunk/extras/restart-devmon-if-purple (rev 0) +++ trunk/extras/restart-devmon-if-purple 2013-03-02 09:20:30 UTC (rev 243) @@ -0,0 +1,47 @@ +#!/bin/bash +if [ "$BB" == "" ] +then + echo "This script must be run under a Hobbit or Xymon environment" >&2 + echo "e.g. by: bbcmd $0" >&2 + exit 1 +fi +if [ "$BBDISPLAYS" != "" ] +then + BBDISP=${BBDISPLAYS#,*} +fi +COLOR=$($BB $BBDISP "hobbitdboard host=$HOSTNAME test=dm" | cut -d'|' -f3) + +if [ "`id -u`" -eq 0 ] +then + DEVMON="/etc/init.d/devmon" + PKILL="pkill" +else + DEVMON="sudo /etc/init.d/devmon" + PKILL="sudo pkill" +fi + +if [ "$COLOR" == "purple" ] +then + LOGSAVE=/var/log/devmon/failures/devmon-failure-`date +%Y-%m-%d-%H:%M:%S`.log + echo "Devmon is purple, saving last 200 lines of log to $LOGSAVE" + tail -n200 /var/log/devmon/devmon.log > $LOGSAVE + $DEVMON stop + NUM=$(pgrep -u devmon|wc -l) + if [ "$NUM" -ne 0 ] + then + echo "Devmon failed to stop cleanly, terminating manually" + $PKILL -u devmon + sleep 5 + fi + NUM=$(pgrep -u devmon|wc -l) + if [ "$NUM" -ne 0 ] + then + echo "Devmon failed to terminate cleanly, killing manually" + $PKILL -9 -u devmon + fi + $DEVMON start +else + [ "$DEBUG" == 1 ] && echo "Devmon isn't purple, it is $COLOR" + exit 0 +fi + Property changes on: trunk/extras/restart-devmon-if-purple ___________________________________________________________________ Added: svn:executable + * Added: trunk/extras/restart-devmon-if-purple.cfg =================================================================== --- trunk/extras/restart-devmon-if-purple.cfg (rev 0) +++ trunk/extras/restart-devmon-if-purple.cfg 2013-03-02 09:20:30 UTC (rev 243) @@ -0,0 +1,6 @@ +[devmonr] + ENVFILE /usr/lib64/xymon/server/etc/hobbitserver.cfg + CMD /usr/local/bin/restart-devmon-if-purple + INTERVAL 1m + LOGFILE /var/log/xymon/devmon-restart.log + Added: trunk/extras/xymon-control-devmon.sudoers =================================================================== --- trunk/extras/xymon-control-devmon.sudoers (rev 0) +++ trunk/extras/xymon-control-devmon.sudoers 2013-03-02 09:20:30 UTC (rev 243) @@ -0,0 +1 @@ +xymon ALL=NOPASSWD: /usr/bin/pkill *-u devmon,/etc/init.d/devmon * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |