I am trying to setup a bash script within which a connection to an Oracle instance to check the various dba jobs scheduled and if a specific job is not running i need to display an error message.
Here is the script i have written and it works partially, the script works only until it reaches the IF statement
enter code here
#!/usr/bin/env bash enter code here
#write output of the sql query to an output file enter code here
output_file="/tmp/datatool_output.csv" enter code here
> $output_file
enter code here
echo " enter code here
SET FEED OFF enter code here
SET PAGESIZE 0 enter code here
SET COLSEP , enter code here
SET linesize 100 enter code here
SET TRIMSPOOL ON enter code here
SET TRIMOUT ON
enter code here
SELECT JOB_NAME, STATE FROM DBA_SCHEDULER_JOBS where job_name ='run_LoadDatatoolStore';
enter code here
exit" | sqlplus -s sqlplus -s "username/password@dbip:dbport/SID" >> $output_file
`enter code here`a_var=($(awk -F',' '{print $2}' $output_file | sed 's/\s//g' | xargs))
enter code here
for item in ${a_var[@]} enter code here
do enter code here
val=$(echo $item | awk -F',' '{print $1}')
enter code here
if [[ $val -eq "SCHEDULED" ]] || [[ $val -eq "RUNNING" ]] ; then enter code here
echo "OK: The job LoadDatatool is either Scheduled or in the Running state" enter code here
exit 0 # this is used for interpretation by nagios to display no alert alert enter code here
else [[ $val -eq "BLOCKED" ]] enter code here
echo "CRITICAL: The Db scheduler job LoadDatatool is in a Blocked state" enter code here
exit 2 enter code here
fi
I get test.sh: line 24: syntax error: unexpected end of file when i run the script Any help figuring this out is appreciated.
Thanks, Karthik
Aucun commentaire:
Enregistrer un commentaire