#!/usr/bin/perl -W # Created by Patrick Webster 20050412 pwebster@aushack.com # # Automatically connects to server, logs in, grabs the session cookie, resends requests with the authCookie, # reiterates through the array to set the group ID for the statistics, does a regex on the results and prints # the value from the source, then prints it out in a typical CGI # # This script was designed to be used with Broadsoft VoIP PABX Software. # At version 13 and below, there was no user friendly method to determine the queue, hence this hack. # # Released under the BSD LICENSE - free as in beer :) # # Version 0.1a - Initial code # Version 0.1b - CGI support # Version 0.1c - Added popup code, and TITLE for Task bar # Version 0.1d - Some minor beauty updates # Version 0.1e - Added a few lines for multiple queues. # Version 0.1f - Added extra queues. I should really read it from the website, but don't have the time. # Version 0.1g - Fixed incorrect content type. Updated code for version 13 compatibility. # Version 0.2a - Cleaned up. print "content-type: text/html\n\n"; use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Headers; use HTTP::Cookies; $cookie_jar = HTTP::Cookies->new( file => '/tmp/lwp_cookies.dat', autosave => 1, ignore_discard => 1, ); $ua = LWP::UserAgent->new; $response = $ua->request(POST 'http://site/servlet/com.broadsoft.clients.oam.servlets.Login', [UserID => "user\@example.com", Password => "mypassword", domain => '']); @Queue = ( "http://site/Group/Call_Center/EditRedirect/index.jsp?key=Credit_Control", "http://site/Group/Call_Center/EditRedirect/index.jsp?key=Customer_Support" ); @QueueName = ( "Credit_Control", "Customer_Support" ); $qC = 0; print "\n\nMy Company\n\n\n
\n\n\n"; foreach $queue(@Queue) { @Array = ("http://site/Common/folder_contents.jsp?menuId=1", $queue, "http://site/User/CCStatistics/"); if ($response->is_success) { #print $response->content; $cookie_jar->extract_cookies($response); my $url; foreach $url(@Array) { $request = HTTP::Request->new(GET => $url); $cookie_jar->add_cookie_header($request); my $response = $ua->request($request); $htmlOutput = $response->content; #print $response->content; } } else { print STDERR $response->status_line, "\n"; } if ($htmlOutput =~ /Number of calls in queue now: \<\/TD\>\n\\([0-9])/m) { $waitingNum = $1; } else { $waitingNum = "error: no response"; } print "$QueueName[$qC]: $waitingNum
\n"; $qC++; } print "
\n\n\n"; # EOF