设为首页 收藏本站
查看: 661|回复: 0

nagios check_procs

[复制链接]

尚未签到

发表于 2017-4-20 09:31:34 | 显示全部楼层 |阅读模式
【基本介绍】
nagios的客户端nrpe自带了check_procs可以监控进程的数量(nrpe2.13带有这个脚本,早期版本不确定)
【基本参数】

[iyunv@local libexec]# ./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


【简单例子】
创建监控警告:进程名是salt-minion数量在1以外的

[iyunv@locallibexec]# ./check_procs -w 1:1 -C salt-minion
PROCS OK: 1 process with command name 'salt-minion


【一些总结】
1.如果判断进程名
用扩展信息模式,就可以指定进程名字,进程状态等信息

[iyunv@local libexec]# ./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'
[iyunv@local libexec]# /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


【参考】
http://bangbangsoundslikemachinery.blogspot.tw/2011/09/nagios-plugin-checkprocs-incorrectly.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-366663-1-1.html 上篇帖子: (转载)Nagios企业级系统监控方案 下篇帖子: [转]Ganglia 和 Nagios,第 2 部分: 使用 Nagios 监视企业集群
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表