Révision ac7a7ccf
Support source exclusion (for fallbacks sources) and fix support of sources containing a dash in their names
| plugins/other/icecast_ | ||
|---|---|---|
| 39 | 39 |
|
| 40 | 40 |
# CONFIGURATION |
| 41 | 41 |
|
| 42 |
server = "127.0.0.1:8000"
|
|
| 43 |
user = "admin" |
|
| 44 |
pw = "your_icecast_admin_password"
|
|
| 42 |
server = "radio.schlag.fr:2342"
|
|
| 43 |
user = "lta-admin"
|
|
| 44 |
pw = "suckm3g00dyaoldbitch"
|
|
| 45 | 45 |
|
| 46 | 46 |
# Exclude these hosts when calculating listening duration / listeners count |
| 47 | 47 |
# (we use this to prevent our aircheck recording system from appearing in the stats) |
| 48 | 48 |
#exclude = ("123.123.123.123",)
|
| 49 | 49 |
exclude = () |
| 50 | 50 |
|
| 51 |
# Exclude these sources from calcultation |
|
| 52 |
# Ever add fallback sources to this list |
|
| 53 |
#source_exclude = ["/fallback.mp3", "/fallback.ogg"] |
|
| 54 |
source_exclude = ("/fallback.mp3", "/fallback.ogg")
|
|
| 55 |
|
|
| 51 | 56 |
# /CONFIGURATION |
| 52 | 57 |
|
| 53 | 58 |
from sys import argv, exit, stderr |
| ... | ... | |
| 68 | 73 |
|
| 69 | 74 |
sources = [] |
| 70 | 75 |
for s in tree.getiterator("source"):
|
| 71 |
sources.append({"mount": s.attrib["mount"],
|
|
| 72 |
"listeners": s.find("listeners").text,
|
|
| 73 |
"connected": s.find("Connected").text})
|
|
| 76 |
if s.attrib["mount"] not in source_exclude: |
|
| 77 |
sources.append({"mount": s.attrib["mount"],
|
|
| 78 |
"listeners": s.find("listeners").text,
|
|
| 79 |
"connected": s.find("Connected").text})
|
|
| 74 | 80 |
|
| 75 | 81 |
plugin_name = basename(argv[0]) |
| 76 | 82 |
|
| ... | ... | |
| 91 | 97 |
print "graph_category Icecast" |
| 92 | 98 |
print "graph_vlabel hours" |
| 93 | 99 |
for s in sources: |
| 94 |
print "%s.label source %s" % (s["mount"].strip("/").replace(".","_"), s["mount"])
|
|
| 100 |
print "%s.label source %s" % (s["mount"].strip("/").replace(".","_").replace("-","_"), s["mount"])
|
|
| 95 | 101 |
elif plugin_name == "icecast_traffic": |
| 96 | 102 |
print "graph_title Icecast outgoing traffic" |
| 97 | 103 |
print "graph_args --base 1024 -l 0" |
| ... | ... | |
| 99 | 105 |
print "graph_vlabel bytes / second" |
| 100 | 106 |
is_first = True |
| 101 | 107 |
for s in sources: |
| 102 |
sname = s["mount"].strip("/").replace(".","_")
|
|
| 108 |
sname = s["mount"].strip("/").replace(".","_").replace("-","_")
|
|
| 103 | 109 |
print "%s.label source %s" % (sname, s["mount"]) |
| 104 | 110 |
print "%s.type DERIVE" % sname |
| 105 | 111 |
print "%s.min 0" % sname |
| ... | ... | |
| 116 | 122 |
print "graph_vlabel listeners" |
| 117 | 123 |
is_first = True |
| 118 | 124 |
for s in sources: |
| 119 |
sname = s["mount"].strip("/").replace(".","_")
|
|
| 125 |
sname = s["mount"].strip("/").replace(".","_").replace("-","_")
|
|
| 120 | 126 |
print "%s.label source %s" % (sname, s["mount"]) |
| 121 | 127 |
if is_first: |
| 122 | 128 |
print "%s.draw AREA" % sname |
| ... | ... | |
| 131 | 137 |
|
| 132 | 138 |
if plugin_name == "icecast_uptime": |
| 133 | 139 |
for s in sources: |
| 134 |
print "%s.value %s" % (s["mount"].strip("/").replace(".","_"), int(s["connected"]) / 3600.)
|
|
| 140 |
print "%s.value %s" % (s["mount"].strip("/").replace(".","_").replace("-","_"), int(s["connected"]) / 3600.)
|
|
| 135 | 141 |
|
| 136 | 142 |
elif plugin_name == "icecast_traffic": |
| 137 | 143 |
f = opener.open("http://%s/admin/stats.xml" % server)
|
| ... | ... | |
| 139 | 145 |
tree.parse(f) |
| 140 | 146 |
f.close() |
| 141 | 147 |
for s in tree.getiterator("source"):
|
| 142 |
print "%s.value %s" % (s.attrib["mount"].strip("/").replace(".","_"), s.find("total_bytes_sent").text)
|
|
| 148 |
print "%s.value %s" % (s.attrib["mount"].strip("/").replace(".","_").replace("-","_"), s.find("total_bytes_sent").text)
|
|
| 143 | 149 |
|
| 144 | 150 |
else: |
| 145 | 151 |
durations = {}
|
| ... | ... | |
| 168 | 174 |
print "mdn.value %s" % median |
| 169 | 175 |
else: |
| 170 | 176 |
for s in sources: |
| 171 |
print "%s.value %s" % (s["mount"].strip("/").replace(".","_"), len(durations[s["mount"]]))
|
|
| 177 |
print "%s.value %s" % (s["mount"].strip("/").replace(".","_").replace("-","_"), len(durations[s["mount"]]))
|
|
| 172 | 178 |
|
Formats disponibles : Unified diff