nagios check_procs - 进程监控

【基本介绍】
nagios的客户端nrpe自带了check_procs可以监控进程的数量(nrpe2.13带有这个脚本,早期版本不确定)

【基本参数】
[code="linux"]
# ./check_procs -h
check_procs v1.4.15 (nagios-plugins 1.4.15)

Checks all processes and generates WARNING or CRITICAL states if the specified
metric is outside the required threshold ranges. The metric defaults to number
of processes. Search filters can be applied to limit the processes to check.

Usage:
check_procs -w <range> -c <range> [-m metric] [-s state] [-p ppid]
[-u user] [-r rss] [-z vsz] [-P %cpu] [-a argument-array]
[-C command] [-t timeout] [-v]

Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
-w, --warning=RANGE
Generate warning state if metric is outside this range
-c, --critical=RANGE
Generate critical state if metric is outside this range
-m, --metric=TYPE
Check thresholds against metric. Valid types:
PROCS - number of processes (default)
VSZ - virtual memory size
RSS - resident set memory size
CPU - percentage CPU
ELAPSED - time elapsed in seconds
-t, --timeout=INTEGER
Seconds before connection times out (default: 10)
-v, --verbose
Extra information. Up to 3 verbosity levels

Filters:
-s, --state=STATUSFLAGS
Only scan for processes that have, in the output of `ps`, one or
more of the status flags you specify (for example R, Z, S, RS,
RSZDT, plus others based on the output of your 'ps' command).
-p, --ppid=PPID
Only scan for children of the parent process ID indicated.
-z, --vsz=VSZ
Only scan for processes with VSZ higher than indicated.
-r, --rss=RSS
Only scan for processes with RSS higher than indicated.
-P, --pcpu=PCPU
Only scan for processes with PCPU higher than indicated.
-u, --user=USER
Only scan for processes with user name or ID indicated.
-a, --argument-array=STRING
Only scan for processes with args that contain STRING.
--ereg-argument-array=STRING
Only scan for processes with args that contain the regex STRING.
-C, --command=COMMAND
Only scan for exact matches of COMMAND (without path).

RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If
specified 'max:min', a warning status will be generated if the
count is inside the specified range

This plugin checks the number of currently running processes and
generates WARNING or CRITICAL states if the process count is outside
the specified threshold ranges. The process count can be filtered by
process owner, parent process PID, current state (e.g., 'Z'), or may
be the total number of running processes

Examples:
check_procs -w 2:2 -c 2:1024 -C portsentry
Warning if not two processes with command name portsentry.
Critical if < 2 or > 1024 processes

check_procs -w 10 -a '/usr/local/bin/perl' -u root
Warning alert if > 10 processes with command arguments containing
'/usr/local/bin/perl' and owned by root

check_procs -w 50000 -c 100000 --metric=VSZ
Alert if VSZ of any processes over 50K or 100K

check_procs -w 10 -c 20 --metric=CPU
Alert if CPU of any processes over 10%% or 20%%

Send email to nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net
[/code]

【简单例子】
创建监控警告:进程名是salt-minion数量在1以外的
[code="linux"]
# ./check_procs -w 1:1 -C salt-minion
PROCS OK: 1 process with command name 'salt-minion
[/code]


【一些总结】
1.如果判断进程名
用扩展信息模式,就可以指定进程名字,进程状态等信息
[code="linux"]
# ./check_procs -vv -w 1:1 -C salt-minion
CMD: /bin/ps axwo 'stat uid pid ppid vsz rss pcpu comm args'
Matched: uid=0 vsz=361980 rss=26648 pid=27079 ppid=1 pcpu=0.00 stat=Sl etime= prog=salt-minion args=/usr/bin/python2.6 /usr/bin/salt-minion -d
PROCS OK: 1 process with command name 'salt-minion'
# /bin/ps axwo 'stat uid pid ppid vsz rss pcpu comm args' | grep salt-minion
S+ 0 3628 3505 6056 576 0.0 grep grep salt-minion
Sl 0 27079 1 361980 26648 0.0 salt-minion /usr/bin/python2.6 /usr/bin/salt-minion -d
[/code]

【参考】
[url]http://bangbangsoundslikemachinery.blogspot.tw/2011/09/nagios-plugin-checkprocs-incorrectly.html[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值