#!/usr/bin/perl # # Plugin to monitor Codian Conferences & Participants # # # (c) 2006 - Laurent FACQ (facq@u-bordeaux.fr) - REAUMUR / Universite de Bordeaux - # $Id: codian2munin,v 1.8 2006/06/09 13:54:03 facq Exp $ # Cf. Codian MCU 4200 Series Management API - 2.0.1.pdf # Cf. http://www.blackperl.com/RPC::XML/README # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use RPC::XML; # debian: apt-get install librpc-xml-perl use RPC::XML::Client; ################################################################################ $host = 'host'; # codian hostname $user= 'admin'; # admin account $ps= 'password'; # password ### TODO : keep track of participant/conference - start/stop ### $log_to_file= "/tmp/visio"; ### $state_file : current participant/conference to simulate start/stop ################################################################################ # config (required) if ($ARGV[0] eq "config") { print "graph_title Conferences & Participants\n"; print "graph_vlabel Number\n"; print "current_conferences.label Current Conf.\n"; print "current_conferences.type GAUGE\n"; print "current_conferences.draw AREA\n"; print "active_conferences.label Active Conf.\n"; print "active_conferences.type GAUGE\n"; print "current_participants.label Current Part.\n"; print "current_participants.type GAUGE\n"; print "current_participants.draw AREA\n"; print "active_participants.label Active Part.\n"; print "active_participants.type GAUGE\n"; exit 0; } if ($log_to_file) { open(LOG,">> $log_to_file"); } $client = RPC::XML::Client->new("http://$host/RPC2"); $id= 0; $ok= 1; $n_current_conference= $n_active_conference= 0; while ($ok) { $req = RPC::XML::request->new('conference.enumerate', RPC::XML::struct->new( 'authenticationUser', $user, 'authenticationPassword',$ps, ($id?('enumerateID', RPC::XML::string->new($id)):'' ) ) ); $resp = $client->send_request($req); if ($resp->is_fault) { $ok= 0; } $id= $resp->value->{enumerateID}; if (!$id) { $ok= 0; } foreach $c ( @{$resp->value->{conferences}} ) { if ($c->{conferenceActive}) { $n_current_conference++; } } } ######"" $id= 0; $ok= 1; $n_current_participant= $n_active_participant= 0; while ($ok) { $req = RPC::XML::request->new('participant.enumerate', RPC::XML::struct->new( 'authenticationUser', $user, 'authenticationPassword',$ps, ($id?('enumerateID', RPC::XML::string->new($id)):'' ) ) ); $resp = $client->send_request($req); if ($resp->is_fault) { $ok= 0; } $id= $resp->value->{enumerateID}; if (!$id) { $ok= 0; } foreach $c ( @{$resp->value->{participants}} ) { if ($c->{callState} eq 'connected') { $n_current_participant++; if ($c->{conferenceName}) { $n_active_participant++; if (!defined($conf{$c->{conferenceName}})) { $conf{$c->{conferenceName}}= 1; $n_current_conference++; } } } } } print "current_conferences.value $n_current_conference\n"; print "active_conferences.value $n_active_conference\n"; print "current_participants.value $n_current_participant\n"; print "active_participants.value $n_active_participant\n";