Révision 01f45be5
Initial version
| plugins/other/punbb_users | ||
|---|---|---|
| 1 |
#!/usr/bin/perl |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor the number of users on a punbb forum |
|
| 4 |
# |
|
| 5 |
# Requirements: |
|
| 6 |
# - Needs access to the forum |
|
| 7 |
# |
|
| 8 |
# Parameters supported: |
|
| 9 |
# |
|
| 10 |
# config |
|
| 11 |
# autoconf |
|
| 12 |
# |
|
| 13 |
# Configurable variables |
|
| 14 |
# |
|
| 15 |
# url to extern.php |
|
| 16 |
# |
|
| 17 |
# |
|
| 18 |
# $Log$ |
|
| 19 |
# |
|
| 20 |
# |
|
| 21 |
# |
|
| 22 |
# Magic markers: |
|
| 23 |
#%# family=auto |
|
| 24 |
#%# capabilities=autoconf |
|
| 25 |
|
|
| 26 |
my $ret = undef; |
|
| 27 |
|
|
| 28 |
if (! eval "require LWP::UserAgent;") |
|
| 29 |
{
|
|
| 30 |
$ret = "LWP::UserAgent not found"; |
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
|
|
| 34 |
# CHANGE ME |
|
| 35 |
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://www.url.to/forums/extern.php?action=online";
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
# Should not be longer... |
|
| 39 |
my $timeout = 5; |
|
| 40 |
|
|
| 41 |
my $type = undef; |
|
| 42 |
|
|
| 43 |
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) |
|
| 44 |
{
|
|
| 45 |
if ($ret) |
|
| 46 |
{
|
|
| 47 |
print "no ($ret)\n"; |
|
| 48 |
exit 1; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
if ( defined $ARGV[0] and $ARGV[0] eq "config" ) |
|
| 54 |
{
|
|
| 55 |
print "graph_title Users\n"; |
|
| 56 |
print "graph_args --base 1000\n"; |
|
| 57 |
print "graph_vlabel current users\n"; |
|
| 58 |
print "graph_category Forums\n"; |
|
| 59 |
print "graph_total Total\n"; |
|
| 60 |
|
|
| 61 |
print "members.label Members\n"; |
|
| 62 |
print "members.draw AREA\n"; |
|
| 63 |
print "guests.draw STACK\n"; |
|
| 64 |
print "guests.label Guests\n"; |
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
exit 0; |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
|
|
| 72 |
my $ua = LWP::UserAgent->new(timeout => $timeout); |
|
| 73 |
my $url = sprintf $URL; |
|
| 74 |
my $response = $ua->request(HTTP::Request->new('GET', $url));
|
|
| 75 |
|
|
| 76 |
# Example output : Guests online: 92<br />Registered users online: 2<br /> |
|
| 77 |
if ($response->content =~ /Guests online: (\d+)<br \/>Registered users online: (\d+)<br \/>/im) |
|
| 78 |
{
|
|
| 79 |
print "members.value $2\n"; |
|
| 80 |
print "guests.value $1\n"; |
|
| 81 |
|
|
| 82 |
} else |
|
| 83 |
{
|
|
| 84 |
print $response->content."\n"; |
|
| 85 |
print "members.value U\n"; |
|
| 86 |
print "guests.value U\n"; |
|
| 87 |
|
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
|
|
| 91 |
# vim:syntax=perl |
|
Formats disponibles : Unified diff