Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package CloudForecast::Data::Qmailqueue;
use CloudForecast::Data -base;
use CloudForecast::Log;
rrds map { [ $_, 'GAUGE' ] } qw /queue preprocess/;
graphs 'queue' => 'Qmail Queue';
title { "Qmail Queue" };
fetcher {
my $c = shift;
my $etbl = $c->component('SNMP')->table("nsExtendConfigTable");
if ( !$etbl ) {
CloudForecast::Log->warn("couldnot get ExtendConfigTable");
return [undef, undef];
}
my $iid;
for my $id ( keys %{$etbl} ) {
if ( $etbl->{$id}->{nsExtendToken} eq 'qmail' ) {
$iid = $id;
last;
}
}
if ( !$iid ) {
CloudForecast::Log->warn("couldnot find qmail configuration");
return [undef, undef];
}
my $ret = $c->component('SNMP')->get(["nsExtendOutputFull",$iid]);
my $content = $ret->[0];
my $queue;
my $preprocess;
if ( $content =~ m!messages in queue: (\d+)! ) {
$queue = $1;
}
if ( $content =~ m!messages in queue but not yet preprocessed: (\d+)! ) {
$preprocess = $1;
}
return [ $queue, $preprocess ];
};
__DATA__
@@ queue
DEF:my1=<%RRD%>:queue:AVERAGE
DEF:my2=<%RRD%>:preprocess:AVERAGE
AREA:my2#0000FF: Preprocess
GPRINT:my2:LAST:Current\:%6.2lf
GPRINT:my2:AVERAGE:Ave\:%6.2lf
GPRINT:my2:MAX:Max\:%6.2lf\c
STACK:my1#C00000: Queue
GPRINT:my1:LAST:Current\:%6.2lf
GPRINT:my1:AVERAGE:Ave\:%6.2lf
GPRINT:my1:MAX:Max\:%6.2lf\c
extend qmail /pato/to/bin/qmail-qstat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment