diff --git a/plugins/other/punbb_users b/plugins/other/punbb_users new file mode 100755 index 00000000..fec3cd2c --- /dev/null +++ b/plugins/other/punbb_users @@ -0,0 +1,91 @@ +#!/usr/bin/perl +# +# Plugin to monitor the number of users on a punbb forum +# +# Requirements: +# - Needs access to the forum +# +# Parameters supported: +# +# config +# autoconf +# +# Configurable variables +# +# url to extern.php +# +# +# $Log$ +# +# +# +# Magic markers: +#%# family=auto +#%# capabilities=autoconf + +my $ret = undef; + +if (! eval "require LWP::UserAgent;") +{ + $ret = "LWP::UserAgent not found"; +} + + +# CHANGE ME +my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://www.url.to/forums/extern.php?action=online"; + + +# Should not be longer... +my $timeout = 5; + +my $type = undef; + +if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) +{ + if ($ret) + { + print "no ($ret)\n"; + exit 1; + } + +} + +if ( defined $ARGV[0] and $ARGV[0] eq "config" ) +{ + print "graph_title Users\n"; + print "graph_args --base 1000\n"; + print "graph_vlabel current users\n"; + print "graph_category Forums\n"; + print "graph_total Total\n"; + + print "members.label Members\n"; + print "members.draw AREA\n"; + print "guests.draw STACK\n"; + print "guests.label Guests\n"; + + + + exit 0; +} + + +my $ua = LWP::UserAgent->new(timeout => $timeout); + my $url = sprintf $URL; +my $response = $ua->request(HTTP::Request->new('GET', $url)); + +# Example output : Guests online: 92
Registered users online: 2
+ if ($response->content =~ /Guests online: (\d+)
Registered users online: (\d+)
/im) + { + print "members.value $2\n"; + print "guests.value $1\n"; + + } else + { + print $response->content."\n"; + print "members.value U\n"; + print "guests.value U\n"; + + } + + +# vim:syntax=perl