Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/bin/perl
@results = `ps -ef | grep jobd`;
@testJobs = ("aua_prod","aua_dev","alf_prod","alf_dev","bsc_prod","bsc_dev","cer_prod","cer_dev","cng_prod","cng_dev","can_prod","can_dev","del_prod","del_dev","eri_prod","eri_dev","fin_prod","fin_dev","fre_prod","fre_dev","gen_prod","gen_dev","gcc_prod","gcc_dev","jam_prod","jam_dev","jef_prod","jef_dev","mon_prod","mon_dev","one_prod","one_dev","pot_prod","pot_dev","pur_prod","pur_dev","rcc_prod","rcc_dev","sth_prod","sth_dev","sul_prod","sul_dev","uls_prod","uls_dev","exl_dev")
@stopJobs;
foreach $item (@results) {
@runningJobs;
$job = substr($item,-9,9);
$job =~ s/^\s+(.*?)\s+$/$1/;
$job =~ s/\s//g;
push(@runningJobs,$job);
&checkJobs(@runningJobs);
}
sub checkJobs(@rJobs) {
$flag = false;
for($i = 0; $i < $#testJobs; $i++; ) {
for($j = 0; $j < $#rJobs; $j++; ) {
#foreach $tJob (@testJobs){
#foreach $rJob ( @rJobs) {
if($testJobs[$i] == $rJobs[$j]) {
$flag = true;
}#if
}#for
if ($flag != true) {
push(@stoppedJobs, $testJobs[$i]);
}
}#for
}#checkJobs()
#print "@stoppedJobs \n";
syntax error at detectJobs.pl line 5, near "$item ("
syntax error at detectJobs.pl line 13, near "}"
[\code]
#!/bin/perl
@results = `ps -ef | grep jobd`;
@testJobs = ("aua_prod","aua_dev","alf_prod","alf_dev","bsc_prod","bsc_dev","cer_prod","cer_dev","cng_prod","cng_dev","can_prod","can_dev","del_prod","del_dev","eri_prod","eri_dev","fin_prod","fin_dev","fre_prod","fre_dev","gen_prod","gen_dev","gcc_prod","gcc_dev","jam_prod","jam_dev","jef_prod","jef_dev","mon_prod","mon_dev","one_prod","one_dev","pot_prod","pot_dev","pur_prod","pur_dev","rcc_prod","rcc_dev","sth_prod","sth_dev","sul_prod","sul_dev","uls_prod","uls_dev","exl_dev")
[COLOR=red]foreach $item (@results) {[/color]
@runningJobs;
$job = substr($item,-9,9);
$job =~ s/^\s+(.*?)\s+$/$1/;
$job =~ s/\s//g;
push(@runningJobs,$job);
&checkJobs(@runningJobs);
print "@stoppedJobs \n" ;
[COLOR=red]}[/color]
sub checkJobs(@rJobs) {
foreach $job (@testJobs){
unless( grep /$job/, @rJobs ){
push @stoppedJobs, $job;
}
}
}
#!/bin/perl
@results = `ps -ef | grep jobd`;
@testJobs = ("aua_prod","aua_dev","alf_prod","alf_dev","bsc_prod","bsc_dev","cer_prod","cer_dev","cng_prod","cng_dev","can_prod",
"can_dev","del_prod","del_dev","eri_prod","eri_dev","fin_prod","fin_dev","fre_prod","fre_dev","gen_prod","gen_dev",
"gcc_prod","gcc_dev","jam_prod","jam_dev","jef_prod","jef_dev","mon_prod","mon_dev","one_prod","one_dev","pot_prod",
"pot_dev","pur_prod","pur_dev","rcc_prod","rcc_dev","sth_prod","sth_dev","sul_prod","sul_dev","uls_prod","uls_dev",
"exl_dev")
#would probably be best to read these jobs from an external file, so it can be updated by an external interface
foreach $item (@results) {
@runningJobs; #what are you doing here, redeclaring an array?
$job = substr($item,-9,9); #the substr will be quicker than split
$job =~ s/^\s+(.*?)\s+$/$1/; #
$job =~ s/\s//g; #
push(@runningJobs,$job); #
&checkJobs(@runningJobs);
}
sub checkJobs(@rJobs) {
$flag = false;
foreach $job (@rJobs) {
foreach $tjob (@testJobs) {
if ($tjob eq $job) {
push (@stoppedJobs, $job);
}
}
}
}
#!/usr/local/bin/perl
@results = `ps -ef | grep jobd`;
@testJobs = ("aua_prod","aua_dev","alf_prod","alf_dev","bsc_prod","bsc_dev","cer_prod","cer_dev","cng_prod","cng_dev","can_prod",
"can_dev","del_prod","del_dev","eri_prod","eri_dev","fin_prod","fin_dev","fre_prod","fre_dev","gen_prod","gen_dev",
"gcc_prod","gcc_dev","jam_prod","jam_dev","jef_prod","jef_dev","mon_prod","mon_dev","one_prod","one_dev","pot_prod",
"pot_dev","pur_prod","pur_dev","rcc_prod","rcc_dev","sth_prod","sth_dev","sul_prod","sul_dev","uls_prod","uls_dev",
"exl_dev","ksb_dev");
#would probably be best to read these jobs from an external file, so it can be updated by an external interface
@stoppedJobs = ();
@runningJobs = ();
$mailprogram = "/bin/mailx";
$sendto = "ksbrace@hotmail.com";
$from = "detectJobs.pl_script";
$subject = "Jobs are not running";
foreach $item (@results) {
$job = substr($item,-9,9); #the substr will be quicker than split
$job =~ s/^\s+(.*?)\s+$/$1/; #
$job =~ s/\s//g; #
push(@runningJobs,$job); #
}
&checkJobs(@runningJobs);
$numStoppedJobs = @stoppedJobs;
if(numStoppedJobs > 0 ) {
sendMail();
print "@stoppedJobs \n";
sub checkJobs{
my (@rJobs) = @_;
foreach $job (@testJobs){
unless( grep /$job/, @rJobs ){
push @stoppedJobs, $job;
}
}
}
sub sendMail(){
#-t option takes the headersfrom the lines following the mail
#command -oi options prevent a period at the beginning of a line
# from meaning end of input.
open(MAIL, "|$mailprogram -t -oi") || die "Can't open mail program: $!\n";
print MAIL "To: $sendto\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
The following are jobs that didn't start:
@stoppedJobs;
EOF
close MAIL;
}
#!/usr/local/bin/perl
@results = `ps -ef | grep jobd`;
@testJobs = ("aua_prod","aua_dev","alf_prod","alf_dev","bsc_prod","bsc_dev","cer_prod","cer_dev","cng_prod","cng_dev","can_prod",
"can_dev","del_prod","del_dev","eri_prod","eri_dev","fin_prod","fin_dev","fre_prod","fre_dev","gen_prod","gen_dev",
"gcc_prod","gcc_dev","jam_prod","jam_dev","jef_prod","jef_dev","mon_prod","mon_dev","one_prod","one_dev","pot_prod",
"pot_dev","pur_prod","pur_dev","rcc_prod","rcc_dev","sth_prod","sth_dev","sul_prod","sul_dev","uls_prod","uls_dev",
"exl_dev","ksb_dev");
#would probably be best to read these jobs from an external file, so it can be updated by an external interface
@stoppedJobs = ();
@runningJobs = ();
$mailprogram = "/bin/mailx";
$sendto = "ksbrace@hotmail.com";
$from = "detectJobs.pl_script";
$subject = "Jobs are not running";
foreach $item (@results) {
$job = substr($item,-9,9); #the substr will be quicker than split
$job =~ s/^\s+(.*?)\s+$/$1/; #
$job =~ s/\s//g; #
push(@runningJobs,$job); #
}
&checkJobs(@runningJobs);
$numStoppedJobs = @stoppedJobs;
if(numStoppedJobs > 0 ) {
sendMail();
print "@stoppedJobs \n";
} #add this bracket
sub checkJobs{
my (@rJobs) = @_;
foreach $job (@testJobs){
unless( grep /$job/, @rJobs ){
push @stoppedJobs, $job;
}
}
}
sub sendMail() {
#-t option takes the headersfrom the lines following the mail
#command -oi options prevent a period at the beginning of a line
# from meaning end of input.
open(MAIL, "|$mailprogram -t -oi") || die "Can't open mail program: $!\n";
print MAIL "To: $sendto\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL <<"EOF"; #use this one
# print MAIL <<EOF; #start a "here document"
The following are jobs that didn't start:
@stoppedJobs;
EOF
close MAIL;
}
print MAIL <<"EOF";
#!/usr/local/bin/perl
@results = `ps -ef | grep jobd`;
@testJobs = ("aua_prod","aua_dev","alf_prod","alf_dev","bsc_prod","bsc_dev","cer_prod","cer_dev","cng_prod","cng_dev","can_prod",
"can_dev","del_prod","del_dev","eri_prod","eri_dev","fin_prod","fin_dev","fre_prod","fre_dev","gen_prod","gen_dev",
"gcc_prod","gcc_dev","jam_prod","jam_dev","jef_prod","jef_dev","mon_prod","mon_dev","one_prod","one_dev","pot_prod",
"pot_dev","pur_prod","pur_dev","rcc_prod","rcc_dev","sth_prod","sth_dev","sul_prod","sul_dev","uls_prod","uls_dev",
"exl_dev","ksb_dev");
#would probably be best to read these jobs from an external file, so it can be updated by an external interface
@stoppedJobs = ();
@runningJobs = ();
$mailprogram = "/usr/lib/sendmail";
$sendto = "kelly.brace@itec.mail.suny.edu";
$from = "kelly.brace@itec.mail.suny.edu";
$subject = "Jobs are not running";
foreach $item (@results) {
$job = substr($item,-9,9); #the substr will be quicker than split
$job =~ s/^\s+(.*?)\s+$/$1/; #
$job =~ s/\s//g; #
push(@runningJobs,$job); #
}
&checkJobs(@runningJobs);
$numStoppedJobs = @stoppedJobs;
if($numStoppedJobs > 0 ) {
sendMail();
print "sent mail";
}
print "@stoppedJobs \n";
sub checkJobs{
my (@rJobs) = @_;
foreach $job (@testJobs){
unless( grep /$job/, @rJobs ){
push @stoppedJobs, $job;
}
}
}
sub sendMail(){
#-t option takes the headers from the lines following the mail
#command -oi options prevent a period at the beginning of a line
# from meaning end of input.
open(MAIL, "|$mailprogram -t -oi") || die "Can't open mail program: $!\n";
print MAIL "To: $sendto\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL <<EOF;
"The following are jobs that didn't start:
@stoppedJobs;
EOF
close(MAIL);
}