Changes between Version 9 and Version 10 of OMDeventhandlers

Show
Ignore:
Timestamp:
11/14/11 14:48:24 (8 years ago)
Author:
jonmills (IP: 152.54.3.30)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OMDeventhandlers

    v9 v10  
    4747 
    4848=== 'del_vm' eventhandler script === 
    49 {{{ 
    50 #!/bin/bash 
    51 # 
    52 # Event handler script for re-inventorying a host when the 
    53 # "Check_MK Inventory" check comes back telling you that there 
    54 # are unchecked services on a host. 
    5549 
    56 export PATH="/omd/sites/nagios/lib/perl5/bin:/omd/sites/nagios/local/bin:/omd/sites/nagios/bin:/omd/sites/nagios/local/lib/perl5/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/local/bin:/opt/local/sbin" 
    57  
    58 # These are bash args brought in from the command line 
    59 LOG=/tmp/del_vm.sh 
    60 HOSTNAME=$1 
    61 HOSTSTATE=$2 
    62  
    63 case "$HOSTSTATE" in 
    64  
    65 UP) 
    66         # Do nothing on ok 
    67         ;; 
    68  
    69 DOWN) 
    70  
    71         # We need to verify the $INSTANCE is gone, using euca-describe-instances 
    72         RESULT=$(euca-describe-instances | egrep '(running|pending)' | grep ${HOSTNAME} >/dev/null; echo $?) 
    73         if [ $RESULT = 1 ]; then 
    74  
    75         #Logging... 
    76         touch $LOG 
    77         echo $0 > $LOG 
    78         echo `date` >> $LOG 
    79         echo "HOSTNAME is $HOSTNAME" >> $LOG 
    80         echo "HOSTSTATE is $HOSTSTATE" >> $LOG 
    81         echo " " >> $LOG 
    82  
    83         # Clean up cmk 
    84         echo "Running cmk --flush $HOSTNAME" >> $LOG 
    85         ${OMD_ROOT}/bin/cmk --flush $HOSTNAME >> $LOG 
    86  
    87         # Remove the VM from Check_MK 
    88         echo "Removing $HOSTNAME from hosts.mk" >> $LOG 
    89         /bin/sed -i '/'$HOSTNAME'/ d' ${OMD_ROOT}/etc/check_mk/conf.d/hosts.mk >> $LOG 
    90         echo "Removing $HOSTNAME from ipaddresses.mk" >> $LOG 
    91         /bin/sed -i '/'$HOSTNAME'/ d' ${OMD_ROOT}/etc/check_mk/conf.d/ipaddresses.mk >> $LOG 
    92  
    93         # Now re-inventory && reload 
    94         echo "Running cmk -IIu" >> $LOG 
    95         ${OMD_ROOT}/bin/cmk -IIu >> $LOG 
    96         echo "Running cmk -O" >> $LOG 
    97         ${OMD_ROOT}/bin/cmk -O >> $LOG 
    98  
    99         fi 
    100         ;; 
    101  
    102 esac 
    103  
    104 exit 0 
    105 }}} 
     50 * SVN Source: 
     51  * [https://code.renci.org/gf/project/networkedclouds/scmsvn/?action=browse&path=%2Fnagios%2Ftrunk%2Feventhandlers%2Fscripts%2Fdel_vm.sh&view=markup del_vm.sh]