Projet

Général

Profil

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

root / plugins / other / snmp__wmsstreamingplayers @ ba2f09ff

Historique | Voir | Annoter | Télécharger (2,78 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__wmsStreamingPlayers,v $
31
# Revision 1.4  2007/08/09 22:18:39  root
32
# Modified using 'rcsedit'
33
#
34
#
35
#%# family=snmpauto
36
#%# capabilities=snmpconf
37

    
38
use strict;
39
use Net::SNMP;
40

    
41
my $DEBUG = 0;
42
my $MAXLABEL = 20;
43

    
44
my $host      = $ENV{host}      || undef;
45
my $port      = $ENV{port}      || 161;
46
my $community = $ENV{community} || "public";
47
my $iface     = $ENV{interface} || undef;
48

    
49
my $response;
50

    
51
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
52
{
53
	print "require 1.3.6.1.4.1.311.1.7.13.10.0 [0-9]\n"; # Number
54
	exit 0;
55
}
56

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

    
72
my ($session, $error) = Net::SNMP->session(
73
		-hostname  => $host,
74
		-community => $community,
75
		-port      => $port
76
	);
77

    
78
if (!defined ($session))
79
{
80
	die "Croaking: $error";
81
}
82

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

    
96
	exit 0;
97
}
98

    
99
print "wmsStreamingPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.10.0"), "\n";
100

    
101
sub get_single
102
{
103
	my $handle = shift;
104
	my $oid    = shift;
105

    
106
	print "# Getting single $oid...\n" if $DEBUG;
107

    
108
	$response = $handle->get_request ($oid);
109

    
110
	if (!defined $response->{$oid})
111
	{
112
	    return undef;
113
	}
114
	else
115
	{
116
	    return $response->{$oid};
117
	}
118
}
119