Custom Nagios plugin script in CentOS 7

Source: Internet
Author: User

First, the system environment

Operating system: CentOS 7

Nagios server-side version: nagios-4.0.8-2.el7.x86_64

Nrpe Client version: nrpe-2.15-7.el7.x86_64

Two, Nagios custom plugin return code:
Return Code Service State Host State
0 OK up
1 WARNING up or down/unreachable*
2 CRITICAL down/unreachable
3 UNKNOWN down/unreachable

Third, define the plug-in, put the plug-in/usr/lib64/nagios/plugins

(1) Scripts need to have Execute permission

-RWXRWXRWX 1 Nagios Nagios 281 may 13:35 check_zfstatus.sh

(2) Define the monitoring command, in the monitored end/etc/nagios/nrpe.cfg,

command[check_zfs]=/usr/bin/sudo/usr/lib64/nagios/plugins/check_zfstatus.sh

(3) define Service and command on Nagios server side

Define Command{
Command_name Check_nrpe
Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$
}

Define Service{
Use Local-service
HOST_NAME test
Service_description Zfs_status
Check_command CHECK_NRPE!CHECK_ZFS
}

Four, restart the process, in the monitoring interface can see the definition of the service

PS: In the installation process encountered problems and solutions

Attach the script code:

#! /bin/bash
Sudo/usr/sbin/zpool Scrub Myzpool
Device= ' Sudo/usr/sbin/zpool status | Grep-o UNAVAIL | Uniq '
Status=unavail
if [["$device" = = "$status"]]; Then
echo "Device wrong!"
Exit 2
Else
echo "Device all right;"
Exit 0
Fi
Script Description:

(1) Because Zpool only root user has permission, Nrpe cannot call, so need to edit/etc/sudoers file, give

Nrpe permissions. Add Nrpe all= (All) Nopasswd:all

(2) [["$device" = = "$status"]] because the device variable is sometimes null, it is necessary to write two brackets in the judgment

(3) If the monitoring status output is inconsistent with the script execution results, the error is switched to the Nagios user
/usr/lib64/nagios/plugins/check_nrpe-h IP address-c CHECK_ZFS





This article is from the Linux tours blog, so be sure to keep this source http://bluefei.blog.51cto.com/3921428/1782527

Custom Nagios plugin script in CentOS 7

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.