[ILUG] setiathome

From: Ger Gorman (gormo at domain epona.physics.ucg.ie)
Date: Tue 25 May 1999 - 17:34:12 IST


 I don't know if anyone else was having a problem with setiathome running
  in the background.....I have a pretty small machine...166Mhz with 32M ram
 so there was a bit too much swapping with X going on (it was starting to get
  to me...ya even with nice 20).
 
  So I wrote this little script....more as an exercise in PERL than anything
  else. So I've appended it to the end of this and someone might find it usefull
  and/or make a cooler version of it and remail it.....
 
  ps....I run it as a cron job every 5 mins...
 
  cheers
  g
 
  --------------------------------------------

 
 
 #!/usr/bin/perl
 #Script is to check to see if seti at home is running. if so{
 #checks to see if I have been idle for more than 5 mins.
 #If I have it restarts seti....if I haven't it suspends it
 
 
 #first get the pid of setiathome
 
 $seti_ps = `ps auwx|grep "[s]etiathome"`;
  at domain seti_pid = split(" ",$seti_ps);
 $pid = at domain seti_pid[1];
 
 # Now provided that seto is running, do all the other stuff....
 if($pid =~ /\d+/){
   # Now see if I have been more than 5 mins idle. I'm only looking for
   # me as I don't care about anyone else who logs onto my machine!.
    at domain finger_report = split("\n",`finger|grep gormo`);
   
   $gone_for_coffee = 1;
   $slaving_away = 0;
   foreach $finger_report ( at domain finger_report){
     
      at domain finger_fields = split(" ",$finger_report);
     $idle = at domain finger_fields[3];
     #ok....it's not too pretty but it works!
     if($idle =~ /:/ ){
       next;
     }elsif( $idle =~ /d$/ ){
       next;
     }elsif( !($idle =~ /\d/ ) ){
       $gone_for_coffee = 0;
       $slaving_away = 1;
       last;
     }elsif( at domain finger_fields[3] < 5 ){
       $gone_for_coffee = 0;
       $slaving_away = 1;
       last;
     }
   }
   #if I am at work make sure that setiathome is put to bed.
   if($slaving_away == 1){
     $kill_report = `kill -SIGSTOP $pid`;
   }elsif($gone_for_coffee == 1){
      at domain load_av = split(" ",`uptime`);
     if( at domain load_av[8] < 50.0){
       #if the processor is mostly idle then set seti going again.
       $kill_report = `kill -SIGCONT $pid`;
     }
   }
 
 }
 



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:14 GMT