2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #23 from lkarsten/master

Further development on munin-node-from-hell (UTF8, plugins in warnings, verbosity decided runtime)
This commit is contained in:
Steve Schnepp 2012-02-09 09:25:55 -08:00
commit 13662ae943
5 changed files with 108 additions and 20 deletions

View File

@ -10,8 +10,8 @@ stuff we do at http://hostedmunin.com/ . Use it as you feel fit :)
Current features controlled via config file: Current features controlled via config file:
* Respond slowly or never to queries. * Respond slowly or never to queries.
* Have plugins that always are in warning or alarm. * Have plugins that always are in warning or critical.
* Extensive number of plugins. * Extensive number of plugins running at once.
* Run on multiple ports at the same time, to test huge amounts of clients. * Run on multiple ports at the same time, to test huge amounts of clients.
@ -21,8 +21,8 @@ Usage
munin-node-from-hell takes two arguments; the mode and which config file to munin-node-from-hell takes two arguments; the mode and which config file to
use. Mode is either --run or --muninconf. use. Mode is either --run or --muninconf.
This software is meant to run as an ordinary unix user, please don't run This software is meant to run as an ordinary Unix user, please don't run
it as root without some thought. it as root.
You probably want: You probably want:

View File

@ -0,0 +1,15 @@
#
# Initialise plugins that test the basic functions of Munin.
#
#
[instance:basic]
pluginprofile = basic
port = 4000
[pluginprofile:basic]
plugins = always_warning, always_critical, graph_area
[base]
# when building an example config with --muninconf, what hostname to output.
hostname = localhost

View File

@ -1,4 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
# .- coding: utf-8 -.
# #
# Artificial munin node that behaves in all the ways you would like # Artificial munin node that behaves in all the ways you would like
# ordinary nodes _not_ to behave. # ordinary nodes _not_ to behave.
@ -84,25 +85,90 @@ class tarpit(MuninPlugin):
modules["tarpit"] = tarpit() modules["tarpit"] = tarpit()
class always_warning(MuninPlugin): class always_warning(MuninPlugin):
conftext = """graph_title Always in LEVEL
graph_vlabel Level
graph_scale no
graph_info A simple graph that is always in LEVEL
graph_category always_LEVEL
generic.label Level
generic.info Level usually above warning level
generic.warning 5
generic.critical 10"""
def fetch(self, conf): def fetch(self, conf):
return "generic.value 10" return "generic.value 10"
def config(self, conf): def config(self, conf):
return """graph_title Always in warning return self.conftext.replace("LEVEL","warning")
graph_vlabel Level
graph_scale no
graph_info A simple graph that is always in warning or alarm
graph_category active_notification
generic.label Level
generic.info Level usually above warning level
generic.warn 5
generic.crit 10"""
modules["always_warning"] = always_warning() modules["always_warning"] = always_warning()
class always_alarm(always_warning): class always_critical(always_warning):
def fetch(self, conf): def fetch(self, conf):
return "generic.value 20" return "generic.value 20"
modules["always_alarm"] = always_alarm()
def config(self, conf):
return self.conftext.replace("LEVEL","critical")
modules["always_critical"] = always_critical()
class graph_area(MuninPlugin):
"A plugin that uses STACK and AREA. From proc_pri. Use: testing the grapher"
def fetch(self, conf):
return """high.value 3
low.value 2
locked.value 1"""
def config(self, conf):
return """graph_title AREA and STACK
graph_order low high locked
graph_category graphtest
graph_info This graph shows nuber of processes at each priority
graph_args --base 1000 -l 0
graph_vlabel Number of processes
high.label high priority
high.draw STACK
high.info The number of high-priority processes (tasks)
low.label low priority
low.draw AREA
low.info The number of low-priority processes (tasks)
locked.label locked in memory
locked.draw STACK
locked.info The number of processes that have pages locked into memory (for real-time and custom IO)
"""
modules["graph_area"] = graph_area()
class utf8_graphcat(MuninPlugin):
"A plugin with a graph category which has UTF-8 in it"
def fetch(self, conf):
load = open("/proc/loadavg", "r").read()
load, rest = load.split(" ", 1)
load = float(load)
return "apples.value %.2f" % load
def config(self, conf):
return """graph_title Example UTF-8 graph
graph_vlabel apples
graph_category foo™
apples.label apples
graph_info Apples eaten
apples.info Apples eaten"""
modules["utf8_graphcat"] = utf8_graphcat()
class utf8_graphname(MuninPlugin):
"A plugin with a UTF-8 name"
def fetch(self, conf):
load = open("/proc/loadavg", "r").read()
load, rest = load.split(" ", 1)
load = float(load)
return "apples.value %.2f" % load
def config(self, conf):
return """graph_title Example UTF-8 graph
graph_vlabel apples
graph_category system
apples.label apples
graph_info Apples eaten
apples.info Apples eaten"""
modules["utf8_™graphname"] = utf8_graphname()
class ArgumentTCPserver(SocketServer.ThreadingTCPServer): class ArgumentTCPserver(SocketServer.ThreadingTCPServer):
@ -122,7 +188,7 @@ class MuninHandler(SocketServer.StreamRequestHandler):
""" """
def handle(self): def handle(self):
print "%s: Connection from %s:%s. server args is %s" \ if self.server.args.get("verbose"): print "%s: Connection from %s:%s. server args is %s" \
% (self.server.args["name"], self.client_address[0], self.client_address[1], self.server.args) % (self.server.args["name"], self.client_address[0], self.client_address[1], self.server.args)
# slow path # slow path
hostname = self.server.args["name"] hostname = self.server.args["name"]
@ -198,15 +264,19 @@ def start_servers(instances):
def usage(): def usage():
print "Usage: %s [--run] [--muninconf] <configfile>" % sys.argv[0] print "Usage: %s [--run] [--verbose] [--muninconf] <configfile>" % sys.argv[0]
def main(): def main():
if len(sys.argv) <= 2: if len(sys.argv) <= 2:
usage() usage()
sys.exit(1) sys.exit(1)
verbose = False
if "--verbose" in sys.argv:
verbose = True
config = ConfigParser.RawConfigParser() config = ConfigParser.RawConfigParser()
config.read(sys.argv[2]) config.read(sys.argv[-1])
instancekeys = [ key for key in config.sections() if key.startswith("instance:") ] instancekeys = [ key for key in config.sections() if key.startswith("instance:") ]
servers = {} servers = {}
@ -260,6 +330,8 @@ def main():
instanceconfig[k] = v instanceconfig[k] = v
instanceconfig["plugins"] = plugins instanceconfig["plugins"] = plugins
if "--verbose" in sys.argv:
instanceconfig["verbose"] = True
instanceconfig["name"] = "%s-%s" % (instancename, portinstance) instanceconfig["name"] = "%s-%s" % (instancename, portinstance)
instanceconfig["expanded_port"] = portinstance instanceconfig["expanded_port"] = portinstance
@ -275,6 +347,7 @@ def main():
if "--run" in sys.argv: if "--run" in sys.argv:
if verbose: print "Starting up.."
servers = start_servers(instances) servers = start_servers(instances)
try: try:

View File

@ -12,7 +12,7 @@ port = 3000
#port = 4940 #port = 4940
#sleepyness = 30 #sleepyness = 30
[pluginprofile:notif] [pluginprofile:notif]
plugins = always_warning, always_alarm plugins = always_warning, always_critical
[base] [base]
# when building an example config with --muninconf, what hostname to output. # when building an example config with --muninconf, what hostname to output.

View File

@ -6,7 +6,7 @@ pluginprofile = tarpit
port = 3000 port = 3000
[pluginprofile:tarpit] [pluginprofile:tarpit]
plugins = tarpit, load, locks plugins = load, locks, tarpit, load, locks
[pluginprofile:base] [pluginprofile:base]
plugins = load, locks, locks, load, load, locks, locks, load, load, load plugins = load, locks, locks, load, load, locks, locks, load, load, load