Repository
Munin (contrib)
Last change
2018-09-16
Graph Categories
Family
auto
Capabilities
Keywords
Language
Perl

punbb_users

Sadly there is no documentation for this plugin.

#!/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";
        } else {
                print "yes\n";
        }
        exit 0;

}

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 forum\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<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