2007-06-02 09:40:17 +02:00
|
|
|
#!/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" )
|
|
|
|
{
|
2018-09-16 04:09:21 +02:00
|
|
|
if ($ret) {
|
2007-06-02 09:40:17 +02:00
|
|
|
print "no ($ret)\n";
|
2018-09-16 04:09:21 +02:00
|
|
|
} else {
|
|
|
|
print "yes\n";
|
2007-06-02 09:40:17 +02:00
|
|
|
}
|
2018-09-16 04:09:21 +02:00
|
|
|
exit 0;
|
2007-06-02 09:40:17 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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";
|
2018-08-01 23:56:56 +02:00
|
|
|
print "graph_category forum\n";
|
2007-06-02 09:40:17 +02:00
|
|
|
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<br />Registered users online: 2<br />
|
|
|
|
if ($response->content =~ /Guests online: (\d+)<br \/>Registered users online: (\d+)<br \/>/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
|