Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #Variable storage
- core_env=$("DV")
- core_dir1=$(printf "/home/essbase/TWSEssbRuns/9.6.1/server/bin")
- core_dir2=$(printf "/home/essbase/TWSEssbRuns/9.6.1/tomcat/bin")
- #Check core file on the 1st dir
- cd $core_dir1
- core_out_count1=$(find . -maxdepth 1 -type f -name "core.*" -printf "\n" | wc -l) #count on dir1
- core_check1= $(find . -type f -name 'core.*' -exec sh -c '
- for name; do
- if strings "$name" | grep -qF "pmdtm("; then
- printf "%s\n" "$name"
- fi
- done' find-sh {} + | awk '{print $0,"\n"}') #initial check of core files
- core_check2=$(find . -type f -name 'core.*' -exec file {} + | awk '{print $0,"\n"}') #check for the core files if core_check1 returns blank
- if [$core_out_count1!=0];
- if [$core_check1=" "];
- if [$core_check1!=" "];
- then core_msg1=$(echo "$core_out_count2 core files exist in $core_dir2.")
- fi
- fi
- elif core_msg1=$(echo "No core files in $core_dir1.")
- fi
- #Check core file on the 2nd dir
- cd $core_dir2
- core_out_count2=$(find . -maxdepth 1 -type f -name "core.*" -printf "\n" | wc -l) #count on dir2
- core_check1= $(find . -type f -name 'core.*' -exec sh -c '
- for name; do
- if strings "$name" | grep -qF "pmdtm("; then
- printf "%s\n" "$name"
- fi
- done' find-sh {} + | awk '{print $0,"\n"}') #initial check of core files
- core_check2=$(find . -type f -name 'core.*' -exec file {} + | awk '{print $0,"\n"}') #check for the core files if core_check1 returns blank
- if [$core_out_count2!=0];
- if [$core_check1=" "];
- if [$core_check2!=" "];
- then core_msg2=$(echo "$core_out_count2 core files exist in $core_dir2.")
- fi
- fi
- elif core_msg2=$(echo "No core files in $core_dir2.")
- fi
- #Send e-mail to users
- if [$core_out_count1!=0 && $core_check1!=" "]; #core in dir1 exist & 1st check script worked
- then echo "$core_msg1\n\n$core_check1" | mail -s "Core files exist in $core_env" "[email protected],[email protected],[email protected]"
- if [$core_out_count2!=0 && $core_check1!=" "]; #core in dir2 exist & 1st check script worked
- then echo "$core_msg2\n\n$core_check1" | mail -s "Core files exist in $core_env" "[email protected],[email protected],[email protected]"
- if [$core_out_count1!=0 && $core_check2!=" "]; #core in dir1 exist & 1st check script did not worked
- then echo "$core_msg1\n\n$core_check2" | mail -s "Core files exist in $core_env" "[email protected],[email protected],[email protected]"
- if [$core_out_count2!=0 && $core_check2!=" "]; #core in dir2 exist & 1st check script did not worked
- then echo "$core_msg2\n\n$core_check2" | mail -s "Core files exist in $core_env" "[email protected],[email protected],[email protected]"
- fi
- fi
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement