#!/usr/bin/perl
# Wed Sep 12 18:04:43 CEST 2007
# Plugin for flash media server
# By Johan MATHE
# GPLv2 Licence
use LWP::UserAgent;
use LWP::Simple;
my $login = "admin";
my $mdp = "my_mdp";
my $host = "http://localhost";
my $port = 1111;

my $ua = LWP::UserAgent->new(timeout => 30);
my $url = sprintf("%s:%d/admin/getServerStats?auser=%s\&apswd=%s", 
$host, $port, $login, $mdp);


if ( defined $ARGV[0] and $ARGV[0] eq "config" )
{
        print "graph_title Flash media server \n";
        print "graph_vlabel cxions number\n";
        print "graph_category Flash\n";
        print "fmserv_c.label Connexions\n";
        print "fmserv_c.type GAUGE\n";
        print "fmserv_c.max 150\n";
        print "fmserv_c.min 0\n";

        exit 0;
}

my $response = $ua->request(HTTP::Request->new('GET',$url));


if($response->content =~ /<connected>+(.+)\<\/connected\>$/im)
{
                print "fmserv_c.value $1\n";
                } else {
                print "fmserv_c.value U\n";
                }


# vim:syntax=perl


