Real-time monitoring of Nagios

Source: Internet
Author: User

Nagios can only monitor the server for 1 minutes, 5 minutes, and 15 minutes. But we can't see through Nagios What services our servers are running in the blink of an emergency. This does not help us find the cause of the problem. Because of the need to record the status of the service for a moment.

1. Edit the Host file Linhost.cfg

Define Service{

Use Generic-service

HOST_NAME Linhost

Service_description Load_average_res

Check_command Check_nrpe!check_load

Event_handler Processes_snapshot_res!linhost

Contact_groups Admins

}


Define Service{

Use Generic-service

HOST_NAME Linhost

Service_description LOAD_AVERAGE_CPU

Check_command Check_nrpe!check_load

Event_handler Processes_snapshot_cpu!linhost

Contact_groups Admins

}


2. Edit the command file command.cfg

Define Command{

Command_name Processes_snapshot_res

Command_line $USER 1$/eventhandlers/processes_snapshot_res.sh $ $SERVICESTATETYPE $ $SERVICEATTEMPT $ $SERVICESTATE hostaddress$

}


Define Command{

Command_name PROCESSES_SNAPSHOT_CPU

Command_line $USER 1$/eventhandlers/processes_snapshot_cpu.sh $ $SERVICESTATETYPE $ $SERVICEATTEMPT $ $SERVICESTATE hostaddress$

}


3. Editing Scripts processes_snapshot_cpu.sh and processes_snapshot_res.sh

processes_snapshot_cpu.sh

#!/bin/bash

Case "$" in

OK)

;;

WARNING)

/usr/local/nagios/libexec/check_nrpe-h $4-c PROCESSES_SNAPSHOT_CPU

;;

UNKNOWN)

;;

CRITICAL)

/usr/local/nagios/libexec/check_nrpe-h $4-c PROCESSES_SNAPSHOT_CPU

;;

Esac


Exit 0


processes_snapshot_res.sh

#!/bin/bash

Case "$" in

OK)

;;

WARNING)

/usr/local/nagios/libexec/check_nrpe-h $4-c Processes_snapshot_res

;;

UNKNOWN)

;;

CRITICAL)

/usr/local/nagios/libexec/check_nrpe-h $4-c Processes_snapshot_res

;;

Esac


Exit 0


4. Edit the configuration file on the monitored side nrpe.cfg

COMMAND[PROCESSES_SNAPSHOT_RES]=TOP-CSBN 1 | Tail-n +8 | Sort-rn-k6 | Head-n >/tmp/proc_snap_res_ ' Date +%y%m%d-%h:%h:%s '. txt

COMMAND[PROCESSES_SNAPSHOT_CPU]=TOP-CSBN 1 | Tail-n +8 | Sort-rn-k9 | Head-n >/tmp/proc_snap_cpu_ ' Date +%y%m%d-%h:%h:%s '. txt


5. Create a directory on the monitored side

#cd/usr/local/nagios

#mkdir Log

#chmod 777 Log

#chown Nagios:nagios Log


6. Nagios has caching capabilities and we need to turn off Nagios's caching capabilities. Edit the Nagios master configuration file nagios.cfg.

Cached_host_check_horizon=0

Cached_service_check_horizon=0


This is configured, when our server load is too high, will be in the/usr/local/nagios/log directory of the monitored server to generate file records that instant delivery services.

This article is from the "Operational Work Notes" blog, make sure to keep this source http://yyyummy.blog.51cto.com/8842100/1554483

Real-time monitoring of Nagios

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.