Skip to content
Advertisement

Monitor a Pacemaker Cluster with ocf:pacemaker:ClusterMon and/or external-agent

Im trying to configure Pacemaker cluster events notifications via external agent to receive notifications when failover switching happens.
I searched for below links

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Configuring_the_Red_Hat_High_Availability_Add-On_with_Pacemaker/s1-eventnotification-HAAR.html

http://floriancrouzat.net/2013/01/monitor-a-pacemaker-cluster-with-ocfpacemakerclustermon-andor-external-agent/

But not understanding how actually do this.
Could you please give step by step explaination.

Thank You,
Ranjan.

Advertisement

Answer

The RedHat doc is terse, but Florian’s blog entry is pretty detailed and the references at the end are helpful.

The question as asked is sort of vague, so I’m answering what I think you’re asking.

Briefly, summarizing part of Florian’s post, ClusterMon is a resource agent (ocf:pacemaker:ClusterMon) that runs crm_mon behind the scenes.

My (SLES 11 SP3) resource’s documentation says:

JavaScript

But, the real power is the extra_options because this allows you to have the resource agent tell crm_mon what to do with the results. Specifically, the extra_options are passed verbatim as command line options for crm_mon.

As Florian mentioned, more recent vintages of crm_mon (what’s actually doing the work) don’t come with SMTP (email) or SNMP support built in. However, it still supports the external agent (through the -E switch).

So, to understand what the extra_options does, you should consult man crm_mon.

From the RedHat documentation you linked to, the first “extra_options” value of -T pacemaker@example.com -F pacemaker@nodeX.example.com -P PACEMAKER -H mail.example.com tell crm_mon to send an email To pacemaker@example.com, From pacemaker@nodeX.example.com, with subject Prefix PACEMAKER, through the mail Host (smtp server) mail.example.com.

The second “extra_options” example in the RedHat doc you reference had value -S snmphost.example.com -C public which tells crm_mon to send SNMP traps to snmphost.example.com using the Community named public.

The third “extra_options” example has value -E /usr/local/bin/example.sh -e 192.168.12.1. This tells crm_mon to run the External program /usr/local/bin/example.sh and it also also specifies the ‘external recipient’ which actually just gets thrown into an environment variable CRM_notify_recipient that’s exported before spawning the script.

When running an external agent, crm_mon calls the script provided for every cluster event (including successful monitoring operations!). This script inherits a bunch of environment variables that tell you what’s going on.

From: http://clusterlabs.org/doc/en-US/Pacemaker/1.1/html/Pacemaker_Explained/s-notification-external.html the environment variables that are set are:

JavaScript

The job of the script is to consume these environment variables and do something reasonable with them. What is “reasonable” depends on your environment.

The example with SNMP traps in Florian’s blog assumes you are familiar with SNMP traps. If not, then that’s an entirely different question and beyond the scope of the resource agent.

The example with SNMP traps gives a good conditional statement to identify events that are either unsuccessful monitor events, or events that are not monitor events.

The scaffolding of a monitoring script to do whatever you would like with the available information is really a stripped down version of the snmp trap shell script referenced in Florian’s blog post. It looks like:

JavaScript

However, if you’re following Florian’s advice and you clone the resource, the script will run on every node. For SNMP traps that’s perfectly fine. However, if you’re doing something like sending an email from the script, you may not want to actually have it cloned.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement