Nagios check_ping Command Examples

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_ping
check_ping: Could not parse arguments
Usage: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 10
PING 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 5
CRITICAL - 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% -4
PING 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 set
check_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,10
check_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% -6
check_ping: Invalid hostname/address - 192.168.1.1
时间: 2024-10-05 17:02:22

Nagios check_ping Command Examples的相关文章

15 Linux Split and Join Command Examples to Manage Large Files--reference

by HIMANSHU ARORA on OCTOBER 16, 2012 http://www.thegeekstuff.com/2012/10/15-linux-split-and-join-command-examples-to-manage-large-files/ Linux split and join commands are very helpful when you are manipulating large files. This article explains how

Basic chkconfig Command Examples in Linux

This is our ongoing Linux command series where we are going to review how we can usechkconfigcommand efficiently with it's available parameters. TheChkconfigcommand tool allows to configure services start and stop automatically in the/etc/rd.d/init.d

Top 30 Nmap Command Examples For Sys/Network Admins

Nmap is short for Network Mapper. It is an open source security tool for network exploration, security scanning and auditing. However, nmap command comes with lots of options that can make the utility more robust and difficult to follow for new users

13 Basic Cat Command Examples in Linux(转) Linux中cat命令的13中基本用法

Cat (串联) 命令是Linux/Unix开源系统中比较常用的一个命令.我们可以通过Cat命令创建一个或多个文件,查看文件内容,串联文件并将内容输出到终端设备或新的文件当中,这篇文章我们将会以实例的方式讲解Linux中cat命令一些简便的用法. The cat (short for "concatenate") command is one of the most frequently used command in Linux/Unix like operating systems

A Complete Guide to Usage of ‘usermod’ command– 15 Practical Examples with Screenshots

https://www.tecmint.com/usermod-command-examples/ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In Unix/Linux distribut

Nagios配置文件nagios.cfg详解

这里开始要讲一些Nagios的配置. 首先要看看目前Nagios的主配置路径下有哪些文件.[[email protected] etc]# ll总用量 152-rwxrwxr-x. 1 nagios nagios 1825 9月  24 14:40 cgi.cfg-rwxrwxr-x. 1 nagios nagios 9747 9月  24 14:40 checkcommands.cfg-rwxrwxr-x. 1 nagios nagios 1089 9月  24 14:40 connector

Nagios配置之交换机及路由

监控交换机大多是监控交换机端口up/down,以及端口流量 .监控开启状态需要snmp协议,请确保交换机及路由已开启snmp,并设置好社区集(community),监控流量需要mrtg 1.安装mrtg yum install mrtg Perl libpng zlib 2.修改snmpd的配置,以使其允许mrtg读取其interface(网络接口) 流量数据. vi /etc/snmp/snmpd.conf 将#view systemview included mib2 的内容修改为: vie

Nagios安装与配置(2)

一.配置Nagios Nagios 主要用于监控一台或者多台本地主机及远程的各种信息,包括本机资源及对外的服务等.默认的Nagios 配置没有任何监控内容,仅是一些模板文件.若要让Nagios 提供服务,就必须修改配置文件,增加要监控的主机和服务,下面将详细介绍. Nagios 安装完毕后,默认的配置文件在/usr/local/nagios/etc目录下.我们在编译的时候指定了 --sysconfdir=DIR, 所以我们的配置文件目录为/etc/nagios. 1.配置文件的作用概述 备注:N

企业级监控nagios实践

nagios 监控服务应用指南 小区:视频监控,保安 企业工作中为什么要部署监控系统 监控系统相当于哨兵的作用,监控几百台上千台服务器,监控系统非常重要. 监控系统都需要监控 1. 本地资源:负载uptime cpu(top,sar),磁盘(df),内存(free),io(iostat),raid,温度,passwd文件的变化,本地所有文件指纹识别 2. 网络服务:端口,url ,丢包,进程数,网络流量 3. 其他设备: 路由器.交换机端口流量,打印机,windows等 4. 业务数据:用户登录