# Go through the database, and grab the name and state of each service
# running on this host.
- opendir( DIR, "$main::SPONGDB/$host/services" );
- while( defined( $_ = readdir( DIR ) ) ) {
- next unless /^(.*)-(green|yellow|red)$/ ;
- my( $name, $color ) = ($1, $2);
+ if ( ! $main::SERVICELISTFIX ) {
+ opendir( DIR, "$main::SPONGDB/$host/services" );
+ while( defined( $_ = readdir( DIR ) ) ) {
+ next unless /^(.*)-(green|yellow|red)$/ ;
+ my( $name, $color ) = ($1, $2);
+
+ # A hack to get around a local problem.
+ if( $name eq "procs" ) { $name = "jobs"; }
+
+ $got_one = 1;
+ my( $rtime ) = (stat( "$main::SPONGDB/$host/services/$_" ))[9];
+ my $service = Spong::Service->new( $host, $name );
+
+ $service->rtime( $rtime );
+ if( $rtime < ( time() - (3 * $main::SPONGSLEEP) ) ) {
+ $service->rcolor( $color ); $service->color( "purple" );
+ } else {
+ $service->rcolor( $color ); $service->color( $color );
+ }
+ $service_hash{$name} = $service;
+ }
+ closedir( DIR );
+ } else {
+ my @files = ();
+ {
+ local $SIG{'CHLD'} = 'IGNORE';
+ eval { @files = `cd $main::SPONGDB/$host/services/; ls *`; };
+ }
+ foreach ( @files ) {
+ chomp;
+ next unless /^(.*)-(green|yellow|red)$/ ;
+ my( $name, $color ) = ($1, $2);
- # A hack to get around a local problem.
- if( $name eq "procs" ) { $name = "jobs"; }
+ # A hack to get around a local problem.
+ if( $name eq "procs" ) { $name = "jobs"; }
- $got_one = 1;
- my( $rtime ) = (stat( "$main::SPONGDB/$host/services/$_" ))[9];
- my $service = Spong::Service->new( $host, $name );
+ $got_one = 1;
+ my( $rtime ) = (stat( "$main::SPONGDB/$host/services/$_" ))[9];
+ my $service = Spong::Service->new( $host, $name );
- $service->rtime( $rtime );
- if( $rtime < ( time() - (3 * $main::SPONGSLEEP) ) ) {
- $service->rcolor( $color ); $service->color( "purple" );
- } else {
- $service->rcolor( $color ); $service->color( $color );
+ $service->rtime( $rtime );
+ if( $rtime < ( time() - (3 * $main::SPONGSLEEP) ) ) {
+ $service->rcolor( $color ); $service->color( "purple" );
+ } else {
+ $service->rcolor( $color ); $service->color( $color );
+ }
+ $service_hash{$name} = $service;
}
- $service_hash{$name} = $service;
}
- closedir( DIR );
return undef unless $got_one;