in reply to Tk process monitoring
my $status_check=$w->Button(-text=> 'UP', -fg=>'black', -bg=>'red', -activebackground=>'red', -activeforeground=>'black'); my $status_email=$w->Button(-text=> 'DOWN', -fg=>'black', -bg=>'red', -activebackground=>'red', -activeforeground=>'black'); $w->repeat(500,sub{&status_check}); sub status_check { my @temp=`ps -ef | grep check.pl`; foreach (@temp) { if ($_=~/^kevin\s+\d{4,5}\s+\d{1,5}\s+\d{1,5}\s+\d{2}:\d{2}\s+ +pts\/2\s+\d{2}:\d{2}:\d{2} perl \/home\/Kevin\/Desktop\/ip\/check.pl/ +) {$check=1;} } if (($check)==1) { $status_check->configure(-bg=>'green', -activebackground=>'green', -text=>'UP'); } else { $status_check->configure(-bg=>'red', -activebackground=>'red', -text=>'DOWN'); } my @temp=`ps -ef | grep email.pl`; foreach (@temp) { if ($_=~/^kevin\s+\d{4,5}\s+\d{1,5}\s+\d{1,5}\s+\d{2}:\d{2}\s+ +pts\/2\s+\d{2}:\d{2}:\d{2} perl \/home\/Kevin\/Desktop\/spam\/email.p +l/) {$email=1;} } if (($email)==1) { $status_email->configure(-bg=>'green', -activebackground=>'green', -text=>'UP'); } else { $status_email->configure(-bg=>'red', -activebackground=>'red', -text=>'DOWN'); } undef($email); undef($check); }
|
|---|