This article describes how to gather activity statistics across a cluster of traffic managers using Perl, SOAP::Lite and Stingray's SOAP Control API.
Each local Stingray Traffic Manager tracks a very wide range of activity statistics. These may be exported using SNMP or retrieved using the System/Stats interface in Stingray's SOAP Control API.
When you use the Activity monitoring in Stingray's Administration Interface, a collector process communicates with each of the Traffic Managers in your cluster, gathering the local statistics from each and merging them before plotting them on the activity chart.
'Aggregate data across all traffic managers'
However, when you use the SNMP or Control API interfaces directly, you will only receive the statistics from the Traffic Manager machine you have connected to. If you want to get a cluster-wide view of activity using SNMP or the Control API, you will need to poll each machine and merge the results yourself.
Using Perl and SOAP::Lite to query the traffic managers and merge activity statistics
The following code sample determines the total TCP connection rate across the cluster as follows:
Connect to the named traffic manager and use the getAllClusterMachines() method to retrieve a list of all of the machines in the cluster;
Poll each machine in the cluster for its current value of TotalConn (the total number of TCP connections processed since startup);
Sleep for 10 seconds, then poll each machine again;
Calculate the number of connections processed by each traffic manager in the 10-second window, and calculate the per-second rate accurately using high-res time.
use SOAP::Lite 0.6;
use Time::HiRes qw( time sleep );
my $userpass = "admin:admin"; # SOAP-capable authentication credentials
my $adminserver = "stingray:9090"; # Details of an admin server in the cluster
my $sampletime = 10; # Sample time (seconds)
sub getAllClusterMembers( $$ );
sub makeConnections( $$$ );
sub makeRequest( $$ );
my $machines = getAllClusterMembers( $adminserver, $userpass );