Révision 6f6a48ff
Initial version
| plugins/other/vbulletin_users | ||
|---|---|---|
| 1 |
#!/usr/bin/perl |
|
| 2 |
# |
|
| 3 |
# Plugin to monitor the number of guests/users on a vbulletin forum |
|
| 4 |
# Since we are using a regexp, this will work for EN forum only... adapt the regexp if your forum is not using that language. |
|
| 5 |
# visual-regexp is a great help for tuning the regexp (package exists on Debian and Ubuntu repositories) |
|
| 6 |
# |
|
| 7 |
# |
|
| 8 |
# Parameters supported: |
|
| 9 |
# |
|
| 10 |
# config |
|
| 11 |
# autoconf |
|
| 12 |
# |
|
| 13 |
# Configurable variables |
|
| 14 |
# |
|
| 15 |
# url to online.php, this page is part of vbulletin distribution, pp=1 so the page is fast to load and doesn't give us too many unwanted info |
|
| 16 |
# |
|
| 17 |
# $Log$ |
|
| 18 |
# |
|
| 19 |
# |
|
| 20 |
# Not sure about those lines... |
|
| 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 |
# CHANGE ME |
|
| 34 |
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://www.url.to/forums/online.php?pp=1";
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
# We will use this variable, not on this release ;-) |
|
| 38 |
my $forum_type = exists $ENV{'type'} ? $ENV{'type'} : "vbulletin";
|
|
| 39 |
|
|
| 40 |
# same here |
|
| 41 |
my %regexp = ("vbulletin"=> "<strong\>(\d+)[^\d]+(\d+)\sguests\</strong>",
|
|
| 42 |
"punbb" => "", |
|
| 43 |
"phpbb" => ""); |
|
| 44 |
|
|
| 45 |
my $type = undef; |
|
| 46 |
my $timoeout = 30; |
|
| 47 |
|
|
| 48 |
if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) |
|
| 49 |
{
|
|
| 50 |
if ($ret) |
|
| 51 |
{
|
|
| 52 |
print "no ($ret)\n"; |
|
| 53 |
exit 1; |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
} |
|
| 57 |
|
|
| 58 |
if ( defined $ARGV[0] and $ARGV[0] eq "config" ) |
|
| 59 |
{
|
|
| 60 |
print "graph_title Forum Users\n"; |
|
| 61 |
print "graph_args -l 0\n"; |
|
| 62 |
print "graph_vlabel current users\n"; |
|
| 63 |
print "graph_category Forum\n"; |
|
| 64 |
print "graph_total Total\n"; |
|
| 65 |
|
|
| 66 |
print "members.label Members\n"; |
|
| 67 |
print "members.draw AREA\n"; |
|
| 68 |
print "guests.draw STACK\n"; |
|
| 69 |
print "guests.label Guests\n"; |
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
exit 0; |
|
| 74 |
} |
|
| 75 |
|
|
| 76 |
|
|
| 77 |
my $ua = LWP::UserAgent->new(timeout => $timeout); |
|
| 78 |
my $url = sprintf $URL; |
|
| 79 |
my $response = $ua->request(HTTP::Request->new('GET',$url));
|
|
| 80 |
|
|
| 81 |
# part of the output we want to catch : <strong>42 members and 420 guests</strong> --> 42 - 420 |
|
| 82 |
if ($response->content =~ /<strong>(\d+)\smembers[^\d]+(\d+)\sguests<\/strong>/im) |
|
| 83 |
{
|
|
| 84 |
|
|
| 85 |
print "members.value $1\n"; |
|
| 86 |
print "guests.value $2\n"; |
|
| 87 |
|
|
| 88 |
} else {
|
|
| 89 |
print "members.value U\n"; |
|
| 90 |
print "guests.value U\n"; |
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
|
|
| 94 |
# vim:syntax=perl |
|
Formats disponibles : Unified diff