Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: Perl | Size: 0.80 KB | Hits: 24 | Expires: Never
Copy text to clipboard
  1. #!/usr/bin/perl
  2.  
  3. #processes to monitor
  4. %procs = (
  5.     "urbanterror","start_server_ut",
  6.     "bloodfrontier","bfserver_linux",
  7.     "assaultcube","start_server_acube",
  8.     "teeworlds","teeworlds_srv",
  9.     "smokinguns","start_server_sg",
  10.     "worldofpadman","start_server_wop"
  11.     );
  12. $status = "lxgc.shackhost.net status:";
  13.  
  14. #Check monitored processes
  15. foreach $game (sort keys %procs)
  16. {
  17.     $counter++;
  18.     $proc_list = `ps ax`; #Not getting this each loop will cause $proc_list to get mangled by the regex
  19.     if ($proc_list =~ m/.*$procs{$game}.*/g)
  20.     {
  21.         $status = $status . " $game(ON)";
  22.         #print "$game is running($procs{$game})\n";
  23.     }
  24.     else
  25.     {
  26.         $status = $status . " $game(OFF)";
  27.         #print "$game is not running($procs{$game})\n";
  28.     }
  29. }
  30. print "$status";