aboutsummaryrefslogtreecommitdiff
path: root/net/analyzer/munin/plugins/icecast
blob: b5fea5178001140a5b5918896a66a519b6f0c8ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# icecast munin plugin
# feedback: rhatto at riseup.net | gpl
#
# configuration example:
#
#  [icecast]
#  env.host localhost
#  evn.port 8000
#  env.stats /munin.xsl 
#  env.lynx /usr/bin/lynx
#
# munin.xsl example:
#
# <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
# <xsl:output omit-xml-declaration="no" method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
#             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" encoding="UTF-8" />
# <xsl:template match = "/icestats" >
# <xsl:for-each select="source">
# <xsl:value-of select="@mount" />.value, <xsl:value-of select="listeners" /><br />
# </xsl:for-each>
# </xsl:template>
# </xsl:stylesheet>
#

if [ -z "$host" ]; then
  host="localhost"
fi

if [ -z "$port" ]; then
  port="8000"
fi

if [ -z "$stats" ]; then
  stats="munin.xsl"
fi

if [ -z "$lynx" ]; then
  lynx="/usr/bin/lynx"
fi

if [ "$1" == "config" ]; then
  cat << EOF
graph_title Icecast usage
graph_vlabel Listeners
graph_category other
EOF

for mount in `$lynx http://$host:$port/$stats -dump | cut -d , -f 1 | sed -e 's/\///g' -e 's/^   //' -e 's/.value//' -e 's/\./_/g' `; do
  echo $mount.label $mount
done

exit 0
else

  $lynx http://$host:$port/$stats -dump | sed -e 's/,//g' -e 's/\///g' -e 's/^   //' -e 's/\.ogg/_ogg/'

fi