root / plugins / snmp / snmp__screenos @ ef960abc
Historique | Voir | Annoter | Télécharger (3,97 ko)
| 1 | d7e83154 | Diego Elio Pettenò | #!/usr/bin/perl -w |
|---|---|---|---|
| 2 | 8d259040 | Diego Elio Pettenò | # -*- cperl -*- |
| 3 | d7e83154 | Diego Elio Pettenò | |
| 4 | =head1 NAME |
||
| 5 | |||
| 6 | snmp__screenos_ - SNMP plugin to monitor Juniper ScreenOS based routers |
||
| 7 | |||
| 8 | =head1 APPLICABLE SYSTEMS |
||
| 9 | |||
| 10 | This has been developed against a Juniper SSG5-Serial router, but |
||
| 11 | should work with any ScreenOS-based router as manufactured by Juniper. |
||
| 12 | |||
| 13 | Using a command such as "munin-node-configure --snmp |
||
| 14 | switch.langfeldt.net --snmpversion 2c --snmpcommunity public | sh -x" |
||
| 15 | should identify whether this plugin can apply. |
||
| 16 | |||
| 17 | |||
| 18 | =head1 CONFIGURATION |
||
| 19 | |||
| 20 | As a rule SNMP plugins need site specific configuration. The default |
||
| 21 | configuration (shown here) will only work on insecure sites/devices: |
||
| 22 | |||
| 23 | [snmp_*] |
||
| 24 | env.version 2 |
||
| 25 | env.community public |
||
| 26 | |||
| 27 | In general SNMP is not very secure at all unless you use SNMP version |
||
| 28 | 3 which supports authentication and privacy (encryption). But in any |
||
| 29 | case the community string for your devices should not be "public". |
||
| 30 | |||
| 31 | Please see 'perldoc Munin::Plugin::SNMP' for further configuration |
||
| 32 | information. |
||
| 33 | |||
| 34 | =head1 MIB INFORMATION |
||
| 35 | |||
| 36 | This plugin requires NETSCREEN-RESOURCE-MIB information. |
||
| 37 | |||
| 38 | =head1 MAGIC MARKERS |
||
| 39 | |||
| 40 | #%# family=snmpauto |
||
| 41 | #%# capabilities=snmpconf |
||
| 42 | |||
| 43 | =head1 AUTHOR |
||
| 44 | |||
| 45 | Copyright (C) 2012 Diego Elio Pettenò. |
||
| 46 | |||
| 47 | =head1 LICENSE |
||
| 48 | |||
| 49 | GPLv2 |
||
| 50 | |||
| 51 | =cut |
||
| 52 | |||
| 53 | use strict; |
||
| 54 | use Munin::Plugin; |
||
| 55 | use Munin::Plugin::SNMP; |
||
| 56 | |||
| 57 | # This corresponds to NETSCREEN-SMI::netscreenResource |
||
| 58 | my $oidBase = '1.3.6.1.4.1.3224.16'; |
||
| 59 | |||
| 60 | 8ca0283c | Diego Elio Pettenò | my $oidCpuAvg = "$oidBase.1.1"; |
| 61 | my $oidCpuLast1Min = "$oidBase.1.2"; |
||
| 62 | my $oidCpuLast5Min = "$oidBase.1.3"; |
||
| 63 | my $oidCpuLast15Min = "$oidBase.1.4"; |
||
| 64 | my $oidMemAllocate = "$oidBase.2.1"; |
||
| 65 | my $oidMemLeft = "$oidBase.2.2"; |
||
| 66 | my $oidSessAllocate = "$oidBase.3.2"; |
||
| 67 | my $oidSessMaximum = "$oidBase.3.3"; |
||
| 68 | my $oidSessFailed = "$oidBase.3.4"; |
||
| 69 | d7e83154 | Diego Elio Pettenò | |
| 70 | if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
|
||
| 71 | print "require $oidBase.[23].[13].0"; |
||
| 72 | f5705164 | Diego Elio Pettenò | exit 0; |
| 73 | d7e83154 | Diego Elio Pettenò | } |
| 74 | |||
| 75 | my $session = Munin::Plugin::SNMP->session(); |
||
| 76 | 8d259040 | Diego Elio Pettenò | my $data = $session->get_entries(-columns => [$oidCpuAvg, |
| 77 | $oidCpuLast1Min, |
||
| 78 | $oidCpuLast5Min, |
||
| 79 | $oidCpuLast15Min, |
||
| 80 | $oidMemAllocate, |
||
| 81 | $oidMemLeft, |
||
| 82 | $oidSessAllocate, |
||
| 83 | $oidSessMaximum, |
||
| 84 | $oidSessFailed ]); |
||
| 85 | d7e83154 | Diego Elio Pettenò | |
| 86 | if ($ARGV[0] and $ARGV[0] eq "config") {
|
||
| 87 | my ($host) = Munin::Plugin::SNMP->config_session(); |
||
| 88 | |||
| 89 | my $memTotal = $data->{"$oidMemAllocate.0"} + $data->{"$oidMemLeft.0"};
|
||
| 90 | |||
| 91 | # this is the closet I can get to the yellow/red on the ScreenOS |
||
| 92 | # interface. |
||
| 93 | my $memWarning = int($memTotal * 0.75 + 0.5); |
||
| 94 | my $memCritical = int($memTotal * 0.85 + 0.5); |
||
| 95 | my $sessWarning = int($data->{"$oidSessMaximum.0"} * 0.75 + 0.5);
|
||
| 96 | my $sessCritical = int($data->{"$oidSessMaximum.0"} * 0.85 + 0.5);
|
||
| 97 | |||
| 98 | print <<END; |
||
| 99 | host_name $host |
||
| 100 | |||
| 101 | multigraph screenos_memory |
||
| 102 | graph_title Memory allocation |
||
| 103 | graph_vlabel bytes |
||
| 104 | graph_args --base 1024 |
||
| 105 | graph_category system |
||
| 106 | |||
| 107 | memory.label Memory |
||
| 108 | memory.min 0 |
||
| 109 | memory.max $memTotal |
||
| 110 | memory.warning $memWarning |
||
| 111 | memory.critical $memCritical |
||
| 112 | |||
| 113 | multigraph screenos_sessions |
||
| 114 | graph_title Sessions allocation |
||
| 115 | graph_vlabel Count |
||
| 116 | graph_category system |
||
| 117 | |||
| 118 | sessions.label Active Sessions |
||
| 119 | sessions.min 0 |
||
| 120 | sessions.max $data->{"$oidSessMaximum.0"}
|
||
| 121 | sessions.warning $sessWarning |
||
| 122 | sessions.critical $sessCritical |
||
| 123 | failed.label Failed Sessions |
||
| 124 | failed.min 0 |
||
| 125 | failed.critical 1 |
||
| 126 | 8d259040 | Diego Elio Pettenò | |
| 127 | multigraph screenos_cpu |
||
| 128 | 55975991 | Diego Elio Pettenò | graph_title CPU Utilization |
| 129 | graph_vlabel Percentage |
||
| 130 | 8d259040 | Diego Elio Pettenò | graph_category system |
| 131 | |||
| 132 | average.label Average |
||
| 133 | average.min 0 |
||
| 134 | average.max 100 |
||
| 135 | average.warning 75 |
||
| 136 | average.critical 85 |
||
| 137 | last1.label Last minute |
||
| 138 | last1.min 0 |
||
| 139 | last1.max 100 |
||
| 140 | last1.warning 75 |
||
| 141 | last1.critical 85 |
||
| 142 | last5.label Last 5 minutes |
||
| 143 | last5.min 0 |
||
| 144 | last5.max 100 |
||
| 145 | last5.warning 75 |
||
| 146 | last5.critical 85 |
||
| 147 | last15.label Last 15 minutes |
||
| 148 | last15.min 0 |
||
| 149 | last15.max 100 |
||
| 150 | last15.warning 75 |
||
| 151 | last15.critical 85 |
||
| 152 | d7e83154 | Diego Elio Pettenò | END |
| 153 | |||
| 154 | exit 0; |
||
| 155 | } |
||
| 156 | |||
| 157 | print <<END; |
||
| 158 | multigraph screenos_memory |
||
| 159 | memory.value $data->{"$oidMemAllocate.0"}
|
||
| 160 | |||
| 161 | multigraph screenos_sessions |
||
| 162 | sessions.value $data->{"$oidSessAllocate.0"}
|
||
| 163 | failed.value $data->{"$oidSessFailed.0"}
|
||
| 164 | 8d259040 | Diego Elio Pettenò | |
| 165 | multigraph screenos_cpu |
||
| 166 | average.value $data->{"$oidCpuAvg.0"}
|
||
| 167 | last1.value $data->{"$oidCpuLast1Min.0"}
|
||
| 168 | last5.value $data->{"$oidCpuLast5Min.0"}
|
||
| 169 | last15.value $data->{"$oidCpuLast15Min.0"}
|
||
| 170 | d7e83154 | Diego Elio Pettenò | END |
