Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / snmp / snmp__wmsstreamingmmsplayers @ e5ce7492

Historique | Voir | Annoter | Télécharger (2,88 ko)

1
#!/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__wmsStreamingMmsPlayers,v $
31
# Revision 1.2  2007/08/09 22:18:23  root
32
# Modified using 'rcsedit'
33
#
34
# Revision 1.1  2007/08/09 22:17:51  root
35
# Checked in using 'rcsedit'
36
#
37
#
38
#%# family=snmpauto
39
#%# capabilities=snmpconf
40

    
41
use strict;
42
use Net::SNMP;
43

    
44
my $DEBUG = 0;
45
my $MAXLABEL = 20;
46

    
47
my $host      = $ENV{host}      || undef;
48
my $port      = $ENV{port}      || 161;
49
my $community = $ENV{community} || "public";
50
my $iface     = $ENV{interface} || undef;
51

    
52
my $response;
53

    
54
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
55
{
56
	print "require 1.3.6.1.4.1.311.1.7.13.7.0 [0-9]\n"; # Number
57
	exit 0;
58
}
59

    
60
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsStreamingMmsPlayers$/)
61
{
62
	$host  = $1;
63
	if ($host =~ /^([^:]+):(\d+)$/)
64
	{
65
		$host = $1;
66
		$port = $2;
67
	}
68
}
69
elsif (!defined($host))
70
{
71
	print "# Debug: $0 -- $1\n" if $DEBUG;
72
	die "# Error: couldn't understand what I'm supposed to monitor.";
73
}
74

    
75
my ($session, $error) = Net::SNMP->session(
76
		-hostname  => $host,
77
		-community => $community,
78
		-port      => $port
79
	);
80

    
81
if (!defined ($session))
82
{
83
	die "Croaking: $error";
84
}
85

    
86
if (defined $ARGV[0] and $ARGV[0] eq "config")
87
{
88
	print "host_name $host\n";
89
	print "graph_title wmsStreamingMmsPlayers
90
graph_args --base 1000 -l 0 
91
graph_vlabel wmsStreamingMmsPlayers
92
graph_category streaming
93
graph_info This graph shows wmsStreamingMmsPlayers.
94
wmsStreamingMmsPlayers.label wmsStreamingMmsPlayers
95
wmsStreamingMmsPlayers.draw LINE2
96
wmsStreamingMmsPlayers.info The wmsStreamingMmsPlayers
97
";
98

    
99
	exit 0;
100
}
101

    
102
print "wmsStreamingMmsPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.7.0"), "\n";
103

    
104
sub get_single
105
{
106
	my $handle = shift;
107
	my $oid    = shift;
108

    
109
	print "# Getting single $oid...\n" if $DEBUG;
110

    
111
	$response = $handle->get_request ($oid);
112

    
113
	if (!defined $response->{$oid})
114
	{
115
	    return undef;
116
	}
117
	else
118
	{
119
	    return $response->{$oid};
120
	}
121
}
122