From 1c60f63b11a526b0bf0c983fbef6230717208448 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Thu, 10 Jan 2013 10:27:35 +0100 Subject: [PATCH 1/2] db2_cnx: adding a plugin for monitoring DB2 connections --- plugins/db2/db2_cnx | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 plugins/db2/db2_cnx diff --git a/plugins/db2/db2_cnx b/plugins/db2/db2_cnx new file mode 100644 index 00000000..d6d60ad1 --- /dev/null +++ b/plugins/db2/db2_cnx @@ -0,0 +1,37 @@ +#! /bin/sh +# (c) 2012 - Steve Schnepp - LGPL + +# XXX - coded hastily + +# Source the DB2 profile +. /home/db2inst1/sqllib/db2profile + +echo "graph_title Number of connections" +echo "graph_category DB2" +echo "graph_args -l 0" + +db2 list application | tail +5 | awk ' /^[A-Z]/ { print $1 }' | sort | uniq -c > $HOME/run/$(basename $0).txt + +# Get users list +touch $HOME/run/$(basename $0).users +awk '{ print $2 }' $HOME/run/$(basename $0).txt | cat $HOME/run/$(basename $0).users - | sort -ru > $HOME/run/$(basename $0).users.tmp +mv $HOME/run/$(basename $0).users.tmp $HOME/run/$(basename $0).users + +# Emit config +if [ "$1" = "config" ] +then + awk ' { print $1 ".label " $1 "\n" $1 ".draw AREASTACK" }' $HOME/run/$(basename $0).users +fi + +# Emit values +for i in $( cat $HOME/run/$(basename $0).users ) +do + TMPLINE=$(awk -v i=$i '($2 == i) { print }' $HOME/run/$(basename $0).txt) + if [ -z "$TMPLINE" ] + then + echo "$i.value 0" + else + echo "$TMPLINE" | awk ' { print $2 ".value " $1 }' + + fi +done From 1db419b1ee79d3fffd889ea530adba17fe7f1759 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Thu, 10 Jan 2013 10:32:05 +0100 Subject: [PATCH 2/2] db2_cnx: +x --- plugins/db2/db2_cnx | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 plugins/db2/db2_cnx diff --git a/plugins/db2/db2_cnx b/plugins/db2/db2_cnx old mode 100644 new mode 100755