#! /usr/bin/perl # Copyright (C) 2008 Joey Schulze # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 dated June, 1991. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. # Source: http://www.infodrom.org/Infodrom/tools/munin.html # Supported configuration: # # [hylafax] # user root # env.faxstat /usr/bin/faxstat use strict; use warnings; my $faxstat = '/usr/bin/faxstat'; $faxstat = $ENV{'faxstat'} if exists $ENV{'faxstat'}; sub gather { my $q = 0; if (open(my $sendq, "$faxstat -s|")) { while (<$sendq>) { next unless /^\d/; chomp; $q++; } close $sendq; } return $q; } if (@ARGV) { if ($ARGV[0] eq 'autoconf' || $ARGV[0] eq 'detect') { if (system("$faxstat > /dev/null 2>&1") == 0) { print "yes\n"; exit 0; } else { print "no\n"; exit 1; } } elsif ($ARGV[0] eq 'config') { print "graph_title HylaFAX Queue\n"; print "graph_args -l 0\n"; print "graph_vlabel Faxes in queue\n"; print "graph_category hylafax\n"; print "graph_info This graph shows the number of unsent fax messages in the queue.\n"; print "sendq.label Send Queue\n"; exit 0; } } printf "sendq.value %d\n", gather;