Nagios check_ping Command Examples

來源:互聯網
上載者:User

標籤:cert   level   out   example   art   command   rip   messages   nal   

check_ping command is a Nagios plugin that is used to check the ping output of a remote server.

Based on the ping output, you can decide to set certain warning and critical threshold level, based on which Nagios can send notifications to you.

If you’ve installed Nagios from source, you’ll find all the default plugins under /usr/local/nagios/libexec directory.

This tutorial explains how you can use check_ping command with some basic examples.

If you don’t pass any arguments to the check_ping command, it will show all available options as shown below.

# cd /usr/local/nagios/libexec# ./check_pingcheck_ping: Could not parse argumentsUsage:check_ping -H <host_address> -w <wrta>,<wpl>% -c <crta>,<cpl>% [-p packets] [-t timeout] [-4|-6]
1. Basic Usage

Use -H option to specify the hostname or the ip-address of the server for which you like to check the ping command output.

You should also pass both warning and critical threshold limit. If not, you’ll get an error.

Threshold limit for check_ping should be passed as a threshold pair, which has two parts:

  1. Round trip average, which is called as RTA. This is specified in ms
  2. Percentage of packet loss, which is called pl. This should be specified as %age.

In the following example, we are checking the ping output for 192.168.1.1 host. The warning limit is 10ms RTA or 2% packet-loss. The critical limit is 20ms or 5% packet loss.

# ./check_ping -H 192.168.1.1 -w 10,2% -c 20,5%PING OK - Packet loss = 0%, RTA = 0.11 ms|rta=0.110000ms;1.000000;2.000000;0.000000 pl=0%;10;20;0

Note: You should specify “%” after the second number in the threshold limit pair.

2. Specify the Number of ECHO Packets

By default the check_ping command will send 5 ICMP ECHO packets. If you like to change this, use -p option.

In the following example, it sends 10 ICMP ECHO packets to the remote host before its output is measured.

# ./check_ping -H 192.168.1.1 -w 10,2% -c 20,5% -p 10PING OK - Packet loss = 0%, RTA = 0.13 ms|rta=0.129000ms;10.000000;20.000000;0.000000 pl=0%;2;5;0
3. Specify the Connection Timeout

By default the check_ping command will do the connection time out (if it is unable to reach the destination host) after 10 seconds. If you like to change this, use -t option.

In the following example, it will wait for 5 seconds before the connection time-out of the remote host.

# ./check_ping -H 192.168.101.49 -w 10,2% -c 20,5% -t 5CRITICAL - Host Unreachable (192.168.101.49)
4. Use IPv4 of IPv6

By default, it will use IPv4. So, you really don’t need to specify “-4” (which is optional).

# ./check_ping -H 192.168.1.1 -w 1,10% -c 2,20% -4PING OK - Packet loss = 0%, RTA = 0.14 ms|rta=0.142000ms;1.000000;2.000000;0.000000 pl=0%;10;20;0

But, when you use IPv6 address, you should use -6 as shown below.

# ./check_ping -H 2002:4559:1FE2::4559:1FE2 -w 1,2% -c 2,5% -6
5. check_ping Error Messages

The following are some possible error messages that you might get when you try to use check_ping command.

Error 1: If you don’t specify warning threshold limit, you’ll get the following error message:

# ./check_ping -H 192.168.1.1<wrta> was not setcheck_ping: Could not parse arguments

Error 2: If you don’t specify % at the end of threshold limit pair, you’ll get the following error message:

# ./check_ping -H 192.168.1.1 -w 1,10check_ping: %s: Warning threshold must be integer or percentage! - 1,10

Error 3: If you don’t specify critical threshold limit, you’ll get the following error message:

# ./check_ping -H 192.168.1.1 -w 1,10%<crta> was not set

Error 4: If the warning threshold limit values is greater than the critical limit value, you’ll get the following error message:

# ./check_ping -H 192.168.1.1 -w 10,10% -c 2,20%<wrta> (10.000000) cannot be larger than <crta> (2.000000)

Error 5: If the specify -6 and give a IPv4 address, you’ll get the following error message:

# ./check_ping -H 192.168.1.1 -w 1,10% -c 2,20% -6check_ping: Invalid hostname/address - 192.168.1.1

Nagios check_ping Command Examples

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.