SOURCES: snmp_ping_stats (NEW) - small tool to ping remote ip and ...

undefine undefine at pld-linux.org
Fri Aug 31 14:40:38 CEST 2007


Author: undefine                     Date: Fri Aug 31 12:40:38 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- small tool to ping remote ip and present resoluts by snmp. feel free to fix it ;)
- gpl of course

---- Files affected:
SOURCES:
   snmp_ping_stats (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/snmp_ping_stats
diff -u /dev/null SOURCES/snmp_ping_stats:1.1
--- /dev/null	Fri Aug 31 14:40:38 2007
+++ SOURCES/snmp_ping_stats	Fri Aug 31 14:40:32 2007
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+# Skrypt perla do mierzenia opó¼nieñ do zadanego hosta
+
+# wstaw do snmpd.conf
+#
+# pass_persist .1.3.6.1.4.1.2021.123 /sciezka/do/snmp_ping_stats
+# a potem
+# [root at serwer1 ~]# snmpwalk -v 1 -c public serwer2  .1.3.6.1.4.1.2021.123.150.254.78.2
+# UCD-SNMP-MIB::ucdavis.123.150.254.78.2 = INTEGER: 9
+#
+
+# Czysci bufor po kazdym wypisaniu tekstu
+$|=1;
+
+my $counter = 0;
+my $place = ".1.3.6.1.4.1.2021.123";
+
+while (<>){
+  # obslugujemy ping/pong
+  if (m!^PING!){
+    print "PONG\n";
+    next;
+  }
+   my $cmd = $_;
+  my $req = <>;
+  chomp($cmd);
+  chomp($req);
+  $ip=$req;
+  $ip =~ s/$place.//g;
+
+  #getnext nie obslugujemy - ip jest podawany w oidzie
+  if ( $cmd eq "getnext" ) {
+    printf("NONE\n");
+  }
+
+  #getnext nie obslugujemy - ip jest podawany w oidzie
+  if ( $cmd eq "get" ) {
+    open(x,"/usr/sbin/fping -C 1 -q $ip 2>&1 |") || die "Nie mozna uruchomic fpinga";
+    my $ping=<x>;
+    @pingl = split(/\s+/, $ping);
+    printf("$req\ninteger\n%d\n", at pingl[2]);
+  }
+}
================================================================


More information about the pld-cvs-commit mailing list