The following code uses Stingray's Control API to retrieve a list of connections recently handled by the traffic manager. It then prints some information about the connections to a particular node.
#!/usr/bin/perl -w
use SOAP::Lite;
# This is the url of the Stingray admin server
# Edit this to match your own settings
my $admin_server = 'https://admin:[email protected]:9090';
BEGIN {
package MyDeserializer;
@MyDeserializer::ISA = 'SOAP:
eserializer';
sub typecast {
my( $self, $val, $name, $attrs, $children, $type ) = @_;
if( $type && $type =~ [email protected]http://soap.zeus.com/zxtm/@ ) {
return $val;
}
return undef;
};
}
my $conn = SOAP::Lite
-> ns('http://soap.zeus.com/zxtm/1.0/System/Connections/')
-> proxy("$admin_server/soap")
-> deserializer( MyDeserializer->new )
-> on_fault( sub {
my( $conn, $res ) = @_;
die ref $res ? $res->faultstring : $conn->transport->status; } );
my $res = $conn->getAllConnections();
foreach my $c ( @{$res->result} ) {
# Skip connections that did not go to node 192.168.100.219:9090
next unless $c->{to} eq '192.168.100.219:9090';
# Print some information about the connections we are interested in
print "From: $c->{from} via $c->{via} to $c->{to}\n";
}
The '$c' value is a Perl hash; the keys in the hash correspond to the fields in the System.Connections.Connection structure:
struct System.Connections.Connection {
# The source IP address and port for connection.
String from;
# The local IP address and port for connection.
String via;
# The destination node for the connection.
String to;
# The connection state.
System.Connections.ConnectionState state;
# The virtual server handling the request.
String vserver;
# The rule being executed.
String rule;
# The pool being used.
String pool;
# The number of bytes that were received from the client.
Integer bytes_in;
# The number of bytes that were sent to the client.
Integer bytes_out;
# The length of time that the connection has been established, in seconds.
Integer time_est;
# The length of time since receiving the last client data, in seconds.
Integer time_client;
# The length of time since receiving the last server data, in seconds.
Integer time_server;
# The number of times that the connection to the node has been retried.
Integer retries;
# The Service Level Monitoring class being used.
String slm_class;
# The Virtual Server Bandwidth class being used.
String vs_bwclass;
# The Pool Bandwidth class being used.
String pool_bwclass;
# The status code in the HTTP response.
String code;
# The host header/URL in the HTTP request.
String request;
}