diff --git a/ykval-munin-responses.pl b/ykval-munin-responses.pl new file mode 100755 index 0000000..dc3f6ce --- /dev/null +++ b/ykval-munin-responses.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +#%# family=auto +#%# capabilities=autoconf + +use strict; +use warnings; + +my @types = qw/OK BAD_OTP MISSING_PARAMETER BACKEND_ERROR BAD_SIGNATURE DELAYED_OTP NO_SUCH_CLIENT NOT_ENOUGH_ANSWERS REPLAYED_REQUEST REPLAYED_OTP OPERATION_NOT_ALLOWED/; +my $logfile = "/var/log/yubikey-val-server-php.log"; + +if(@ARGV > 0) { + if($ARGV[0] eq "autoconf") { + print "yes\n"; + exit 0; + } elsif($ARGV[0] eq "config") { + print "multigraph yk_responses\n"; + print "graph_title YK-VAL response types\n"; + print "graph_vlabel responses\n"; + print "graph_category ykval\n"; + + foreach my $type (@types) { + print "${type}.label ${type}\n"; + print "${type}.type DERIVE\n"; + print "${type}.info Responses\n"; + print "${type}.min 0\n"; + print "${type}.draw LINE1\n"; + } + exit 0 + } + print "unknown command '${ARGV[0]}'\n"; + exit 1 +} + +my %statuses = map { $_ => 0 } @types; + +my $reg = qr/status=([A-Z_]+)/; +open (LOGFILE, "grep 'ykval-verify.*Response' $logfile |"); +while() { + next unless /$reg/; + $statuses{$1}++; +} +close LOGFILE; + +print "multigraph yk_responses\n"; +foreach my $type (@types) { + print "${type}.value ${statuses{$type}}\n"; +} +exit 0