root / plugins / snmp / snmp__wmsplayerallocatedbandwidth @ e5ce7492
Historique | Voir | Annoter | Télécharger (3,07 ko)
| 1 | b10171ea | Andy Linton | #!/usr/bin/perl -w |
|---|---|---|---|
| 2 | # |
||
| 3 | # Copyright (C) 2006 Andy Linton, CityLink, New Zealand |
||
| 4 | # |
||
| 5 | # This program is free software; you can redistribute it and/or |
||
| 6 | # modify it under the terms of the GNU General Public License |
||
| 7 | # as published by the Free Software Foundation; version 2 dated June, |
||
| 8 | # 1991. |
||
| 9 | # |
||
| 10 | # This program is distributed in the hope that it will be useful, |
||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | # GNU General Public License for more details. |
||
| 14 | # |
||
| 15 | # You should have received a copy of the GNU General Public License |
||
| 16 | # along with this program; if not, write to the Free Software |
||
| 17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 18 | # |
||
| 19 | # Derived from SNMP plugin code written by |
||
| 20 | # Jimmy Olsen, Dagfinn Ilmari Mannsaaker |
||
| 21 | # |
||
| 22 | ####################################################################### |
||
| 23 | # |
||
| 24 | # You must enable SNMP for Windows Media Services by running: |
||
| 25 | # |
||
| 26 | # regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll |
||
| 27 | # |
||
| 28 | ####################################################################### |
||
| 29 | # |
||
| 30 | # $Log: snmp__wmsPlayerAllocatedBandwidth,v $ |
||
| 31 | # Revision 1.4 2007/08/09 22:15:50 root |
||
| 32 | # Modified using 'rcsedit' |
||
| 33 | # |
||
| 34 | # Revision 1.3 2007/03/02 19:22:33 root |
||
| 35 | # Modified using 'rcsedit' |
||
| 36 | # |
||
| 37 | # Revision 1.2 2007/03/02 19:19:31 root |
||
| 38 | # Modified using 'rcsedit' |
||
| 39 | # |
||
| 40 | # Revision 1.1 2007/03/02 19:15:28 root |
||
| 41 | # Checked in using 'rcsedit' |
||
| 42 | # |
||
| 43 | #%# family=snmpauto |
||
| 44 | #%# capabilities=snmpconf |
||
| 45 | |||
| 46 | use strict; |
||
| 47 | use Net::SNMP; |
||
| 48 | |||
| 49 | my $DEBUG = 0; |
||
| 50 | my $MAXLABEL = 20; |
||
| 51 | |||
| 52 | my $host = $ENV{host} || undef;
|
||
| 53 | my $port = $ENV{port} || 161;
|
||
| 54 | my $community = $ENV{community} || "public";
|
||
| 55 | my $iface = $ENV{interface} || undef;
|
||
| 56 | |||
| 57 | my $response; |
||
| 58 | |||
| 59 | if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") |
||
| 60 | {
|
||
| 61 | print "require 1.3.6.1.4.1.311.1.7.13.1.0 [0-9]\n"; # Number |
||
| 62 | exit 0; |
||
| 63 | } |
||
| 64 | |||
| 65 | if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsPlayerAllocatedBandwidth$/) |
||
| 66 | {
|
||
| 67 | $host = $1; |
||
| 68 | if ($host =~ /^([^:]+):(\d+)$/) |
||
| 69 | {
|
||
| 70 | $host = $1; |
||
| 71 | $port = $2; |
||
| 72 | } |
||
| 73 | } |
||
| 74 | elsif (!defined($host)) |
||
| 75 | {
|
||
| 76 | print "# Debug: $0 -- $1\n" if $DEBUG; |
||
| 77 | die "# Error: couldn't understand what I'm supposed to monitor."; |
||
| 78 | } |
||
| 79 | |||
| 80 | my ($session, $error) = Net::SNMP->session( |
||
| 81 | -hostname => $host, |
||
| 82 | -community => $community, |
||
| 83 | -port => $port |
||
| 84 | ); |
||
| 85 | |||
| 86 | if (!defined ($session)) |
||
| 87 | {
|
||
| 88 | die "Croaking: $error"; |
||
| 89 | } |
||
| 90 | |||
| 91 | if (defined $ARGV[0] and $ARGV[0] eq "config") |
||
| 92 | {
|
||
| 93 | print "host_name $host\n"; |
||
| 94 | print "graph_title wmsPlayerAllocatedBandwidth |
||
| 95 | graph_args --base 1000 -l 0 |
||
| 96 | graph_vlabel wmsPlayerAllocatedBandwidth |
||
| 97 | graph_category streaming |
||
| 98 | graph_info This graph shows wmsPlayerAllocatedBandwidth. |
||
| 99 | wmsPlayerAllocatedBandwidth.label wmsPlayerAllocatedBandwidth |
||
| 100 | wmsPlayerAllocatedBandwidth.draw LINE2 |
||
| 101 | wmsPlayerAllocatedBandwidth.info The wmsPlayerAllocatedBandwidth. |
||
| 102 | "; |
||
| 103 | |||
| 104 | exit 0; |
||
| 105 | } |
||
| 106 | |||
| 107 | print "wmsPlayerAllocatedBandwidth.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.1.0"), "\n"; |
||
| 108 | |||
| 109 | sub get_single |
||
| 110 | {
|
||
| 111 | my $handle = shift; |
||
| 112 | my $oid = shift; |
||
| 113 | |||
| 114 | print "# Getting single $oid...\n" if $DEBUG; |
||
| 115 | |||
| 116 | $response = $handle->get_request ($oid); |
||
| 117 | |||
| 118 | if (!defined $response->{$oid})
|
||
| 119 | {
|
||
| 120 | return undef; |
||
| 121 | } |
||
| 122 | else |
||
| 123 | {
|
||
| 124 | return $response->{$oid};
|
||
| 125 | } |
||
| 126 | } |
