From: Andrea R. <ar...@sy...> - 2005-11-23 17:49:00
|
Author: arighi Date: 2005-11-23 14:59:27 -0600 (Wed, 23 Nov 2005) New Revision: 3270 Modified: trunk/sbin/si_monitortk Log: - added the summary of the managed clients in the status bar Modified: trunk/sbin/si_monitortk =================================================================== --- trunk/sbin/si_monitortk 2005-11-22 20:12:02 UTC (rev 3269) +++ trunk/sbin/si_monitortk 2005-11-23 20:59:27 UTC (rev 3270) @@ -227,11 +227,6 @@ # Show the body. display_nodes(); -# Define status bar messages. -$b->attach($tab, - -statusmsg => "Status of the nodes ($database)", -); - # Display command buttons. show_command_buttons(); @@ -422,8 +417,14 @@ # Fill the main list with the status of all nodes. sub display_nodes { + # Statistic counters. + my $num_ok = 0; + my $num_fail = 0; + my $num_inst = 0; + my $num_unkn = 0; + # If database is empty simply quit. - return unless (-s $database); + goto status_bar_update unless (-s $database); # Open and read lock the database. open(LOCK, ">", "$lock_file") or @@ -448,18 +449,23 @@ my $fg; my $status = $client->{$mac}->{'status'} || 0; if (!$status) { + $num_inst++; $status = 'initializing...'; $fg = '#0000FF'; } elsif ($status < 0) { + $num_fail++; $status = 'error!'; $fg = '#FF0000'; } elsif ($status == 100) { + $num_ok++; $status = 'done'; $fg = '#009000'; } elsif (($status > 0) && ($status < 100)) { + $num_inst++; $status = sprintf('%.2f%%', $status); $fg = '#000000'; } else { + $num_unkn++; $status = '???'; $fg = 'darkgrey'; } @@ -523,6 +529,12 @@ } } } + # Update the status bar. +status_bar_update: + $b->attach($tab, + -statusmsg => "Managed nodes: " . ($num_ok + $num_inst + $num_unkn + $num_fail) . + " ($num_ok ok, $num_inst installing, $num_unkn unknown, $num_fail error)", + ); } # Usage: |