我有一个 etch nagios 服务器(我将称之为 NagiosServer),它成功地监控了很多东西,包括另一个 etch 服务器(MonitorEtch)。使用 check_nrpe 和 check_procs,我可以检查正在运行的守护进程的进程列表,例如“/usr/sbin/squid”。
从 NagiosServer 检查 MonitorEtch(正确结果):
/usr/lib/nagios/plugins/check_nrpe -H MonitorEtch -c check_process -a /usr/sbin/squid 1:1 1:1
PROCS OK: 1 process with args '/usr/sbin/squid'
/usr/lib/nagios/plugins/check_nrpe -H MonitorEtch -c check_process -a whatever 1:1 1:1
PROCS CRITICAL: 0 processes with args 'whatever'
Run Code Online (Sandbox Code Playgroud)
我已经构建了一个我想要监控的新服务器,运行 Lucid (MonitorLucid)。无论我尝试从 NagiosServer 监控什么进程,我都会得到超出预期的结果。
从 NagiosServer 检查 MonitorLucid(结果不正确):
/usr/lib/nagios/plugins/check_nrpe -H MonitorLucid -c check_process -a whatever 1:1 1:1
PROCS OK: 1 process with args 'whatever'
ps ax|grep sophie
12737 ? Ss 0:00 /usr/sbin/sophie -D
12738 ? S 0:03 /usr/sbin/sophie -D
19591 pts/0 S+ 0:00 grep --color=auto sophie
/usr/lib/nagios/plugins/check_nrpe -H 192.168.19.252 -c check_process -a sophie 1:1 1:1
PROCS CRITICAL: 3 processes with args 'sophie'
Run Code Online (Sandbox Code Playgroud)
MonitorLucid/MonitorEtch 上 /etc/nagios/nrpe_local.cfg 的内容:
allowed_hosts=NagiosServer,127.0.0.1
dont_blame_nrpe=1
command[check_process]=/usr/lib/nagios/plugins/check_procs -a $ARG1$ -m PROCS -w $ARG2$ -c $ARG3$
Run Code Online (Sandbox Code Playgroud)
然而,如果我在本地执行检查,它会返回正确的结果!
从 MonitorLucid 检查 MonitorLucid(正确结果):
/usr/lib/nagios/plugins/check_procs -a whatever -m PROCS -w 1:1 -c 1:1
PROCS CRITICAL: 0 processes with args 'whatever'
/usr/lib/nagios/plugins/check_procs -a sophie -m PROCS -w 1:1 -c 1:1
PROCS CRITICAL: 2 processes with args 'sophie'
Run Code Online (Sandbox Code Playgroud)
在这一点上我没有想法,没有比我应该检查的多 1 个实例。
我有类似的问题。check_procs
是内部调用/bin/ps axwo 'stat uid pid ppid vsz rss pcpu comm args'
,它列出进程然后对它们进行计数。如果您已将 nagios 配置为使用不同的用户运行,则它将用于sudo
执行该命令。问题就在这里。如果您键入sudo ps -AF | grep sudo
,某些分布会返回“ grep sudo
”,其他分布会返回“ sudo ps -AF
”和“ grep sudo
”。由于 check_procs 正在对所有进程进行计数,因此您将在不同的机器上得到不同的结果。不幸的是,我还没有解决方案如何强制 check_procs 不计算sudo
进程。
归档时间: |
|
查看次数: |
9427 次 |
最近记录: |