From 8354c8ba4b72986b39bc16ca0d3f18b888afa3c2 Mon Sep 17 00:00:00 2001 From: Lasse Karstensen Date: Sat, 17 Mar 2012 21:00:03 +0100 Subject: [PATCH 1/6] Support multiple config files at once --- tools/munin-node-from-hell/muninnode-from-hell | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/munin-node-from-hell/muninnode-from-hell b/tools/munin-node-from-hell/muninnode-from-hell index 30b05473..e58c2816 100755 --- a/tools/munin-node-from-hell/muninnode-from-hell +++ b/tools/munin-node-from-hell/muninnode-from-hell @@ -264,7 +264,7 @@ def start_servers(instances): def usage(): - print "Usage: %s [--run] [--verbose] [--muninconf] " % sys.argv[0] + print "Usage: %s [--run] [--verbose] [--muninconf] " % sys.argv[0] def main(): if len(sys.argv) <= 2: @@ -276,7 +276,12 @@ def main(): verbose = True config = ConfigParser.RawConfigParser() - config.read(sys.argv[-1]) + for configfile in sys.argv[1:]: + if not configfile.endswith(".conf"): + continue + if verbose: + print "Reading config file %s" % configfile + config.read(configfile) instancekeys = [ key for key in config.sections() if key.startswith("instance:") ] servers = {} @@ -330,14 +335,14 @@ def main(): instanceconfig[k] = v instanceconfig["plugins"] = plugins - if "--verbose" in sys.argv: - instanceconfig["verbose"] = True + instanceconfig["verbose"] = verbose instanceconfig["name"] = "%s-%s" % (instancename, portinstance) instanceconfig["expanded_port"] = portinstance instances.append(instanceconfig) # XXX: need to store what handlers we should have. + print instances # output sample munin config for the poller if "--muninconf" in sys.argv: From be1fb5df6578c4eac7c72860f6a79aa468a4ae6f Mon Sep 17 00:00:00 2001 From: Lasse Karstensen Date: Sat, 17 Mar 2012 21:00:19 +0100 Subject: [PATCH 2/6] minor stuff --- tools/munin-node-from-hell/basic.conf | 4 ++-- tools/munin-node-from-hell/notifications.conf | 2 +- tools/munin-node-from-hell/tarpit.conf | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/munin-node-from-hell/basic.conf b/tools/munin-node-from-hell/basic.conf index 64c83add..985a11d0 100644 --- a/tools/munin-node-from-hell/basic.conf +++ b/tools/munin-node-from-hell/basic.conf @@ -5,10 +5,10 @@ [instance:basic] pluginprofile = basic -port = 4000 +port = 4001 [pluginprofile:basic] -plugins = always_warning, always_critical, graph_area +plugins = graph_area [base] # when building an example config with --muninconf, what hostname to output. diff --git a/tools/munin-node-from-hell/notifications.conf b/tools/munin-node-from-hell/notifications.conf index 61f05118..f3593de0 100644 --- a/tools/munin-node-from-hell/notifications.conf +++ b/tools/munin-node-from-hell/notifications.conf @@ -5,7 +5,7 @@ [instance:notifications] pluginprofile = notif -port = 3000 +port = 4010 # #[instance:baz] diff --git a/tools/munin-node-from-hell/tarpit.conf b/tools/munin-node-from-hell/tarpit.conf index ecc6cc29..3e68f1e7 100644 --- a/tools/munin-node-from-hell/tarpit.conf +++ b/tools/munin-node-from-hell/tarpit.conf @@ -3,14 +3,11 @@ [instance:tarpit] pluginprofile = tarpit -port = 3000 +port = 4005 [pluginprofile:tarpit] plugins = load, locks, tarpit, load, locks -[pluginprofile:base] -plugins = load, locks, locks, load, load, locks, locks, load, load, load - [base] # when building an example config with --muninconf, what hostname to output. hostname = localhost From 164f6c89c6c631cc466acb87349b649dc0844313 Mon Sep 17 00:00:00 2001 From: Lasse Karstensen Date: Sat, 17 Mar 2012 21:00:26 +0100 Subject: [PATCH 3/6] many --- tools/munin-node-from-hell/huge.conf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tools/munin-node-from-hell/huge.conf diff --git a/tools/munin-node-from-hell/huge.conf b/tools/munin-node-from-hell/huge.conf new file mode 100644 index 00000000..43a83c90 --- /dev/null +++ b/tools/munin-node-from-hell/huge.conf @@ -0,0 +1,14 @@ +# +# Quick estimate says 30 plugins is a good estimate for a common client. +# + +[instance:huge] +pluginprofile = huge +portrange = 4000-4100 + +[pluginprofile:huge] +plugins = load, locks, load, locks, load, locks, load, locks, load, locks, load, locks, load, locks, load, locks ,load, locks, load, locks, load, locks, load, locks ,load, locks, load, locks, load, locks, load, locks + +[base] +# when building an example config with --muninconf, what hostname to output. +hostname = localhost From 219b679f5c373bef2b424a543e6c6eec8fabfc91 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sun, 18 Mar 2012 12:34:48 +0100 Subject: [PATCH 4/6] adding a glassfish plugin with wildcard --- plugins/glassfish/glassfish_counters_ | 95 +++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 plugins/glassfish/glassfish_counters_ diff --git a/plugins/glassfish/glassfish_counters_ b/plugins/glassfish/glassfish_counters_ new file mode 100644 index 00000000..2e9ce701 --- /dev/null +++ b/plugins/glassfish/glassfish_counters_ @@ -0,0 +1,95 @@ +#!/bin/ksh +# -*- sh -*- + +: << =cut + +=head1 NAME + +glassfish_counters_ - Wildcard-plugin to monitor counters in GlassFish + +=head1 CONFIGURATION + +This plugin does need the full path to the asadmin script: + [glassfish_counters_*] + env.ASADMIN /usr/local/glassfish/bin/asadmin + +This is a wildcard plugin. To monitor an subtree, link +glassfish_counters_ to this file. E.g. + + ln -s /usr/share/munin/plugins/glassfish_counters_ \ + /etc/munin/plugins/glassfish_counters_server.web.request + +...will monitor server.web.request.* + +To ignore certain counters, just add more "IGNORE" lines on top of +the awk script. (XXX: Fixme for env.) + +=head1 AUTHOR +Philipp Buehler + +=head1 LICENSE + +BSD 2-clause + +=head1 VERSION + + $Id: glassfish_counters_.in$ + 0.0.1 + +=cut +[ -z $ASADMIN ] && { + echo "ASADMIN not set in node configuration" + exit 1 + } || MUN_AS_ADMIN=${ASADMIN} + +check_link () { + scriptname=${0##*/} + myself=${scriptname##*_} + if [ "x$myself" = "x" ] ; then + echo "plugin must be symlinked, e.g. to glassfish_counters_server.web.request" + exit 1 + fi +} + +SUBTREE=${0##*glassfish_counters_} + +case $1 in + suggest) + echo "not implemented" + exit 0 + ;; + config) + check_link + $MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ + awk 'BEGIN{ FS="[ = ]" } + /requestcount/ { next; } # IGNORE + /dotted-name/ { myself = $NF + print "graph_title GlassFish", myself + print "graph_vlabel count" + print "graph_category glassfish" + print "graph_info this shows available counters from", myself + next + } + /-name / { nwhat = split($1, what, ".") + gsub(/-name/, "", what[nwhat]) + print what[nwhat] ".label=" $NF + } + /-description / { nwhat = split($1, what, ".") + gsub(/-description/, "", what[nwhat]) + $1 = ""; line = $0 + gsub(/^ /,"", line) + print what[nwhat] ".info=" line + } + ' + exit 0 + ;; +esac + +check_link +$MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ +awk 'BEGIN{ FS="[ = ]" } + /requestcount/ { next;} # IGNORE + /-count / { nwhat = split($1, what, ".") + gsub(/-count/, "", what[nwhat]) + print what[nwhat] ".value=" $NF} +' \ No newline at end of file From dec087a5ce4f9767c828e318dd27ba63297f75d0 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sun, 18 Mar 2012 12:40:03 +0100 Subject: [PATCH 5/6] using bash instead of ksh. it should be quite compatible. better would be a proper port to sh (or better, perl) --- plugins/glassfish/glassfish_counters_ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/glassfish/glassfish_counters_ b/plugins/glassfish/glassfish_counters_ index 2e9ce701..1bd26d7d 100644 --- a/plugins/glassfish/glassfish_counters_ +++ b/plugins/glassfish/glassfish_counters_ @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/bash # -*- sh -*- : << =cut @@ -92,4 +92,4 @@ awk 'BEGIN{ FS="[ = ]" } /-count / { nwhat = split($1, what, ".") gsub(/-count/, "", what[nwhat]) print what[nwhat] ".value=" $NF} -' \ No newline at end of file +' From 2580942ba2878b3fcc33394e699b293ca3c0eee9 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sun, 18 Mar 2012 12:56:22 +0100 Subject: [PATCH 6/6] fixed output --- plugins/glassfish/glassfish_counters_ | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/glassfish/glassfish_counters_ b/plugins/glassfish/glassfish_counters_ index 1bd26d7d..a13fd68e 100644 --- a/plugins/glassfish/glassfish_counters_ +++ b/plugins/glassfish/glassfish_counters_ @@ -61,7 +61,7 @@ case $1 in config) check_link $MUN_AS_ADMIN get -t --monitor=true "${SUBTREE}.*" | \ - awk 'BEGIN{ FS="[ = ]" } + awk 'BEGIN{ FS="[ = ]"} /requestcount/ { next; } # IGNORE /dotted-name/ { myself = $NF print "graph_title GlassFish", myself @@ -72,13 +72,14 @@ case $1 in } /-name / { nwhat = split($1, what, ".") gsub(/-name/, "", what[nwhat]) - print what[nwhat] ".label=" $NF + print what[nwhat] ".label " $NF + print what[nwhat] ".type GAUGE" } /-description / { nwhat = split($1, what, ".") gsub(/-description/, "", what[nwhat]) $1 = ""; line = $0 gsub(/^ /,"", line) - print what[nwhat] ".info=" line + print what[nwhat] ".info " line } ' exit 0