mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
Plugin icecast2_: fix code style issues reported by flake8
This commit is contained in:
parent
c466adc4d3
commit
ab3a583756
2 changed files with 91 additions and 85 deletions
|
@ -1,6 +1,12 @@
|
||||||
#! /usr/bin/python
|
#! /usr/bin/python
|
||||||
# -*- coding: iso-8859-1 -*-
|
# -*- coding: iso-8859-1 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import urllib2
|
||||||
|
from xml.dom import minidom
|
||||||
|
|
||||||
|
|
||||||
# Hostname of Icecast server
|
# Hostname of Icecast server
|
||||||
# Just canonical name, no http:// nor ending /
|
# Just canonical name, no http:// nor ending /
|
||||||
host = "foo.bar.com"
|
host = "foo.bar.com"
|
||||||
|
@ -21,14 +27,13 @@ oggbitrates = [56, 128, 172]
|
||||||
# well the total number of listeners for any configured stream.
|
# well the total number of listeners for any configured stream.
|
||||||
# For each stream with multiple bitrates, create one
|
# For each stream with multiple bitrates, create one
|
||||||
# icecast2_streamname
|
# 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.
|
# 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
|
# For each streamname, the plugin will check for the configured bitrates
|
||||||
# Expecting the mountpoints to be on the form of
|
# Expecting the mountpoints to be on the form of
|
||||||
# /streamname_<bitrate> for mp3
|
# /streamname_<bitrate> for mp3
|
||||||
# /streamname_<bitrate>.ogg for Ogg/Vorbis
|
# /streamname_<bitrate>.ogg for Ogg/Vorbis
|
||||||
|
|
||||||
import urllib2, os.path, time, sys
|
|
||||||
from xml.dom import minidom
|
|
||||||
|
|
||||||
def hent_XML():
|
def hent_XML():
|
||||||
auth_handler = urllib2.HTTPBasicAuthHandler()
|
auth_handler = urllib2.HTTPBasicAuthHandler()
|
||||||
|
@ -76,7 +81,7 @@ def hent_XML():
|
||||||
for file in filelist:
|
for file in filelist:
|
||||||
if file.find("icecast2_") != -1:
|
if file.find("icecast2_") != -1:
|
||||||
channelname = file[len("icecast2_"):]
|
channelname = file[len("icecast2_"):]
|
||||||
if channelname != "total" and chanlist.has_key(channelname) != 1:
|
if channelname != "total" and channelname not in chanlist:
|
||||||
chanlist[channelname] = 0
|
chanlist[channelname] = 0
|
||||||
chanlist = chanlist.keys()
|
chanlist = chanlist.keys()
|
||||||
chanlist.sort()
|
chanlist.sort()
|
||||||
|
@ -103,11 +108,13 @@ def hent_XML():
|
||||||
print "graph_vlabel lyttere"
|
print "graph_vlabel lyttere"
|
||||||
print "graph_category streaming"
|
print "graph_category streaming"
|
||||||
for bitrate in mp3bitrates:
|
for bitrate in mp3bitrates:
|
||||||
print "%s_%s.label %s-%s" % (sourcename, bitrate, "/" + sourcename.replace("_", "-"), bitrate)
|
print "%s_%s.label %s-%s" % (sourcename, bitrate,
|
||||||
|
"/" + sourcename.replace("_", "-"), bitrate)
|
||||||
sumstring += "%s_%s " % (sourcename, bitrate)
|
sumstring += "%s_%s " % (sourcename, bitrate)
|
||||||
print "%s_%s.critical -0.5:" % (sourcename, bitrate)
|
print "%s_%s.critical -0.5:" % (sourcename, bitrate)
|
||||||
for bitrate in oggbitrates:
|
for bitrate in oggbitrates:
|
||||||
print "%s_%s_ogg.label %s-%s.ogg" % (sourcename, bitrate, "/" + sourcename.replace("_", "-"), bitrate)
|
print "%s_%s_ogg.label %s-%s.ogg" % (sourcename, bitrate,
|
||||||
|
"/" + sourcename.replace("_", "-"), bitrate)
|
||||||
print "%s_%s_ogg.critical -0.5:" % (sourcename, bitrate)
|
print "%s_%s_ogg.critical -0.5:" % (sourcename, bitrate)
|
||||||
sumstring += "%s_%s_ogg " % (sourcename, bitrate)
|
sumstring += "%s_%s_ogg " % (sourcename, bitrate)
|
||||||
print "%slyttere.label Totalt antall lyttere" % sourcename
|
print "%slyttere.label Totalt antall lyttere" % sourcename
|
||||||
|
@ -121,26 +128,26 @@ def hent_XML():
|
||||||
for file in filelist:
|
for file in filelist:
|
||||||
if file.find("icecast2_") != -1:
|
if file.find("icecast2_") != -1:
|
||||||
channelname = file[len("icecast2_"):]
|
channelname = file[len("icecast2_"):]
|
||||||
if channelname != "total" and statslist.has_key(channelname) != 1:
|
if channelname != "total" and channelname not in statslist:
|
||||||
statslist[channelname] = 0
|
statslist[channelname] = 0
|
||||||
|
|
||||||
for source in sourcelist:
|
for source in sourcelist:
|
||||||
listeners, name = sourcelist[source]
|
listeners, name = sourcelist[source]
|
||||||
if not statslist.has_key(source[:source.rfind("_")]):
|
if source[:source.rfind("_")] not in statslist:
|
||||||
statslist[source[:source.rfind("_")]] = 0
|
statslist[source[:source.rfind("_")]] = 0
|
||||||
statslist[source[:source.rfind("_")]] += int(listeners)
|
statslist[source[:source.rfind("_")]] += int(listeners)
|
||||||
for stat in statslist:
|
for stat in statslist:
|
||||||
print "%s.value %s" % (stat, statslist[stat])
|
print "%s.value %s" % (stat, statslist[stat])
|
||||||
else:
|
else:
|
||||||
for bitrate in mp3bitrates:
|
for bitrate in mp3bitrates:
|
||||||
if sourcelist.has_key("%s_%s" % (sourcename, bitrate)):
|
if ("%s_%s" % (sourcename, bitrate)) in sourcelist:
|
||||||
listeners = sourcelist["%s_%s" % (sourcename, bitrate)][0]
|
listeners = sourcelist["%s_%s" % (sourcename, bitrate)][0]
|
||||||
print listeners
|
print listeners
|
||||||
else:
|
else:
|
||||||
listeners = -1
|
listeners = -1
|
||||||
print "%s_%s.value %s" % (sourcename, bitrate, listeners)
|
print "%s_%s.value %s" % (sourcename, bitrate, listeners)
|
||||||
for bitrate in oggbitrates:
|
for bitrate in oggbitrates:
|
||||||
if sourcelist.has_key("%s_%s.ogg" % (sourcename, bitrate)):
|
if ("%s_%s.ogg" % (sourcename, bitrate)) in sourcelist:
|
||||||
listeners = sourcelist["%s_%s.ogg" % (sourcename, bitrate)][0]
|
listeners = sourcelist["%s_%s.ogg" % (sourcename, bitrate)][0]
|
||||||
else:
|
else:
|
||||||
listeners = -1
|
listeners = -1
|
||||||
|
|
|
@ -157,7 +157,6 @@ plugins/http/wget_page
|
||||||
plugins/i2p/i2p_
|
plugins/i2p/i2p_
|
||||||
plugins/icecast/icecast_
|
plugins/icecast/icecast_
|
||||||
plugins/icecast/icecast2
|
plugins/icecast/icecast2
|
||||||
plugins/icecast/icecast2_
|
|
||||||
plugins/icecast/icecast2_all
|
plugins/icecast/icecast2_all
|
||||||
plugins/icecast/icecast2_stats_
|
plugins/icecast/icecast2_stats_
|
||||||
plugins/imapproxy/imapproxy_multi
|
plugins/imapproxy/imapproxy_multi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue