Skip to content
Snippets Groups Projects
Commit fb6d04a6 authored by Jörg Sachse's avatar Jörg Sachse
Browse files

fix: make local Oracle CMK checks actually produce useful output (this seems...

fix: make local Oracle CMK checks actually produce useful output (this seems to have been broken from the beginning)
parent 2ef59075
No related branches found
No related tags found
No related merge requests found
Pipeline #2759 failed
...@@ -13,7 +13,7 @@ scriptname=$( basename "${0}" ".sh" ) ...@@ -13,7 +13,7 @@ scriptname=$( basename "${0}" ".sh" )
LOCKFILE="/var/lock/${scriptname}.lock" LOCKFILE="/var/lock/${scriptname}.lock"
status=3 status=3
itemname='oracle_segment_size' itemname='Oracle database segment size'
perf_values="-" perf_values="-"
# check if sqlplus is installed # check if sqlplus is installed
...@@ -44,7 +44,7 @@ flock -n 9 || exit 1 ...@@ -44,7 +44,7 @@ flock -n 9 || exit 1
statustext="Couldn' get used Oracle DB segments." statustext="Couldn' get used Oracle DB segments."
fi fi
echo "${status} ${itemname} ${perf_values} ${statustext}" echo "${status} '${itemname}' ${perf_values} ${statustext}"
) 9>"${LOCKFILE}" ) 9>"${LOCKFILE}"
# Code checked by shellcheck (https://github.com/koalaman/shellcheck) on 2020-12-02 # Code checked by shellcheck (https://github.com/koalaman/shellcheck) on 2022-09-09
...@@ -13,7 +13,7 @@ scriptname=$( basename "${0}" ".sh" ) ...@@ -13,7 +13,7 @@ scriptname=$( basename "${0}" ".sh" )
LOCKFILE="/var/lock/${scriptname}.lock" LOCKFILE="/var/lock/${scriptname}.lock"
status=3 status=3
itemname='oracle_tables_integrity' itemname='Oracle corrupt table blocks'
perf_values="-" perf_values="-"
# check if sqlplus is installed # check if sqlplus is installed
...@@ -21,7 +21,7 @@ BINARY="$(su oracle -c 'command -v sqlplus')" ...@@ -21,7 +21,7 @@ BINARY="$(su oracle -c 'command -v sqlplus')"
[[ ${BINARY} ]] || exit 1 [[ ${BINARY} ]] || exit 1
create_commandlist(){ create_commandlist(){
/bin/su - oracle -c"${BINARY} -S / as sysdba <<-EOF /bin/su - oracle -c"${BINARY} -S / as sysdba <<-\"EOF\"
/* /*
shamelessly stolen (and adapted) from: shamelessly stolen (and adapted) from:
https://oracle-base.com/dba/script?category=miscellaneous&file=analyze_all.sql https://oracle-base.com/dba/script?category=miscellaneous&file=analyze_all.sql
...@@ -29,6 +29,7 @@ create_commandlist(){ ...@@ -29,6 +29,7 @@ create_commandlist(){
more documentation: more documentation:
https://www.oracle.com/technetwork/database/availability/corruption-bestpractices-12c-2141348.pdf https://www.oracle.com/technetwork/database/availability/corruption-bestpractices-12c-2141348.pdf
*/ */
SET TERMOUT OFF
SET PAGESIZE 0 SET PAGESIZE 0
SET FEEDBACK OFF SET FEEDBACK OFF
SET VERIFY OFF SET VERIFY OFF
...@@ -43,13 +44,13 @@ create_commandlist(){ ...@@ -43,13 +44,13 @@ create_commandlist(){
/* run the instructions /* run the instructions
Comment out following line to prevent immediate run */ Comment out following line to prevent immediate run */
--@/tmp/${scriptname}.tempsql /* --@/tmp/${scriptname}.tempsql */
SET PAGESIZE 14 SET PAGESIZE 14
SET FEEDBACK ON SET FEEDBACK ON
SET VERIFY ON SET VERIFY ON
exit; exit;
EOF" \"EOF\"" > /dev/null
echo "exit;" >> "/tmp/${scriptname}.tempsql" echo "exit;" >> "/tmp/${scriptname}.tempsql"
} }
...@@ -57,7 +58,7 @@ create_commandlist(){ ...@@ -57,7 +58,7 @@ create_commandlist(){
# IMPORTANT: Set lock using "flock", NOT "touch"!!! It's atomic and doesn't have to be cleared after the script ran. # IMPORTANT: Set lock using "flock", NOT "touch"!!! It's atomic and doesn't have to be cleared after the script ran.
( (
flock -n 9 || exit 1 flock -n 9 || exit 1
if [[ ( ! -e "/tmp/${scriptname}.tempsql" ) && \ if [[ ( ! -e "/tmp/${scriptname}.tempsql" ) || \
( $(date -r "/tmp/${scriptname}.tempsql" +%s) -lt $(date -d 'now - 14 days' +%s) ) ]]; then ( $(date -r "/tmp/${scriptname}.tempsql" +%s) -lt $(date -d 'now - 14 days' +%s) ) ]]; then
create_commandlist create_commandlist
fi fi
...@@ -70,8 +71,8 @@ flock -n 9 || exit 1 ...@@ -70,8 +71,8 @@ flock -n 9 || exit 1
# - ORA-01578: ORACLE data block corrupted (file # string, block # string) # - ORA-01578: ORACLE data block corrupted (file # string, block # string)
# (https://docs.oracle.com/database/121/ERRMG/ORA-01500.htm#ERRMG-GUID-65B2B9E5-7075-4D53-91B8-FCAECA0AEE0E) # (https://docs.oracle.com/database/121/ERRMG/ORA-01500.htm#ERRMG-GUID-65B2B9E5-7075-4D53-91B8-FCAECA0AEE0E)
# FEEL FREE TO ADD MORE ERRORS AS NECESSARY. # FEEL FREE TO ADD MORE ERRORS AS NECESSARY.
if [[ $( grep -q "ORA-01210" "/tmp/${scriptname}.log" ) || \ if grep -q "ORA-01210" "/tmp/${scriptname}.log" || \
$( grep -q "ORA-01578" "/tmp/${scriptname}.log" ) ]]; then grep -q "ORA-01578" "/tmp/${scriptname}.log"; then
ORACLE_OUTPUT=3 ORACLE_OUTPUT=3
fi fi
...@@ -85,10 +86,10 @@ flock -n 9 || exit 1 ...@@ -85,10 +86,10 @@ flock -n 9 || exit 1
statustext="Database integrity broken, please go look into that NOW!" statustext="Database integrity broken, please go look into that NOW!"
fi fi
echo "${status} ${itemname} ${perf_values} ${statustext}" echo "${status} '${itemname}' ${perf_values} ${statustext}"
) 9>"${LOCKFILE}" ) 9>"${LOCKFILE}"
rm -f "/tmp/${scriptname}.tempsql" rm -f "/tmp/${scriptname}.tempsql"
rm -f "/tmp/${scriptname}.log" rm -f "/tmp/${scriptname}.log"
# Code checked by shellcheck (https://github.com/koalaman/shellcheck) on 2020-12-02 # Code checked by shellcheck (https://github.com/koalaman/shellcheck) on 2022-09-09
--- ---
- name: install self-developed Check_MK plugins for Oracle - name: install self-developed Check_MK plugins for Oracle
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ item }}" src: "usr/lib/check_mk_agent/local/3600/{{ item }}"
dest: "/{{ item }}" dest: "/usr/lib/check_mk_agent/local/3600/{{ item }}"
owner: "root" owner: "root"
group: "root" group: "root"
mode: "0750" mode: "0750"
loop: loop:
- "usr/lib/check_mk_agent/nrpe/check_oracle_db_segment_size.sh" - "check_oracle_db_segment_size.sh"
- "usr/lib/check_mk_agent/nrpe/check_oracle_db_table_integrity.sh" - "check_oracle_db_table_integrity.sh"
- name: configure mrpe
ansible.builtin.blockinfile:
path: "/etc/check_mk/mrpe.cfg"
block: |
Get%20Oracle%20database%20segment%20size. (interval=3600) /usr/lib/check_mk_agent/nrpe/check_oracle_db_segment_size.sh
Find%20corrupt%20Oracle%20table%20blocks. (interval=3600) /usr/lib/check_mk_agent/nrpe/check_oracle_db_table_integrity.sh
# get vendor plugins straight from monitoring server to make sure we get the latest version # get vendor plugins straight from monitoring server to make sure we get the latest version
- name: install vendor Check_MK plugins for Oracle - name: install vendor Check_MK plugins for Oracle
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment