/[rrd-simple-monitoring]/bin/rrd-client-switches.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/rrd-client-switches.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Thu Jul 16 18:48:19 2009 UTC (14 years, 8 months ago) by dpavlin
File MIME type: text/plain
File size: 1033 byte(s)
import upstream http://rrd.me.uk/rrd-simple-monitoring.tar.gz

without prerequisities

1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use constant RRD_CMD => '/home/rrd/bin/rrd-server.pl -u %s';
6 use constant SNMP_CMDS => (
7 '/usr/bin/snmpwalk -c public -v 2c %s IF-MIB::ifInOctets',
8 '/usr/bin/snmpwalk -c public -v 2c %s IF-MIB::ifOutOctets'
9 );
10 use constant HOSTS => qw(
11 switch1.company.com
12 switch2.company.com
13 switch3.company.com
14 switch4.company.com
15 );
16
17 for my $host (HOSTS) {
18 my %update;
19 my $time = time;
20
21 for my $cmd (SNMP_CMDS) {
22 $cmd = sprintf($cmd,$host);
23 print "$cmd\n";
24 for (qx($cmd)) {
25 if (my ($key,$port,$value) = $_ =~ /(if(?:In|Out)Octets)\.(\d+)\s*=\s*(?:Counter32:\s*)?(\d+)/i) {
26 $update{"$time.switch.traffic.$key"} += $value;
27 $update{"$time.switch.traffic.port$port.$key"} = $value;
28 }
29 }
30 }
31
32 my $str;
33 $str .= "$_ $update{$_}\n" for sort keys %update;
34 my $cmd = sprintf(RRD_CMD,$host);
35 print "$cmd\n";
36 open(PH,'|-',$cmd) || die "Unable to open file handle PH for command '$cmd': $!";
37 print PH $str;
38 close(PH) || die "Unable to close file hadle PH for command '$cmd': $!";
39 }
40

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26