[OCI] Check Jobs DBCli
![[OCI] Check Jobs DBCli](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F4007e787-d6ad-47d9-b238-d69a285383ab.png&w=3840&q=75)
Ingeniero informático, Oracle ACE, DBA y Arquitecto OCI, con más de 15 años de experiencia en plataformas Oracle. Certificado en OCI Certified Architect Professional y OCI Migration and Integration Certified Professional.
If you prefer to read in Spanish Spanish version.
Today, let's see a little script in order to see quickly monitor jobs running into Oracle Database Cloud.
Below, you can see the output our sh:
At the top, let's see information about our machine such as host*,* IP*,* shape and timezone.
After that, let's see a summary showing the number of the jobs executed on our machine, including Success, Failure and Others.
In case we have failed jobs, we can see a summary of every job. The structure is as follows:
Name of the execute job, including its progress and number of threads into the job with a failed status.
Code and description of the error.
List of task failed.
Here's our scripts:
#!/bin/bash
JOB_NUM=`dbcli list-jobs -j | jq 'length'`
JOB_OK=`dbcli list-jobs -j | jq '[.[] | select(.status=="Success")] | length'`
JOB_KO=`dbcli list-jobs -j | jq '[.[] | select(.status=="Failure")] | length'`
JOB_UNKOWN=$((JOB_NUM - JOB_OK - JOB_KO))
get_Info(){
curl -s -H "Authorization: Bearer Oracle" http://169.254.169.254/opc/v2/instance/metadata/$1
}
get_Extracc_Info_Job(){
dbcli describe-job -i "\(1" -l Verbose | grep "\)2" | sed "s/.*$2:[[:space:]]*//"
}
get_Count_Task_Job(){
dbcli describe-job -i \(1 -l Verbose | awk '/Task Name/{flag=1; next} flag' | awk '{print \)NF}' | grep \(2 | sort | uniq -c | awk '{print \)1}'
}
design_report(){
for ((i=0; i<$1; i++)); do
printf $2
done
}
design_report 100 '+'
printf '\n'
printf '\n'
echo "Check Jobs in "`hostname`" ("\((get_Info privateIP0)") - Shape "\)(get_Info dbSystemShape)" - Timezone "$(get_Info timeZone)
printf '\n'
design_report 59 '-'
printf '\n'
echo "| ⏰ Jobs ("\({JOB_NUM}") ✅ Success "\){JOB_OK}" ❌ Failure "\({JOB_KO}" ◉ Others "\){JOB_UNKOWN}" |"
design_report 59 '-'
printf '\n'
printf '\n'
if [ "${JOB_KO}" -ne 0 ]; then
echo "Detail Jobs Failure"
design_report 25 '-'
printf '\n'
i=0;
dbcli list-jobs | grep Failure | awk '{print $1}' | while read -r linea; do
((i++))
percent=\((get_Extracc_Info_Job \){linea} "Progress")
if [ "$percent" != "NA" ]; then
percent_n=${percent%\%}
if [ "\(percent_n" -ge 1 ] && [ "\)percent_n" -le 25 ]; then
percent="◔ "${percent}
fi
if [ "\(percent_n" -ge 26 ] && [ "\)percent_n" -le 50 ]; then
percent="◑ "${percent}
fi
if [ "\(percent_n" -ge 51 ] && [ "\)percent_n" -le 100 ]; then
percent="◕ "${percent}
fi
design_report 3 '·' | sed "s/.*'·':[[:space:]]*//" | tr '·' ' '
echo \({i}") "\)(get_Extracc_Info_Job \({linea} "Description")" ("\){percent}") ✖ Failure (" \((get_Count_Task_Job \){linea} "Failure") ")"
design_report 5 '·' | sed "s/.*'·':[[:space:]]*//" | tr '·' ' '
echo \((get_Extracc_Info_Job \){linea} "Message")
design_report 5 '·' | sed "s/.*'·':[[:space:]]*//" | tr '·' ' '
echo "List Task Failure"
dbcli describe-job -i ${linea} -l Verbose | awk '/Task Name/{flag=1; next} flag' | grep "Failure" | cut -c1-60 | while read -r linea; do
design_report 6 '·' | sed "s/.*'·':[[:space:]]*//" | tr '·' ' '
echo "·"${linea}
done
fi
done
``
fi
design_report 100 '+'
printf '\n'
Here's the download link:
https://github.com/dbaenlasombra/OCI/blob/main/oci_dbcli_info.sh
Looking forward to seeing you in the next article :)
![[26ai] JOIN_TO_ME](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F49867547-f920-47a6-b11f-f5db511bcc73.png&w=3840&q=75)
![[26ai] Cleanup of Obsolete PL/SQL Objects](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F64ada612-0048-411c-b9df-61b8825af6e7.png&w=3840&q=75)
![[26ai] Hybrid Read-Only Mode PDB](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F23e8f92e-f89b-4746-930e-98156e3a1ec4.png&w=3840&q=75)
![[26ai] ALERT_LOG_MAX_SIZE](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2Fdad5c53e-425c-4e82-9bbb-e0ccec6e9a4e.jpg&w=3840&q=75)