1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

More housekeeping.

This commit is contained in:
Diego Elio Pettenò 2012-08-06 22:20:20 -07:00
parent 038c3ce96b
commit e5ce74926d
43 changed files with 0 additions and 0 deletions

181
plugins/streaming/icecast2 Executable file
View file

@ -0,0 +1,181 @@
#!/bin/sh
#
# Plugin to monitor icecast2 streams / listeners
#
# Contributed by drew Roberts
#
# based on the postfix_mailqueue plugin as per below
#
# Plugin to monitor postfix mail spools
#
# Contributed by Nicolai Langfeldt
#
# $Log$
# Revision 1.0 2008/07/04 16:02:36 zotz
# Initial work
#
#
#%# family=auto
#%# capabilities=autoconf
# Can be set via environment, but default is /var/spool/postfix
ICEDIR=${icedir:-/var/www/rrd/logs/stream_stats/}
case $1 in
autoconf|detect)
if [ -d $ICEDIR/ ] ; then
echo yes
exit 0
else
echo "no (icedir not found)"
exit 1
fi;;
config)
cat <<'EOF'
graph_title Icecast2 Stream Listeners
graph_args --base 1000 -l 0
graph_vlabel Listeners for Streams
graph_category stream
cool_ogg.label cool_ogg
cool_ogg.draw AREA
cool_ogg.type GAUGE
cool_mp3.label cool_mp3
cool_mp3.draw STACK
cool_mp3.type GAGUE
jamz_ogg.label jamz_ogg
jamz_ogg.draw STACK
jamz_ogg.type GAGUE
jamz_mp3.label jamz_mp3
jamz_mp3.draw STACK
jamz_mp3.type GAGUE
joy_ogg.label joy_ogg
joy_ogg.draw STACK
joy_ogg.type GAGUE
joy_mp3.label joy_mp3
joy_mp3.draw STACK
joy_mp3.type GAGUE
y_ogg.label y_ogg
y_ogg.draw STACK
y_ogg.type GAGUE
y_mp3.label y_mp3
y_mp3.draw STACK
y_mp3.type GAGUE
EOF
exit 0;;
esac
cd $ICEDIR >/dev/null 2>/dev/null || {
echo "# Cannot cd to $ICEDIR"
exit 1
}
/usr/bin/curl -s localhost:7144/status2.xsl > /tmp/ice.txt
/usr/bin/tail -n 1 /tmp/ice.txt > /tmp/ice1.txt
awk 'BEGIN {FS=","} {tot = 0 ; i = (NF-1)/6 ; j=1 ; while (j <= i) {tot = (tot + $(((j-1)*6)+4)) ; print $(((j-1)*6)+1), ":", $(((j-1)*6)+4) > "/tmp/ice2.txt" ; j++}; print "total :", tot >> "/tmp/ice2.txt"} ' /tmp/ice1.txt
# Cool ogg stream
grep cool.ogg /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
coologg="0"
else
coologg=`grep cool.ogg /tmp/ice2.txt | cut -d ":" -f 2 - `
coologg=$(($coologg+0))
fi
#echo $coologg
# Cool mp3 stream
grep coolmp3 /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
coolmp3="0"
else
coolmp3=`grep coolmp3 /tmp/ice2.txt | cut -d ":" -f 2 - `
coolmp3=$(($coolmp3+0))
fi
#echo $coolmp3
# Jamz ogg stream
grep jamz.ogg /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
jamzogg="0"
else
jamzogg=`grep jamz.ogg /tmp/ice2.txt | cut -d ":" -f 2 - `
jamzogg=$(($jamzogg+0))
fi
#echo $jamzogg
# Jamz mp3 stream
grep jamzmp3 /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
jamzmp3="0"
else
jamzmp3=`grep jamzmp3 /tmp/ice2.txt | cut -d ":" -f 2 - `
jamzmp3=$(($jamzmp3+0))
fi
#echo $jamzmp3
# Joy ogg stream
grep joy.ogg /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
joyogg="0"
else
joyogg=`grep joy.ogg /tmp/ice2.txt | cut -d ":" -f 2 - `
joyogg=$(($joyogg+0))
fi
#echo $joyogg
# Joy mp3 stream
grep joymp3 /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
joymp3="0"
else
joymp3=`grep joymp3 /tmp/ice2.txt | cut -d ":" -f 2 - `
joymp3=$(($joymp3+0))
fi
#echo $joymp3
# Y ogg stream
grep "/y.ogg" /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
yogg="0"
else
yogg=`grep "/y.ogg" /tmp/ice2.txt | cut -d ":" -f 2 - `
yogg=$(($yogg+0))
fi
#echo $yogg
# Y mp3 stream
grep "/ymp3" /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
ymp3="0"
else
ymp3=`grep "/ymp3" /tmp/ice2.txt | cut -d ":" -f 2 - `
ymp3=$(($ymp3+0))
fi
#echo $ymp3
# total streams
grep total /tmp/ice2.txt > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
totals="0"
else
totals=`grep total /tmp/ice2.txt | cut -d ":" -f 2 - `
totals=$(($totals+0))
fi
#echo $totals
# output=`echo $coologg:$coolmp3:$jamzogg:$jamzmp3:$joyogg:$joymp3:$yogg:$ymp3:$totals`
cat <<EOF
cool_ogg.value $coologg
cool_mp3.value $coolmp3
jamz_ogg.value $jamzogg
jamz_mp3.value $jamzmp3
joy_ogg.value $joyogg
joy_mp3.value $joymp3
y_ogg.value $yogg
y_mp3.value $ymp3
EOF

153
plugins/streaming/icecast2_ Executable file
View file

@ -0,0 +1,153 @@
#! /usr/bin/python
# -*- coding: iso-8859-1 -*-
# Hostname of Icecast server
# Just canonical name, no http:// nor ending /
host = "foo.bar.com"
username = "admin"
# Password for admin access to Icecast2 server to fetch statistics
password = ""
realm = "Icecast2 Server"
# Bitrates the MP3 stream is served with
mp3bitrates = [56, 128]
# Bitrates the Ogg Stream is served with
oggbitrates = [56, 128, 172]
# This plugin shows the statistics of a specific subset of sources connected to an Icecast2 server.
# Place the file in /usr/share/munin/plugins and then symlink to it from
# /etc/munin/plugins
# The name icecast2_total will show total number of listeners on server, as
# well the total number of listeners for any configured stream.
# For each stream with multiple bitrates, create one
# icecast2_streamname
# If the name contains a "-" exchange it with a "_", and the script will change it back for you. This is to satisfy internal requirements of Munin.
# For each streamname, the plugin will check for the configured bitrates
# Expecting the mountpoints to be on the form of
# /streamname_<bitrate> for mp3
# /streamname_<bitrate>.ogg for Ogg/Vorbis
import urllib2, os.path, time, sys
from xml.dom import minidom
def hent_XML():
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm, host, username, password)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
xmlweb = urllib2.urlopen("http://%s/admin/stats" % host)
xml = xmlweb.read()
xmlweb.close()
# Parser oversikt
xmldoc = minidom.parseString(xml)
xmldoc = xmldoc.firstChild
#Totalt antall lyttere
total_lyttere = xmldoc.getElementsByTagName("clients")[0].firstChild.nodeValue
#Totalt antall kilder
total_kilder = xmldoc.getElementsByTagName("sources")[0].firstChild.nodeValue
#Status for enkelt strøm
sources = xmldoc.getElementsByTagName("source")
sourcelist = {}
for source in sources:
mount = source.getAttribute("mount")
listeners = source.getElementsByTagName("listeners")[0].firstChild.nodeValue
name = source.getElementsByTagName("server_name")[0].firstChild.nodeValue
mount = mount.replace("-", "_")
sourcelist[mount[1:]] = (listeners, name)
sourcename = sys.argv[0].split("/")[-1][len("icecast2_"):]
if len(sys.argv) == 1:
sys.argv.append("")
if sys.argv[1] == "autoconf":
print "yes"
elif sys.argv[1] == "config":
if sourcename == "total":
print "graph_title Totalt antall lyttere"
print "graph_vlabel lyttere"
print "graph_category Icecast"
print "totallyttere.label Totalt antall lyttere"
print "totalkilder.label Totalt antall kilder"
chanlist = {}
for a, b, filelist in os.walk("/etc/munin/plugins"):
for file in filelist:
if file.find("icecast2_") != -1:
channelname = file[len("icecast2_"):]
if channelname != "total" and chanlist.has_key(channelname) != 1:
chanlist[channelname] = 0
chanlist = chanlist.keys()
chanlist.sort()
for chan in chanlist:
graphtitle = ""
for key in sourcelist.keys():
if key.find(chan) != -1:
l, graphtitle = sourcelist[key]
break
if graphtitle == "":
graphtitle = chan
print "%s.label %s" % (chan, graphtitle)
else:
sumstring = ""
graphtitle = ""
for key in sourcelist.keys():
if key.find(sourcename) != -1:
l, graphtitle = sourcelist[key]
break
if graphtitle == "":
graphtitle = sourcename
print "graph_title %s" % graphtitle
print "graph_vlabel lyttere"
print "graph_category Icecast"
for bitrate in mp3bitrates:
print "%s_%s.label %s-%s" % (sourcename, bitrate, "/" + sourcename.replace("_", "-"), bitrate)
sumstring += "%s_%s " % (sourcename, bitrate)
print "%s_%s.critical -0.5:" % (sourcename, bitrate)
for bitrate in oggbitrates:
print "%s_%s_ogg.label %s-%s.ogg" % (sourcename, bitrate, "/" + sourcename.replace("_", "-"), bitrate)
print "%s_%s_ogg.critical -0.5:" % (sourcename, bitrate)
sumstring += "%s_%s_ogg " % (sourcename, bitrate)
print "%slyttere.label Totalt antall lyttere" % sourcename
print "%slyttere.sum %s" % (sourcename, sumstring)
elif sys.argv[1] != "config":
if sourcename == "total":
print "totallyttere.value %s" % total_lyttere
print "totalkilder.value %s" % total_kilder
statslist = {}
for a, b, filelist in os.walk("/etc/munin/plugins"):
for file in filelist:
if file.find("icecast2_") != -1:
channelname = file[len("icecast2_"):]
if channelname != "total" and statslist.has_key(channelname) != 1:
statslist[channelname] = 0
for source in sourcelist:
listeners, name = sourcelist[source]
if not statslist.has_key(source[:source.rfind("_")]):
statslist[source[:source.rfind("_")]] = 0
statslist[source[:source.rfind("_")]] += int(listeners)
for stat in statslist:
print "%s.value %s" % (stat, statslist[stat])
else:
for bitrate in mp3bitrates:
if sourcelist.has_key("%s_%s" % (sourcename, bitrate)):
listeners = sourcelist["%s_%s" % (sourcename, bitrate)][0]
print listeners
else:
listeners = -1
print "%s_%s.value %s" % (sourcename, bitrate, listeners)
for bitrate in oggbitrates:
if sourcelist.has_key("%s_%s.ogg" % (sourcename, bitrate)):
listeners = sourcelist["%s_%s.ogg" % (sourcename, bitrate)][0]
else:
listeners = -1
print "%s_%s_ogg.value %s" % (sourcename, bitrate, listeners)
else:
print sys.argv[1]
if __name__ == "__main__":
hent_XML()

72
plugins/streaming/icecast2_all Executable file
View file

@ -0,0 +1,72 @@
#! /usr/bin/python
# -*- coding: iso-8859-1 -*-
# Hostname of Icecast server
# Just canonical name, no http:// nor ending /
host = "foo.bar.com"
username = "admin"
# Password for admin access to Icecast2 server to fetch statistics
password = ""
realm = "Icecast2 Server"
# This plugin shows the statistics of every source currently connected to the Icecast2 server. See the Icecast2_ plugin for specific mountpoint plugin.
import urllib2, os.path, time, sys
from xml.dom import minidom
def hent_XML():
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password(realm, host, username, password)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
xmlweb = urllib2.urlopen("http://%s/admin/stats" % host)
xml = xmlweb.read()
xmlweb.close()
# Parser oversikt
xmldoc = minidom.parseString(xml)
xmldoc = xmldoc.firstChild
#Totalt antall lyttere
total_lyttere = xmldoc.getElementsByTagName("clients")[0].firstChild.nodeValue
#Totalt antall kilder
total_kilder = xmldoc.getElementsByTagName("sources")[0].firstChild.nodeValue
#Status for enkelt strøm
sources = xmldoc.getElementsByTagName("source")
sourcelist = {}
for source in sources:
mount = source.getAttribute("mount")
listeners = source.getElementsByTagName("listeners")[0].firstChild.nodeValue
name = source.getElementsByTagName("server_name")[0].firstChild.nodeValue
mount = mount.replace("-", "_").replace(".", "_")
sourcelist[mount[1:]] = (listeners, name)
if len(sys.argv) > 0 and sys.argv[1] == "autoconf":
print "yes"
elif len(sys.argv) == 1 or sys.argv[1] != "config":
print "totallyttere.value %s" % total_lyttere
print "totalkilder.value %s" % total_kilder
sourcesort = sourcelist.keys()
sourcesort.sort()
for source in sourcesort:
listeners, name = sourcelist[source]
print "%s.value %s" % (source, listeners)
elif sys.argv[1] == "config":
print "graph_title Total number of listeners"
print "graph_vlabel listeners"
print "graph_category Icecast"
print "totallyttere.label Total number of listeners"
print "totalkilder.label Totalt number of sources"
sourcesort = sourcelist.keys()
sourcesort.sort()
for source in sourcesort:
listeners, name = sourcelist[source]
print "%s.label %s" % (source, "/" + source)
else:
print sys.argv[1]
if __name__ == "__main__":
hent_XML()

View file

@ -0,0 +1,70 @@
#!/usr/bin/ruby
#
# Plugin author: Gunnar Wolf <gwolf@gwolf.org>
#
# You are hereby granted authorization to copy, use, modify, distribute,
# and in general do anything you please with this plugin. It is too simple
# even to GPL-protect it.
#
# This plugin expects to receive via environment variables:
#
# icecast_host - Which host to monitor (default: 127.0.0.1)
# icecast_username - Username to connect with (default: admin)
# icecast_password - Password to connect with (default: hackme)
# icecast_realm - Realm to connect with (default: 'Icecast2 server')
#
require 'hpricot'
require 'open-uri'
def get_conf
# Default values
conf = {:host => '127.0.0.1', :port => 8000,
:username => 'admin', :password => 'hackme' }
conf.keys.each do |key|
env_key = sprintf('icecast_%s', key)
conf[key] = ENV[env_key] if ENV.has_key?(env_key)
end
conf
end
def get_data(conf)
begin
data = Hpricot(open(sprintf('http://%s:%s/admin/stats',
conf[:host], conf[:port]),
:http_basic_authentication=>[conf[:username],
conf[:password]]))
rescue OpenURI::HTTPError
puts "Cannot connect: HTTP connection error"
exit 1
end
data
end
def get_values(data)
vals = {}
[:sources, :clients].each do |key|
elem = data/key
if elem.nil?
vals[key] = 0
else
vals[key] = elem.innerHTML
end
end
vals
end
data = get_data(get_conf)
vals = get_values(data)
if ARGV[0] == 'autoconf'
puts 'yes'
elsif ARGV[0] == 'config'
puts "graph_title Total sources and clients for Icecast"
puts "graph_vlabel listeners"
puts "graph_category Icecast"
puts "sources.label Total number of sources"
puts "clients.label Total number of clients"
else
puts "sources.value " + vals[:sources]
puts "clients.value " + vals[:clients]
end

181
plugins/streaming/icecast_ Executable file
View file

@ -0,0 +1,181 @@
#!/usr/bin/env python2.5
"""
Plugin to monitor icecast2 streaming servers.
Author: Markus Lindenberg <markus.lindenberg@gmail.com>
COntributors: Julien 'Lta' BALLET <elthariel@gmail.com>
Version: 2009111101
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Usage:
- Link or copy to /etc/munin/plugins
- To enable listening duration, traffic and uptime stats,
also link to icecast_duration, icecast_traffic and
icecast_uptime respectively.
Configuration:
- Enter your server, user and pw below
(The plugin does not need to run on
the same host as your icecast2 server)
- Optionally provide hosts to exclude.
- Optionally provide sources to exclude.
Possible TODOs:
- use autoconf
- use munin's configuration system
- documentation
"""
# CONFIGURATION
server = "localhost:8000"
user = "admin"
pw = "yourpassword"
# Exclude these hosts when calculating listening duration / listeners count
# (we use this to prevent our aircheck recording system from appearing in the stats)
#exclude = ("123.123.123.123",)
exclude = ()
# Exclude these sources from calculation. This is usefull to excluse special sources like
# fallback sources which doesn't expose the same informations and then break this script
# Ever add fallback sources to this list
#source_exclude = ["/fallback.mp3", "/fallback.ogg"]
source_exclude = ("/fallback.mp3", "/fallback.ogg")
# /CONFIGURATION
from sys import argv, exit, stderr
import urllib
from xml.etree.ElementTree import ElementTree
from os.path import basename
class IcecastURLopener(urllib.FancyURLopener):
def prompt_user_passwd(self, host, realm):
return (user, pw)
opener = IcecastURLopener()
f = opener.open("http://%s/admin/listmounts" % server)
tree = ElementTree()
tree.parse(f)
f.close()
sources = []
for s in tree.getiterator("source"):
if s.attrib["mount"] not in source_exclude:
sources.append({"mount": s.attrib["mount"],
"listeners": s.find("listeners").text,
"connected": s.find("Connected").text})
plugin_name = basename(argv[0])
try:
if argv[1] == "config":
if plugin_name == "icecast_duration":
print "graph_title Icecast client listening duration"
print "graph_args --base 1000 -l 0"
print "graph_scale no"
print "graph_category Icecast"
print "graph_vlabel minutes"
print "avg.label average listening duration"
print "mdn.label median listening duration"
elif plugin_name == "icecast_uptime":
print "graph_title Icecast source uptime"
print "graph_args --base 1000 -l 0"
print "graph_scale no"
print "graph_category Icecast"
print "graph_vlabel hours"
for s in sources:
print "%s.label source %s" % (s["mount"].strip("/").replace(".","_").replace("-","_"), s["mount"])
elif plugin_name == "icecast_traffic":
print "graph_title Icecast outgoing traffic"
print "graph_args --base 1024 -l 0"
print "graph_category Icecast"
print "graph_vlabel bytes / second"
is_first = True
for s in sources:
sname = s["mount"].strip("/").replace(".","_").replace("-","_")
print "%s.label source %s" % (sname, s["mount"])
print "%s.type DERIVE" % sname
print "%s.min 0" % sname
if is_first:
print "%s.draw AREA" % sname
is_first = False
else:
print "%s.draw STACK" % sname
else:
print "graph_title Icecast listeners count"
print "graph_args --base 1000 -l 0"
print "graph_scale no"
print "graph_category Icecast"
print "graph_vlabel listeners"
is_first = True
for s in sources:
sname = s["mount"].strip("/").replace(".","_").replace("-","_")
print "%s.label source %s" % (sname, s["mount"])
if is_first:
print "%s.draw AREA" % sname
is_first = False
else:
print "%s.draw STACK" % sname
exit(0)
except IndexError:
pass
if plugin_name == "icecast_uptime":
for s in sources:
print "%s.value %s" % (s["mount"].strip("/").replace(".","_").replace("-","_"), int(s["connected"]) / 3600.)
elif plugin_name == "icecast_traffic":
f = opener.open("http://%s/admin/stats.xml" % server)
tree = ElementTree()
tree.parse(f)
f.close()
for s in tree.getiterator("source"):
print "%s.value %s" % (s.attrib["mount"].strip("/").replace(".","_").replace("-","_"), s.find("total_bytes_sent").text)
else:
durations = {}
for s in sources:
durations[s["mount"]] = []
f = opener.open("http://%s/admin/listclients?mount=%s" % (server, s["mount"]))
tree = ElementTree()
tree.parse(f)
f.close()
for l in tree.getiterator("listener"):
if l.find("IP").text not in exclude:
durations[s["mount"]].append(int(l.find("Connected").text))
if plugin_name == "icecast_duration":
if not durations:
exit(0)
alldurations = reduce(lambda x, y: x+y, durations.values())
alldurations.sort()
print "avg.value %s" % (sum(alldurations) / float(len(alldurations)) / 60.,)
if len(alldurations) % 2:
median = alldurations[len(alldurations) / 2] / 60.
elif len(alldurations):
median = (alldurations[len(alldurations) / 2 - 1] + alldurations[len(alldurations) / 2]) / 2. / 60.
else:
median = 0
print "mdn.value %s" % median
else:
for s in sources:
print "%s.value %s" % (s["mount"].strip("/").replace(".","_").replace("-","_"), len(durations[s["mount"]]))

137
plugins/streaming/shoutcast Executable file
View file

@ -0,0 +1,137 @@
#!/usr/local/bin/perl -w
# -*- cperl -*-
=head1 NAME
shoutcast online - Munin plugin to show online for shoutcast v1.9.8
=head1 CONFIGURATION
This shows the default configuration of this plugin. You can override
the status URL.
[shoutcast*]
env.url http://localhost:8000/7.html
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.0
=head1 AUTHOR
Stanislav Rudenko aka Sandel
=head1 LICENSE
none
=cut
my $ret = undef;
if (! eval "require LWP::UserAgent;"){
$ret = "LWP::UserAgent not found";
}
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://localhost:8000/7.html";
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
if ($ret){
print "no ($ret)\n";
exit 0;
}
my $ua = LWP::UserAgent->new(timeout => 30);
$ua->agent('XML Getter (Mozilla Compatible)');
my $request = HTTP::Request->new( 'GET' => $URL );
$request->protocol('HTTP/1.0');
my $response = $ua->request($request);
unless ($response->is_success and $response->content =~ /<HTML><meta http-equiv="Pragma" content="no-cache"><\/head><body>/im) {
print "no (no shoutcast status on $URL)\n";
exit 0;
} else {
print "yes\n";
exit 0;
}
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
# Default Settings
print "graph_title SHOUTcast Online\n";
print "graph_args --base 1000\n";
print "graph_category shoutcast\n";
print "graph_vlabel Connections per \${graph_period}\n";
# Max Listeners Allowed to Connect to Server
print "max_connections.draw AREA\n";
print "max_connections.colour cdcfc4\n";
print "max_connections.min 0\n";
print "max_connections.label Max Slots\n";
print "max_connections.type GAUGE\n";
# Peak Listeners
print "ax_used_connections.draw AREA\n";
print "ax_used_connections.colour ffd660\n";
print "ax_used_connections.min 0\n";
print "ax_used_connections.label Peak Listeners\n";
print "ax_used_connections.type GAUGE\n";
# DJ-Online tag must be eq to Peak Listeners
print "djonline_tag.draw AREA\n";
print "djonline_tag.colour e5ff60\n";
print "djonline_tag.min 0\n";
print "djonline_tag.label DJ-Online Tag\n";
print "djonline_tag.type GAUGE\n";
# Max Listeners Connected to Server
print "all_connections.draw LINE1\n";
print "all_connections.colour a00e95\n";
print "all_connections.min 0\n";
print "all_connections.label Listeners\n";
print "all_connections.type GAUGE\n";
# Max Unique Listeners Connected to Server
print "unique_connections.draw LINE1\n";
print "unique_connections.colour 330099\n";
print "unique_connections.min 0\n";
print "unique_connections.label Unique Listeners\n";
print "unique_connections.type GAUGE\n";
exit 0;
}
#my $ua = LWP::UserAgent->new(timeout => 30);
#my $response = $ua->request(HTTP::Request->new('GET',$URL));
my $ua = LWP::UserAgent->new(timeout => 30);
$ua->agent('XML Getter (Mozilla Compatible)');
my $request = HTTP::Request->new( 'GET' => $URL );
$request->protocol('HTTP/1.0');
my $response = $ua->request($request);
#<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>89,1,453,800,87,128,Kitadani Hiroshi - Bushi</body>
#print $response->content . "\n\n";
if ( $response->content =~ /<HTML><meta http-equiv="Pragma" content="no-cache"><\/head><body>(\d+),(\d+),(\d+),(\d+),(\d+),(\d+),(.*)<\/body>/s ) {
my $djonline = ( $7 =~ m/Dj-Online/i ) ? $3 : '0';
print "max_connections.value $4\n";
print "ax_used_connections.value $3\n";
print "djonline_tag.value $djonline\n";
print "all_connections.value $1\n";
print "unique_connections.value $5\n";
} else {
print "\n";
}

View file

@ -0,0 +1,442 @@
#!/usr/bin/perl
#
=head1 Shoutcast 2.0.x Plugin
A Plugin for monitoring a Shoutcast 2.0.x Server (Multigraph)
=head1 Munin Configuration
[shoutcast2_multi]
env.host 127.0.0.1 *default*
env.port 8000 *default*
env.pass changeme *default*
=head2 Munin Configuration Explanation
host = host we are attempting to connection to, can be ip, or hostname
port = port we need to connect to in order to get to admin.cgi
pass = password to use to authenticate as admin user
=head1 AUTHOR
Matt West < https://github.com/mhwest13 >
=head1 License
GPLv2
=head1 Magic Markers
#%# family=auto
#%# capabilities=autoconf
=cut
use strict;
use warnings;
use LWP::UserAgent;
use XML::Simple;
use Munin::Plugin;
need_multigraph();
=head1 Variable Declarations
This section is mainly for importing / declaring our environment variables.
This is were we will import the data from our plugin-conf.d file so we can
override the default settings which will only work for Shoutcast test configs.
=cut
my $host = $ENV{host} || '127.0.0.1';
my $port = $ENV{port} || 8000;
my $pass = $ENV{pass} || 'changeme';
# Initialize hashref for storing results information...
my $dataRef;
# Create a hashref for our graph information that we will call up later...
my $graphsRef;
my $ua = LWP::UserAgent->new();
$ua->agent('Munin Shoutcast Plugin/0.1');
$ua->timeout(5);
$ua->credentials($host.':'.$port, 'Shoutcast Server', 'admin'=>$pass);
=head1 Graphs Declarations
The following section of code contains our graph information. This is the data
provided to Munin, so that it may properly draw our graphs based on the values
the plugin returns.
While you are free to change colors or labels changing the type, min, or max
could cause unfortunate problems with your graphs.
=cut
$graphsRef->{active} = {
config => {
args => '--base 1000 --lower-limit 0',
vlabel => 'Is a DJ Actively Connected?',
category => 'shoutcast2',
title => 'Active States',
info => 'This graph shows us the active state or not, depending on if a DJ is connected',
},
datasrc => [
{ name => 'active', draw => 'AREA', min => '0', max => '1', label => 'On or Off', type => 'GAUGE' },
],
};
$graphsRef->{listeners} = {
config => {
args => '--base 1000 --lower-limit 0',
vlabel => 'Listener Count',
category => 'shoutcast2',
title => 'Listeners',
info => 'This graph shows us the various counts for listener states we are tracking',
},
datasrc => [
{ name => 'maxlisteners', draw => 'AREA', min => '0', label => 'Max Listeners', type => 'GAUGE' },
{ name => 'currlisteners', draw => 'STACK', min => '0', label => 'Current Listeners', type => 'GAUGE' },
],
};
$graphsRef->{sid_active} = {
config => {
args => '--base 1000 --lower-limit 0',
vlabel => 'Is a DJ Actively Connected?',
title => 'Active State',
info => 'This graph shows us the active state or not, depending on if a DJ is connected',
},
datasrc => [
{ name => 'active', draw => 'AREA', min => '0', max => '1', label => 'On or Off', type => 'GAUGE', xmlkey => 'STREAMSTATUS' },
],
};
$graphsRef->{sid_listeners} = {
config => {
args => '--base 1000 --lower-limit 0',
vlabel => 'Listener Count',
title => 'Listeners',
info => 'This graph shows us the various counts for listener states we are tracking',
},
datasrc => [
{ name => 'maxlisteners', draw => 'AREA', min => '0', label => 'Max Listeners', type => 'GAUGE', xmlkey => 'MAXLISTENERS' },
{ name => 'currlisteners', draw => 'STACK', min => '0', label => 'Current Listeners', type => 'GAUGE', xmlkey => 'CURRENTLISTENERS' },
{ name => 'peaklisteners', draw => 'LINE2', min => '0', label => 'Peak Listeners', type => 'GAUGE', xmlkey => 'PEAKLISTENERS' },
{ name => 'uniqlisteners', draw => 'LINE2', min => '0', label => 'Unique Listeners', type => 'GAUGE', xmlkey => 'UNIQUELISTENERS' },
],
};
if (defined($ARGV[0]) && ($ARGV[0] eq 'config')) {
config();
exit;
}
if (defined($ARGV[0]) && (($ARGV[0] eq 'autoconf') || ($ARGV[0] eq 'suggest'))) {
check_autoconf();
exit;
}
# I guess we are collecting stats to return, execute main subroutine.
main();
exit;
=head1 Subroutines
The following is a description of what each subroutine is for and does
=head2 main
This subroutine is our main routine should we not be calling up autoconf
or config. Ultimately this routine will print out the values for each graph
and graph data point we are tracking.
=cut
sub main {
my ($returnBit,$adminRef) = fetch_admin_data();
if ($returnBit == 0) {
exit;
}
my $streamConfigRef = $adminRef->{STREAMCONFIGS}->{STREAMCONFIG};
my $sidDataRef;
if ($adminRef->{STREAMCONFIGS}->{TOTALCONFIGS} == 1) {
my $sid = $streamConfigRef->{id};
my ($return,$tmpSidRef) = fetch_sid_data($sid);
if ($return == 0) {
# Only one stream, and we didn't get a good response.
exit;
}
$sidDataRef->{$sid} = $tmpSidRef;
} else {
foreach my $sid (keys %{$streamConfigRef}) {
my ($return,$tmpSidRef) = fetch_sid_data($sid);
if ($return == 0) {
next;
}
$sidDataRef->{$sid} = $tmpSidRef;
}
}
print_active_data($sidDataRef);
print_listener_data($adminRef->{STREAMCONFIGS}->{SERVERMAXLISTENERS}, $sidDataRef);
return;
}
=head2 print_active_data
Thie subroutine prints out the active graph values for each stream and ultimately for
the entire shoutcast service. Should 1 Stream be active, but 5 streams available,
the global graph should show the state as active for the service, but clicking into
that graph, should give you a stream level view of which stream was in use during
what time periods.
=cut
sub print_active_data {
my ($sidDataRef) = (@_);
my $globalActive = 0;
foreach my $sid (sort keys %{$sidDataRef}) {
print "multigraph shoutcast2_active.active_sid_$sid\n";
foreach my $dsrc (@{$graphsRef->{sid_active}->{datasrc}}) {
print "$dsrc->{name}.value $sidDataRef->{$sid}->{$dsrc->{xmlkey}}\n";
if ($sidDataRef->{$sid}->{$dsrc->{xmlkey}} == 1) {
$globalActive = 1;
}
}
}
print "multigraph shoutcast2_active\n";
foreach my $dsrc (@{$graphsRef->{active}->{datasrc}}) {
print "$dsrc->{name}.value $globalActive\n";
}
return;
}
=head2 print_listener_data
This subroutine prints out the listener graph values for each stream and ultimately
adds all of the current users together to show that against the maxserver count in
the global graph. Clicking on the global graph will reveal a bit more information
about the users on a stream by stream basis.
=cut
sub print_listener_data {
my ($maxListeners,$sidDataRef) = (@_);
my $globalListeners = 0;
foreach my $sid (sort keys %{$sidDataRef}) {
print "multigraph shoutcast2_listeners.listeners_sid_$sid\n";
foreach my $dsrc (@{$graphsRef->{sid_listeners}->{datasrc}}) {
print "$dsrc->{name}.value $sidDataRef->{$sid}->{$dsrc->{xmlkey}}\n";
if ($dsrc->{name} eq 'currlisteners') {
$globalListeners += $sidDataRef->{$sid}->{$dsrc->{xmlkey}};
}
}
}
print "multigraph shoutcast2_listeners\n";
foreach my $dsrc (@{$graphsRef->{listeners}->{datasrc}}) {
if ($dsrc->{name} eq 'maxlisteners') {
print "$dsrc->{name}.value $maxListeners\n";
} else {
print "$dsrc->{name}.value $globalListeners\n";
}
}
return;
}
=head2 config
The config subroutine can be seen as the main config routine, which
will call up to your shoutcast server to figure out how many streams
you have running, and then print out the appropriate multigraph info.
Ultimately this subroutine will call two more routines to print out
the graph args / configuration information.
=cut
sub config {
my ($returnBit,$adminRef) = fetch_admin_data();
if ($returnBit == 0) {
# $adminRef returned a string, we'll just print it out.
print "no (error response: $adminRef)\n";
exit;
}
my $streamConfigRef = $adminRef->{STREAMCONFIGS}->{STREAMCONFIG};
my $sidDataRef;
if ($adminRef->{STREAMCONFIGS}->{TOTALCONFIGS} == 1) {
my $sid = $streamConfigRef->{id};
my ($return,$tmpSidRef) = fetch_sid_data($sid);
if ($return == 0) {
# Only one stream, and we didn't get a good response.
exit;
}
$sidDataRef->{$sid} = $tmpSidRef;
} else {
foreach my $sid (keys %{$streamConfigRef}) {
my ($return,$tmpSidRef) = fetch_sid_data($sid);
if ($return == 0) {
next;
}
$sidDataRef->{$sid} = $tmpSidRef;
}
}
print_active_config($sidDataRef);
print_listener_config($sidDataRef);
return;
}
=head2 print_active_config
This subroutine prints out the graph information for our active graphs.
It prints the sub-multigraphs first based on stream id, and finally the
root active graph. Its not suggested that you mess with this routine
unless you fully understand what its doing and how munin graph_args work.
=cut
sub print_active_config {
my ($sidDataRef) = (@_);
foreach my $sid (sort keys %{$sidDataRef}) {
# Print the Config Info First
print "multigraph shoutcast2_active.active\_sid\_$sid\n";
print "graph_title ".$graphsRef->{sid_active}->{config}->{title}." for StreamID: $sid\n";
print "graph_args ".$graphsRef->{sid_active}->{config}->{args}."\n";
print "graph_vlabel ".$graphsRef->{sid_active}->{config}->{vlabel}."\n";
print "graph_category streamid_$sid\n";
print "graph_info ".$graphsRef->{sid_active}->{config}->{info}."\n";
# Print the Data Value Info
foreach my $dsrc (@{$graphsRef->{sid_active}->{datasrc}}) {
while ( my ($key, $value) = each (%{$dsrc})) {
next if ($key eq 'name');
next if ($key eq 'xmlkey');
print "$dsrc->{name}.$key $value\n";
}
}
}
print "multigraph shoutcast2_active\n";
print "graph_title ".$graphsRef->{active}->{config}->{title}."\n";
print "graph_args ".$graphsRef->{active}->{config}->{args}."\n";
print "graph_vlabel ".$graphsRef->{active}->{config}->{vlabel}."\n";
print "graph_category ".$graphsRef->{active}->{config}->{category}."\n";
print "graph_info ".$graphsRef->{active}->{config}->{info}."\n";
# Print the Data Value Info
foreach my $dsrc (@{$graphsRef->{active}->{datasrc}}) {
while ( my ($key, $value) = each (%{$dsrc})) {
next if ($key eq 'name');
print "$dsrc->{name}.$key $value\n";
}
}
return;
}
=head2 print_listener_config
This subroutine prints out the graph information for our listeners graphs.
It prints the sub-multigraphs first based on stream id, and finally the
root listeners graph. Its not suggested that you mess with this routine
unless you fully understand what its doing and how munin graph_args work.
=cut
sub print_listener_config {
my ($sidDataRef) = (@_);
foreach my $sid (sort keys %{$sidDataRef}) {
# Print the Config Info First
print "multigraph shoutcast2_listeners.listeners\_sid\_$sid\n";
print "graph_title ".$graphsRef->{sid_listeners}->{config}->{title}." for StreamID: $sid\n";
print "graph_args ".$graphsRef->{sid_listeners}->{config}->{args}."\n";
print "graph_vlabel ".$graphsRef->{sid_listeners}->{config}->{vlabel}."\n";
print "graph_category streamid_$sid\n";
print "graph_info ".$graphsRef->{sid_listeners}->{config}->{info}."\n";
# Print the Data Value Info
foreach my $dsrc (@{$graphsRef->{sid_listeners}->{datasrc}}) {
while ( my ($key, $value) = each (%{$dsrc})) {
next if ($key eq 'name');
next if ($key eq 'xmlkey');
print "$dsrc->{name}.$key $value\n";
}
}
}
print "multigraph shoutcast2_listeners\n";
print "graph_title ".$graphsRef->{listeners}->{config}->{title}."\n";
print "graph_args ".$graphsRef->{listeners}->{config}->{args}."\n";
print "graph_vlabel ".$graphsRef->{listeners}->{config}->{vlabel}."\n";
print "graph_category ".$graphsRef->{listeners}->{config}->{category}."\n";
print "graph_info ".$graphsRef->{listeners}->{config}->{info}."\n";
# Print the Data Value Info
foreach my $dsrc (@{$graphsRef->{listeners}->{datasrc}}) {
while ( my ($key, $value) = each (%{$dsrc})) {
next if ($key eq 'name');
print "$dsrc->{name}.$key $value\n";
}
}
return;
}
=head2 check_autoconf
This subroutine is called up when we intercept autoconf specified in ARGV[0]
If we are able to connect to the shoutcast service as admin and fetch the main
admin stats page, we will return ok, otherwise we will return no and the error
response we got from LWP::UserAgent.
=cut
sub check_autoconf {
my ($returnBit,$adminRef) = fetch_admin_data();
if ($returnBit == 0) {
# $adminRef returned a string, we'll just print it out.
print "no (error response: $adminRef)\n";
} else {
print "yes\n";
}
return;
}
=head2 fetch_sid_data
This subroutine is called up to fetch information on a per stream mentality.
If we are able to connect to the shoutcast service and get the stats we will
return 1 and a hashref of the de-coded xml information, otherwise we return 0
so that we know that we have failed and can handle it gracefully.
=cut
sub fetch_sid_data {
my ($sid) = (@_);
my $url = 'http://'.$host.':'.$port.'/stats?sid='.$sid;
my $response = $ua->get($url);
if ($response->is_success) {
my $returnRef = XMLin($response->decoded_content);
return (1, $returnRef);
} else {
return (0, $response->status_line);
}
}
=head2 fetch_admin_data
This subroutine is called up to fetch information from the admin page to get stream ids.
This subroutine is also used to test that we can connect to the shoutcast service
and if not we can fail gracefully. If we are able to connect to the shoutcast service
and get the stats we will return 1 and a hashref of the de-coded xml information,
otherwise we return 0 so that we know that we have failed and can handle it gracefully.
=cut
sub fetch_admin_data {
my $url = 'http://'.$host.':'.$port.'/admin.cgi?sid=1&mode=viewxml&page=6';
my $response = $ua->get($url);
if ($response->is_success) {
my $returnRef = XMLin($response->decoded_content);
if (($returnRef->{STREAMCONFIGS}->{TOTALCONFIGS} > 0) && (defined($returnRef->{STREAMCONFIGS}->{STREAMCONFIG}))) {
return (1, $returnRef);
} else {
return (0, 'Unable to Detect any Stream Configurations');
}
} else {
return (0, $response->status_line);
}
}

View file

@ -1,121 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Andy Linton, CityLink, New Zealand
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Derived from SNMP plugin code written by
# Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
#######################################################################
#
# You must enable SNMP for Windows Media Services by running:
#
# regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll
#
#######################################################################
#
# $Log: snmp__wmsConnectedPlayers,v $
# Revision 1.2 2007/08/09 22:14:13 root
# Modified using 'rcsedit'
#
# Revision 1.1 2007/08/09 22:07:16 root
# Checked in using 'rcsedit'
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $MAXLABEL = 20;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.4.1.311.1.7.13.3.0 [0-9]\n"; # Number
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsConnectedPlayers$/)
{
$host = $1;
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title wmsConnectedPlayers
graph_args --base 1000 -l 0
graph_vlabel wmsConnectedPlayers
graph_category streaming
graph_info This graph shows wmsConnectedPlayers.
wmsConnectedPlayers.label wmsConnectedPlayers
wmsConnectedPlayers.draw LINE2
wmsConnectedPlayers.info The wmsConnectedPlayers
";
exit 0;
}
print "wmsConnectedPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.3.0"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}

View file

@ -1,127 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Andy Linton, CityLink, New Zealand
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Derived from SNMP plugin code written by
# Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
#######################################################################
#
# You must enable SNMP for Windows Media Services by running:
#
# regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll
#
#######################################################################
#
# $Log: snmp__wmsPlayerAllocatedBandwidth,v $
# Revision 1.4 2007/08/09 22:15:50 root
# Modified using 'rcsedit'
#
# Revision 1.3 2007/03/02 19:22:33 root
# Modified using 'rcsedit'
#
# Revision 1.2 2007/03/02 19:19:31 root
# Modified using 'rcsedit'
#
# Revision 1.1 2007/03/02 19:15:28 root
# Checked in using 'rcsedit'
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $MAXLABEL = 20;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.4.1.311.1.7.13.1.0 [0-9]\n"; # Number
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsPlayerAllocatedBandwidth$/)
{
$host = $1;
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title wmsPlayerAllocatedBandwidth
graph_args --base 1000 -l 0
graph_vlabel wmsPlayerAllocatedBandwidth
graph_category streaming
graph_info This graph shows wmsPlayerAllocatedBandwidth.
wmsPlayerAllocatedBandwidth.label wmsPlayerAllocatedBandwidth
wmsPlayerAllocatedBandwidth.draw LINE2
wmsPlayerAllocatedBandwidth.info The wmsPlayerAllocatedBandwidth.
";
exit 0;
}
print "wmsPlayerAllocatedBandwidth.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.1.0"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}

View file

@ -1,122 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Andy Linton, CityLink, New Zealand
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Derived from SNMP plugin code written by
# Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
#######################################################################
#
# You must enable SNMP for Windows Media Services by running:
#
# regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll
#
#######################################################################
#
# $Log: snmp__wmsStreamingHttpPlayers,v $
# Revision 1.2 2007/08/09 22:16:37 root
# Modified using 'rcsedit'
#
# Revision 1.1 2007/08/09 22:16:02 root
# Checked in using 'rcsedit'
#
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $MAXLABEL = 20;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.4.1.311.1.7.13.6.0 [0-9]\n"; # Number
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsStreamingHttpPlayers$/)
{
$host = $1;
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title wmsStreamingHttpPlayers
graph_args --base 1000 -l 0
graph_vlabel wmsStreamingHttpPlayers
graph_category streaming
graph_info This graph shows wmsStreamingHttpPlayers.
wmsStreamingHttpPlayers.label wmsStreamingHttpPlayers
wmsStreamingHttpPlayers.draw LINE2
wmsStreamingHttpPlayers.info The wmsStreamingHttpPlayers
";
exit 0;
}
print "wmsStreamingHttpPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.6.0"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}

View file

@ -1,122 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Andy Linton, CityLink, New Zealand
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Derived from SNMP plugin code written by
# Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
#######################################################################
#
# You must enable SNMP for Windows Media Services by running:
#
# regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll
#
#######################################################################
#
# $Log: snmp__wmsStreamingMmsPlayers,v $
# Revision 1.2 2007/08/09 22:18:23 root
# Modified using 'rcsedit'
#
# Revision 1.1 2007/08/09 22:17:51 root
# Checked in using 'rcsedit'
#
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $MAXLABEL = 20;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.4.1.311.1.7.13.7.0 [0-9]\n"; # Number
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsStreamingMmsPlayers$/)
{
$host = $1;
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title wmsStreamingMmsPlayers
graph_args --base 1000 -l 0
graph_vlabel wmsStreamingMmsPlayers
graph_category streaming
graph_info This graph shows wmsStreamingMmsPlayers.
wmsStreamingMmsPlayers.label wmsStreamingMmsPlayers
wmsStreamingMmsPlayers.draw LINE2
wmsStreamingMmsPlayers.info The wmsStreamingMmsPlayers
";
exit 0;
}
print "wmsStreamingMmsPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.7.0"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}

View file

@ -1,119 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Andy Linton, CityLink, New Zealand
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Derived from SNMP plugin code written by
# Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
#######################################################################
#
# You must enable SNMP for Windows Media Services by running:
#
# regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll
#
#######################################################################
#
# $Log: snmp__wmsStreamingPlayers,v $
# Revision 1.4 2007/08/09 22:18:39 root
# Modified using 'rcsedit'
#
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $MAXLABEL = 20;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.4.1.311.1.7.13.10.0 [0-9]\n"; # Number
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsStreamingPlayers$/)
{
$host = $1;
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title wmsStreamingPlayers
graph_args --base 1000 -l 0
graph_vlabel wmsStreamingPlayers
graph_category streaming
graph_info This graph shows wmsStreamingPlayers.
wmsStreamingPlayers.label wmsStreamingPlayers
wmsStreamingPlayers.draw LINE2
wmsStreamingPlayers.info The wmsStreamingPlayers
";
exit 0;
}
print "wmsStreamingPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.10.0"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}

View file

@ -1,121 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Andy Linton, CityLink, New Zealand
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Derived from SNMP plugin code written by
# Jimmy Olsen, Dagfinn Ilmari Mannsaaker
#
#######################################################################
#
# You must enable SNMP for Windows Media Services by running:
#
# regsvr32 "%systemroot%\system32\windows media\server\wmssnmp.dll
#
#######################################################################
#
# $Log: snmp__wmsStreamingRtspPlayers,v $
# Revision 1.2 2007/08/09 22:19:32 root
# Modified using 'rcsedit'
#
# Revision 1.1 2007/08/09 22:18:54 root
# Checked in using 'rcsedit'
#
#%# family=snmpauto
#%# capabilities=snmpconf
use strict;
use Net::SNMP;
my $DEBUG = 0;
my $MAXLABEL = 20;
my $host = $ENV{host} || undef;
my $port = $ENV{port} || 161;
my $community = $ENV{community} || "public";
my $iface = $ENV{interface} || undef;
my $response;
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
{
print "require 1.3.6.1.4.1.311.1.7.13.9.0 [0-9]\n"; # Number
exit 0;
}
if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_wmsStreamingRtspPlayers$/)
{
$host = $1;
if ($host =~ /^([^:]+):(\d+)$/)
{
$host = $1;
$port = $2;
}
}
elsif (!defined($host))
{
print "# Debug: $0 -- $1\n" if $DEBUG;
die "# Error: couldn't understand what I'm supposed to monitor.";
}
my ($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port
);
if (!defined ($session))
{
die "Croaking: $error";
}
if (defined $ARGV[0] and $ARGV[0] eq "config")
{
print "host_name $host\n";
print "graph_title wmsStreamingRtspPlayers
graph_args --base 1000 -l 0
graph_vlabel wmsStreamingRtspPlayers
graph_category streaming
graph_info This graph shows wmsStreamingRtspPlayers.
wmsStreamingRtspPlayers.label wmsStreamingRtspPlayers
wmsStreamingRtspPlayers.draw LINE2
wmsStreamingRtspPlayers.info The wmsStreamingRtspPlayers
";
exit 0;
}
print "wmsStreamingRtspPlayers.value ", &get_single ($session, "1.3.6.1.4.1.311.1.7.13.9.0"), "\n";
sub get_single
{
my $handle = shift;
my $oid = shift;
print "# Getting single $oid...\n" if $DEBUG;
$response = $handle->get_request ($oid);
if (!defined $response->{$oid})
{
return undef;
}
else
{
return $response->{$oid};
}
}