Jump to content

Custom script for Oracle ASM Disk Status for Nagios at sandhar

From TetraWiki



Oracle ASM Disk Status Script[edit]

step 1[edit]

Perform the below action as the privileged user to per the task

#!/bin/bash
cat /dev/null > asm_disk_info;
ORACLE_SID=+ASM1
export ORACLE_SID
/u01/app/11.2.0/grid/bin/asmcmd lsdsk -G archive -k >> asm_disk_info;
/u01/app/11.2.0/grid/bin/asmcmd lsdsk -G data -k >> asm_disk_info;
/u01/app/11.2.0/grid/bin/asmcmd lsdsk -G voting -k >> asm_disk_info


to set cronjob[edit]

export EDITOR=vi
crontab -e
3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,59 * * * * /export/home/grid/asm_info.sh #this cron will run  in every 3 minute which provide the disk info in the file and nagios will get the info from that file The maximum delay which can be possible to get the exact info is 6 min due to multiple processing ideally it wont happen

Note: Environment variable are must to set properly we can do the same in in .profile for the permanent set the variable but the script doesn't recognised it so I have done the entry in .profile and as well in the script to have the enviroment make available to run the asmcmd command and full path to command is must to excute the asmcmd command cause it doesn;t recognise the command path due to specific environment.

Details: Archive, Data and Voting were the 3 volumes, Archive volume is the place were all the processing data is required to be processed its a crital one space will always fultuate in it therefore 100GB is the limit for warning and 50GB is for critical state, Data Volume has 3 volumeable disk Data0000, data0001, data0002, same script is use to take output from all and Voting is the disk were all the Configuration file exsist so it will never change ideally for it we have defined the stages which is in blue print.


Sample[edit]

cat check_ASM_ARC

#!/bin/bash
 STATE_OK=0
 STATE_WARNING=1
 STATE_CRITICAL=2
ASM_ARC=`cat /export/home/grid/asm_disk_info | grep ARCHIVE | awk '{print $2 ;}'`
if [ $ASM_ARC -ge 102400 ]
then
       echo "ASM_ARC is OK:AVAILABLE SPACE IS "$ASM_ARC MB;exit ${STATE_OK}
elif [ $ASM_ARC -lt 102400 -a $ASM_ARC -eq 51200 ]
then
       echo "ASM_ARC is in Warning State please check - Available space is"$ASM_ARC MB;exit ${STATE_WARNING}
else
       echo "ASM_ARC volume is crital please check "$ASM_ARC MB;exit ${STATE_CRITICAL}
fi


Change in the above script only 2 parameters for others first grep and second is the threshhold values mentioned in blue prints