[Pacemaker] crm_mon SNMP support

Florian Crouzat gentoo at floriancrouzat.net
Fri Nov 30 09:07:30 EST 2012


Le 29/11/2012 22:10, Andrew Beekhof a écrit :

> Not so fast :-)
>
> crm_mon supports
>
>         -E, --external-agent=value
>                A program to run when resource operations take place.
>
>         -e, --external-recipient=value A recipient for your program
> (assuming you want the program to send something to someone).
>
> so without recompiling, you can call a script - possibly it could call
> something that sends out snmp alerts ;-)


Oh, great!

I had a hard time understanding these two options and how they relate, 
you helped me on IRC but I'll reply here so there is a trace in case 
someone is also interested.

Here is my resource:

primitive ClusterMon ocf:pacemaker:ClusterMon \
         params user="root" update="30" extra_options="-E 
/usr/local/bin/foo.sh -e 192.168.1.2" \
         op monitor on-fail="restart" interval="10" \
         meta target-role="Started"
clone ClusterMon-clone ClusterMon

Here is the content of my script:

$ cat /usr/local/bin/foo.sh

#!/bin/bash

(
echo CRM_notify_recipient $CRM_notify_recipient
echo CRM_notify_node $CRM_notify_node
echo CRM_notify_rsc $CRM_notify_rsc
echo CRM_notify_task $CRM_notify_task
echo CRM_notify_desc $CRM_notify_desc
echo CRM_notify_rc $CRM_notify_rc
echo CRM_notify_target_rc $CRM_notify_target_rc
echo CRM_notify_status $CRM_notify_status
echo
) > /tmp/pacemaker.log

Finally, this is the resulting log of one execution. The script is 
executed on each cluster operation/transition (monitor, stop, start) etc.

$ cat /tmp/pacemaker.log

CRM_notify_recipient 192.168.1.2
CRM_notify_node scoresby2.lyra-network.com
CRM_notify_rsc F
CRM_notify_task monitor
CRM_notify_desc ok
CRM_notify_rc 0
CRM_notify_target_rc 0
CRM_notify_status 0

One just has to do some scripting with these variables to match its 
needs. In my case, I guess I want a SNMP trap whenever CRM_notify_rc != 0.

Thanks


-- 
Florian Crouzat




More information about the Pacemaker mailing list