#!/usr/perl5/5.00503/bin/perl ###################################### require "c:\\mevslights2\\subs.pl"; use Tk; # ############################################################################ # Define program switches and command execute locations ############################################################################ @ipaddr = ("shoshone","clark","lewis"); @port = (4500,5500); # 4500=online, 5500=batch $data = "status"; $system = ""; $server = ""; $rc = ""; # MevsLights("shoshone", "4500", "0"); while ( 1 ) { foreach $server (@ipaddr) # do for each of the servers { foreach $system (@port) # do for each portno (online/batch) { #------------------------------------------------------------------------------------- # Test status a maximum of 5 times or until a 'good' status # check return code [$rc] is received. #------------------------------------------------------------------------------------- $rc = 9; # Set return code to non-zero (9) value so the while loop will work $cnt = 0; # Set counter to zero, used to loop max 5 times before sending email while (($rc != 0) && ($cnt <= 5)) { $sock = get_socket($server, $system); # connect to socket if ( $sock eq "ERROR" ) { # connection error $rc = 2; } else { $response = send_request($sock, $data); # send 'status' request if ( $response eq "" ) {$rc = 3;} # no response (timeout) elsif ( $response eq "1" ) {$rc = 1;} # status check failed elsif ( $response eq "0" ) {$rc = 0;} # status check passed else { $rc = $response; } close_socket($sock); # close socket $cnt++; # incr loop count } sleep 5; # sleep for 5 secs $cnt++; # incr loop count } mevslights(); # Turn on the lights } } sleep 5 } ############################################################################ sub mevslights # User configuration default options ############################################################################ { @color = ("green", "yellow", "red", "red"); if ( ! Exists($ml) ) { $login_title = "MEVSTOOL: User Security"; $ml = MainWindow->new; $ml->title(" MEVS Monitor: MevsLights.pl"); get_time(); $c = $ml->Canvas(-relief => 'groove')->pack(-fill => 'both', -expand => 1); # Set the row and column labels for the server (shoshone, lewis, clark) in red, and the system (online, batch)in blue $c->createText(40,68, -text => "shoshone", -anchor => "w", -fill => "dark red", -font => "arial 12 bold"); $c->createText(40,108, -text => "lewis", -anchor => "w", -fill => "dark red", -font => "arial 12 bold"); $c->createText(40,148, -text => "clark", -anchor => "w", -fill => "dark red", -font => "arial 12 bold"); $c->createText(130,30, -text => "Online", -anchor => "w", -fill => "dark blue", -font => "arial 12 bold"); $c->createText(200,30, -text => "Batch", -anchor => "w", -fill => "dark blue", -font => "arial 12 bold"); # Turn on the MEVS Lights turn_on_lights(); # turn lights on } else { turn_on_lights(); # turn lights on } } ########################################################################### ########################################################################### sub turn_on_lights #02/11/2005 11:47AM ########################################################################### { if ( $server eq "shoshone" ) { if ($system eq "4500") { # online $c->createOval(140,58,160,78, -fill => "$color[$rc]", outline => "dark $color[$rc]"); $data[0] = $rc; } else { # batch $c->createOval(210,58,230,78, -fill => "$color[$rc]", outline => "dark $color[$rc]"); $data[1] = $rc; } } elsif ( $server eq "lewis" ) { if ($system eq "4500") { # online $c->createOval(140,98,160,118, -fill => "$color[$rc]", outline => "dark $color[$rc]"); $data[2] = $rc; } else { # batch $c->createOval(210,98,230,118, -fill => "$color[$rc]", outline => "dark $color[$rc]"); $data[3] = $rc; } } elsif ( $server eq "clark" ) { if ($system eq "4500") { # online $c->createOval(140,138,160,158, -fill => "$color[$rc]", outline => "dark $color[$rc]"); $data[4] = $rc; } else { # batch $c->createOval(210,138,230,158, -fill => "$color[$rc]", outline => "dark $color[$rc]"); $data[5] = $rc; } } } ##turn_on_lights ########################################################################### 1;