This Perl script uses Stingray's diagnoseSystem() SOAP method to read Stingray's internal diagnosis report and display the results.
For information, Stingray's status applet scans similar information to determine the state of the cluster (green - OK, orange - WARNING, red - FAILURE). The status applet queries the health of the various systems in Stingray and choses the color based on the most serious warning or error state (INFO, WARN, SERIOUS).
#!/usr/bin/perl -w
use SOAP::Lite 0.6;
use Data:
umper;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
# Provide our own Deserializer so to deserialize enums correctly
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;
};
}
# This is the url of the Stingray admin server (FIXME)
my $admin_server = 'https://admin:[email protected]:9090';
my $conn = SOAP::Lite
-> ns('http://soap.zeus.com/zxtm/1.0/Diagnose/')
-> proxy("$admin_server/soap")
-> deserializer( MyDeserializer->new )
-> on_fault( sub {
my( $conn, $res ) = @_;
die ref $res ? $res->faultstring : $conn->transport->status; } );
$conn->proxy->ssl_opts( SSL_verify_mode => 0 );
$res = $conn->diagnoseSystem();
my $diag = $res->result;
# NotReachableTrafficManagers
if( @{$diag->{NotReachableTrafficManagers}} ) {
print "The following traffic managers were not reachable:\n";
foreach my $te ( @{$diag->{NotReachableTrafficManagers}} ) {
print " $te\n";
}
} else {
print "All traffic managers were reachable\n";
}
print "\n";
# ConfigErrors
if( @{$diag->{ConfigErrors}} ) {
print "The following configuration files reported errors:\n";
foreach my $ce ( @{$diag->{ConfigErrors}} ) {
print " $ce->{filename}:$ce->{ConfigKey}:$ce->{severity}: $ce->{description}\n";
}
} else {
print "Configuration is OK\n";
}
print "\n";
# FlipperErrors
if( @{$diag->{FlipperErrors}} ) {
print "The following fault tolerance errors were reported:\n";
foreach my $fe ( @{$diag->{FlipperErrors}} ) {
print " $fe->{machine} ($fe->{IPAddress}:\n";
foreach my $ae ( @{$fe->{errors}}) {
print " $ae->{error} (reported $ae->{age} seconds ago)\n";
}
}
} else {
print "Fault tolerance state is OK\n";
}
print "\n";
# FailedNodes
if( @{$diag->{FailedNodes}} ) {
print "The following nodes have errors:\n";
foreach my $fe ( @{$diag->{FailedNodes}} ) {
print " $fe->{node} ($fe->{IpAddress}:$fe->{port}):\n";
print " $fe->{ErrorMessage}\n";
print " Failed $fe->{NoResponseFor} seconds ago, last tested $fe->{NoRequestsFor} seconds ago\n";
}
} else {
print "All nodes are OK\n";
}
print "\n";
# SystemStatuses
if( @{$diag->{SystemStatuses}} ) {
print "The following hardware issues were reported:\n";
foreach my $se ( @{$diag->{SystemStatuses}} ) {
print " $se->{component}: $se->{severity}: $se->{message}\n";
}
} else {
print "No other problems were detected\n";
}
print "\n";