Nagios Monitoring Heartbeat

Source: Internet
Author: User

After the heartbeat, we need to monitor it, and below we will know how to monitor.

Let's start with the next few commands, which are automatically added after the heartbeat is installed, and our monitoring scripts use these commands.

[email protected] libexec]# which cl_status/usr/bin/cl_status[[email protected] libexec]# cl_status listnodes   # List nodes in the current heartbeat cluster 192.168.3.1usvr-211usvr-210[[email protected] libexec]# cl_status nodestatus usvr-211  # List the status of a node Active[[email protected] libexec]# cl_status nodestatus 192.168.3.1  #列出节点的状态ping

Our check_heartbeat.sh principle is to list all nodes in the cluster and to monitor the state of all nodes is normal, the node state of our experiment is ping and active.

When the number of active+ping is 0 o'clock critical

Wart when the number of active+ping is less than the total number of nodes

OK when the number of active+ping equals the total number of nodes

[[email protected] libexec]# cat check_heartbeat.sh #!/bin/bash# author:emmanuel bretelle# date:12/03/2010# Description:retrieve Linux HA cluster status using cl_status# Based on http://www.randombugs.com/linux/ howto-monitor-linux-heartbeat-snmp.html # Autor:stanila Constantin adrian# date:20/03/2009# description:check the num ber of active heartbeats# http://www.randombugs.com# Get program pathrevision=1.3progname= '/bin/basename $ ' progpath= ' echo | /bin/sed-e ' s,[\\/][^\\/][^\\/]*$,, ' node_name= ' uname-n ' cl_st= '/usr/bin/cl_status ' #nagios error codes#. $PROGPATH/utils.sh ok=0warning=1critical=2unknown=3usage () {echo "Nagios plugin to Heartbeat. Usage: $PROGNAME $PROGNAME [--help |-h] $PROGNAME [--version |-v]options:--help-lprint This Help information--v Ersion-v Print version of Plugin "}help () {print_revision $PROGNAME $REVISION echo; usage; echo; Support}while te St-n "$" do case "$" in--help |    -h) Help exit $STATE _OK;; --versIon | -V) print_revision $PROGNAME $REVISION exit $STATE _OK;; #-H) # shift# host=$1;;    #-C) # shift# community=$1;; *) echo "Heartbeat unknown:wrong command Usage";  Exit $UNKNOWN;; Esac shiftdone$cl_st hbstatus >/dev/nullres=$?if [$res-ne 0]then echo "Heartbeat critical:heartbeat is not Runni  Ng on this node "exit $CRITICALfideclare-I i=0declare-i a=0nodes= ' $CL _st listnodes ' for node in $NODESdo status= ' $CL _st  Nodestatus $node ' let i= $I +1# if [$status = = "Active"] by default, the number of active states is detected, but the ping status is also normal, so the following conditions are changed. if [$status = = "Active"-o $status = = "Ping"] then let a= $A +1 fidoneif [$A-eq 0]then echo "Heartbeat CRITICAL: $A/$I "Exit $CRITICALelif [$A-ne $I]then echo" Heartbeat WARNING: $A/$I "Exit $WARNINGelse echo" Heartbeat OK: $A/$ I "Exit $OKfi

We are in the Nagios client, our LVS cluster usvr-210,usvr-211, and we get monitoring information through the Nagios server-side Check_nrpe.

Naigos Client

1. First copy the script to the Nagios command directory and modify the appropriate permissions

CP check_heartbeat.sh/usr/local/nagios/libexec/

chmod a+x check_heartbeat.sh

Chown Nagios.nagios check_heartbeat.sh

2. Add a monitoring command to the Naigos client's configuration file.

Vim/usr/local/nagios/etc/nrpe.cfg

command[check_heartbeat]=/usr/local/nagios/libexec/check_heartbeat.sh

3. Reload the configuration file.

Service xinetd Reload

Nagios Service Side

1. Join the related monitoring service

Define Service {     use                     local-service    service_description     heartbeat-lvs-master    Check_command           check_nrpe!check_heartbeat    service_groups          heartbeat_services     host_name               usvr-210    Check_interval          5       notifications_enabled   1       notification_interval      contact_groups          admins}define Service {     use                     local-service    service_description     heartbeat-lvs-slave    check_command           check_nrpe!check_heartbeat    service_groups          heartbeat_services     host_name               usvr-211    check_interval          5       notifications_enabled   1       notification_interval   30      contact_groups          Admins}
2. Check and load the configuration file

Nagioscheck

Service Nagios Reload

Monitoring is as follows:



OK, our heartbeat monitoring is complete.


I am referring to this site Http://wiki.debuntu.org/wiki/Linux_HA_Heartbeat/Monitoring_with_Nagios, I hope to be helpful to everyone.

Nagios Monitoring Heartbeat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.