#!/bin/sh # # Plugin to monitor the number of recent transactions by user in RT. # # Usage: copy or link into /etc/munin/node.d/ # # Parameters: # # config (required) # autoconf (optional - used by munin-config) # # Config variables: # # logdir - Which logfile to use # logfile - What file to read in logdir # # # Magic markers (optional - used by munin-config and some installation # scripts): # #%# family=contrib PGSQL="/usr/local/bin/psql" PGDB="rt3" if [ "$1" = "autoconf" ]; then # print "no (No RT user found. Please consult your RT administrator.)\n"; # exit 1; echo yes exit 0 fi # [ML] NOTE: we do the u.name filters in the join statement: # sounds absurd, but otherwise the query takes a very long time to execute. # On the downside.. it seems to generate an empty entry (null).. and if we try to filter it out the script does a timeout if [ "$1" = "config" ]; then echo 'graph_title RT transactions by user in past 7 days' echo 'graph_vlabel transactions' echo 'graph_category rt' $PGSQL -F" " -t -A -c "select u.name || '.label', u.name FROM transactions as t LEFT JOIN users as u ON (u.id = t.creator AND u.name not in ('rt', 'RT_System') AND u.name not like '%@%') where t.created > NOW() - interval '3 day' AND t.type IN ('Comment', 'Correspond') group by u.name order by u.name ASC;" $PGDB exit 0 fi $PGSQL -F" " -t -A -c "select u.name || '.value', count(*) as cpt FROM transactions as t LEFT JOIN users as u ON (u.id = t.creator AND u.name not in ('rt', 'RT_System') AND u.name not like '%@%') where t.created > NOW() - interval '3 day' AND t.type IN ('Comment', 'Correspond') group by u.name order by u.name ASC;" $PGDB