/usr/share/munin/plugins/pop_stats is in munin-plugins-extra 2.0.37-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #!/usr/bin/perl
# -*- perl -*-
#%# family=contrib
$pop{'statefile'} = "$ENV{MUNIN_PLUGSTATE}/munin-pop-log.state";
$pos = undef;
$logons = 0;
$pop{'logfile'} = '/var/log/poplog';
if (-f $pop{'logfile'} . ".0")
{
$pop{'rotlogfile'} = $pop{'logfile'} . ".0";
}
elsif (-f $pop{'logfile'} . ".1")
{
$pop{'rotlogfile'} = $pop{'logfile'} . ".1";
}
elsif (-f $pop{'logfile'} . ".01")
{
$pop{'rotlogfile'} = $pop{'logfile'} . ".01";
}
else
{
$pop{'rotlogfile'} = $pop{'logfile'} . ".0";
}
(-f "/etc/linpro/rrd-client.conf") and eval `cat /etc/linpro/rrd-client.conf`;
if ( $ARGV[0] and $ARGV[0] eq "config" )
{
print "graph_title POP logon stats\n";
print "graph_args --base 1000\n";
print "graph_vlabel logons / \${graph_period}\n";
print "logon.label logons\n";
print "logon.type DERIVE\n";
print "logon.min 0\n";
print "logon.draw LINE1\n";
exit 0;
}
if (! -f $pop{'logfile'} and ! -f $pop{'rotlogfile'})
{
print "logon.value U\n";
exit 0;
}
if (-f $pop{'statefile'})
{
open (IN, $pop{'statefile'}) or exit 4;
if (<IN> =~ /^(\d+):(\d+):(\d+)/)
{
($pos, $logons) = ($1, $2, $3);
}
close IN;
}
$startsize = (stat $pop{'logfile'})[7];
if (!defined $pos)
{
# Initial run.
$pos = $startsize;
}
if ($startsize < $pos)
{
# Log rotated
parseEximfile ($pop{'rotlogfile'}, $pos, (stat $pop{'rotlogfile'})[7]);
$pos = 0;
}
parsePopfile ($pop{'logfile'}, $pos, $startsize);
$pos = $startsize;
print "logons.value $logons\n";
open (OUT, ">" . $pop{'statefile'}) or exit 4;
print OUT "$pos:$logons\n";
close OUT;
sub parsePopfile
{
my ($fname, $start, $stop) = @_;
open (LOGFILE, $fname) or exit 3;
seek (LOGFILE, $start, 0) or exit 2;
while (tell (LOGFILE) < $stop)
{
my $line =<LOGFILE>;
chomp ($line);
if ($line =~ / login by/)
{
$logons++;
}
}
close(LOGFILE);
}
# vim:syntax=perl
|