Nagios Monitoring scripts (custom monitoring system disks)

Source: Internet
Author: User

1. Create a script on the client/usr/local/nagios/libexec/check_disk.sh
Vim/usr/local/nagios/libexec/check_disk.sh writes the following: (On the client)
#!/bin/bash
#!/bin/bash
row= ' Df-h |wc-l '
For i in ' seq 2 $row '
Do
Ava= ' df-h |sed-n "$i" P|awk ' {print $4} '
U_per= ' df-h |sed-n "$i" P|sed-n "s/\%//" P|awk ' {print $
p_p= ' df-h-p|sed-n "$i" P|awk ' {print $6} '
If ["$u _per"-gt "];then"
Echo-n "$p _p CRITICAL $u _per% $ava"
sta[$i]=2
elif ["$u _per"-gt "];then"
Echo-n "$p _p warning! $u _per% $ava "
sta[$i]=1
Else
Echo-n "$p _p OK $u _per% $ava"
sta[$i]=0
Fi
Done
N=0
For j in ' Seq 2 $row '
Do
If ["${sta[$j]}"-GT $n];then
n=${sta[$j]}
Fi
Done
Exit $n

2. After saving, modify the permissions of the script
chmod +x/usr/lib/nagios/plugins//check_disk.sh (on client)
3. Then edit the/etc/nagios/nrpe.cfg file
VIM/ETC/NAGIOS/NRPE.CFG # Add a line: (on client)
command[check_disk]=/usr/lib/nagios/plugins/check_disk.sh
Save, restart Nrpe service
/etc/init.d/nrpe restart (on client)
4. The way to detect if the script is working correctly is to execute the following command to the server side:
Check_nrpe-h 192.168.0.12-c Check_disk (on server)
If normal, it will output a row of disk detection data, or may be error.

cd/etc/nagios/conf.d/
Vim 192.168.0.12.cfg (your IP address name) # Add the following:

Define host{
        use                      linux-server            
        host_name           192.168.0.12
        alias                        0.12
        address                 192.168.0.12
        }

Define Service{
Use Generic-service
HOST_NAME 192.168.0.12
Service_description Check_disk
Check_command Check_nrpe!check_disk
Max_check_attempts 5
Normal_check_interval 1
}

Continue adding services

Vim/etc/nagios/objects/commands.cfg

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

Login ip/nagios/to see if it was successful

Nagios monitoring scripts (custom monitoring system disks)

Related Article

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.