博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nagios监控磁盘
阅读量:5337 次
发布时间:2019-06-15

本文共 5310 字,大约阅读时间需要 17 分钟。

    1、查看check_disk脚本

[oracle@rhel5 ~]$ /usr/local/nagios/libexec/check_disk --hcheck_disk v1.4.15 (nagios-plugins 1.4.15)Copyright (c) 1999 Ethan Galstad 
Copyright (c) 1999-2008 Nagios Plugin Development Team
This plugin checks the amount of used disk space on a mounted file systemand generates an alert if free space is less than one of the threshold valuesUsage: check_disk -w limit -c limit [-W limit] [-K limit] {
-p path | -x device}[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ][-t timeout] [-u unit] [-v] [-X type]Options: -h, --help Print detailed help screen -V, --version Print version information -w, --warning=INTEGER Exit with WARNING status if less than INTEGER units of disk are free -w, --warning=PERCENT% Exit with WARNING status if less than PERCENT of disk space is free -c, --critical=INTEGER Exit with CRITICAL status if less than INTEGER units of disk are free -c, --critical=PERCENT% Exit with CRITCAL status if less than PERCENT of disk space is free -W, --iwarning=PERCENT% Exit with WARNING status if less than PERCENT of inode space is free -K, --icritical=PERCENT% Exit with CRITICAL status if less than PERCENT of inode space is free -p, --path=PATH, --partition=PARTITION Path or partition (may be repeated) -x, --exclude_device=PATH
Ignore device (only works if -p unspecified) -C, --clear Clear thresholds -E, --exact-match For paths or partitions specified with -p, only check for exact paths -e, --errors-only Display only devices/mountpoints with errors -g, --group=NAME Group paths. Thresholds apply to (free-)space of all partitions together -k, --kilobytes Same as '--units kB' -l, --local Only check local filesystems -L, --stat-remote-fs Only check local filesystems against thresholds. Yet call stat on remote filesystems to test if they are accessible (e.g. to detect Stale NFS Handles) -M, --mountpoint Display the mountpoint instead of the partition -m, --megabytes Same as '--units MB' -A, --all Explicitly select all paths. This is equivalent to -R '.*' -R, --eregi-path=PATH, --eregi-partition=PARTITION Case insensitive regular expression for path/partition (may be repeated) -r, --ereg-path=PATH, --ereg-partition=PARTITION Regular expression for path or partition (may be repeated) -I, --ignore-eregi-path=PATH, --ignore-eregi-partition=PARTITION Regular expression to ignore selected path/partition (case insensitive) (may be repeated) -i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION Regular expression to ignore selected path or partition (may be repeated) -t, --timeout=INTEGER Seconds before connection times out (default: 10) -u, --units=STRING Choose bytes, kB, MB, GB, TB (default: MB) -v, --verbose Show details for command-line debugging (Nagios may truncate output) -X, --exclude-type=TYPE Ignore all filesystems of indicated type (may be repeated)Examples: check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p / Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB check_disk -w 100 -c 50 -C -w 1000 -c 500 -g sidDATA -r '^/oracle/SID/data.*$' Checks all filesystems not matching -r at 100M and 50M. The fs matching the -r regex are grouped which means the freespace thresholds are applied to all disks together check_disk -w 100 -c 50 -C -w 1000 -c 500 -p /foo -C -w 5% -c 3% -p /bar Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use 100M/50MSend email to nagios-users@lists.sourceforge.net if you have questionsregarding use of this software. To submit patches or suggest improvements,send email to nagiosplug-devel@lists.sourceforge.net

    举例:

    Usage: check_disk -w limit -c limit {-p path | -x device}
    格式:check_disk -w 低限% -c 低限% -p 磁盘设备文件或则分区文件的绝对路径
    Options:
    选项
    -w, --warning=PERCENT%
        设定告警通知百分比数,空间低于该百分比则发出告警通知。
    -c, --critical=PERCENT%
        设定严重告警通知百分比数,空间低于该百分比则发出严重告警通知。
    -p, --path=PATH, --partition=PARTITION
        指定磁盘设备文件或则分区文件的绝对路径。
    #如果要监控根目录,达到80%报警,达到90%为严重危险
    check_disk -w 80% -c 90% -p /dev/hda1   #-p后面接需要监控的硬盘分区,如果是SCSI硬盘就是sda1,当然此时被监控端的nrpe配置文件要进行相应的修改
    其中check_disk主要是检查磁盘的未用空间。
    2、修改nagios主机上被监控主机的配置文件

[root@rhel5 ~]# cat /usr/local/nagios/etc/services.cfg define service{         use    generic-service         host_name oracle         service_description check-disk         check_command    check_nrpe!check_orcl         }

    3、修改被监控主机上的nrpe配置文件

[root@rhel5 ~]# cat /usr/local/nagios/etc/nrpe.cfgcommand[check_orcl]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/mapper/vg_orcl-orcl
[oracle@rhel5 orcl]$ df -h文件系统              容量  已用 可用 已用% 挂载点/dev/sda1             7.8G  3.4G  4.1G  46% /tmpfs                 355M  196M  159M  56% /dev/shm/dev/mapper/vg_orcl-orcl                       15G  8.4G  5.6G  60% /u01/dev/mapper/vg_mysql-mysql                      1.9G  576M  1.3G  32% /mysql

    查看一下页面:

 

    拷贝一些文件到/u01目录下,再df -h查看一下:

[oracle@rhel5 oradata]$ df -h文件系统              容量  已用 可用 已用% 挂载点/dev/sda1             7.8G  3.4G  4.1G  46% /tmpfs                 355M  196M  159M  56% /dev/shm/dev/mapper/vg_orcl-orcl                       15G   12G  3.0G  80% /u01/dev/mapper/vg_mysql-mysql                      1.9G  576M  1.3G  32% /mysql

    最后看一下页面:

转载于:https://www.cnblogs.com/Richardzhu/p/3344241.html

你可能感兴趣的文章
pycharm激活地址
查看>>
hdu 1207 四柱汉诺塔
查看>>
Vue 2.x + Webpack 3.x + Nodejs 多页面项目框架(上篇——纯前端多页面)
查看>>
display:none与visible:hidden的区别
查看>>
我的PHP学习之路
查看>>
【题解】luogu p2340 奶牛会展
查看>>
对PostgreSQL的 SPI_prepare 的理解。
查看>>
解决响应式布局下兼容性的问题
查看>>
京东静态网页练习记录
查看>>
使用DBCP连接池对连接进行管理
查看>>
【洛谷】【堆+模拟】P2278 操作系统
查看>>
hdu3307 欧拉函数
查看>>
Spring Bean InitializingBean和DisposableBean实例
查看>>
Solr4.8.0源码分析(5)之查询流程分析总述
查看>>
[Windows Server]安装系统显示“缺少计算机所需的介质驱动程序”解决方案
查看>>
[容斥][dp][快速幂] Jzoj P5862 孤独
查看>>
Lucene 学习之二:数值类型的索引和范围查询分析
查看>>
软件开发工作模型
查看>>
Java基础之字符串匹配大全
查看>>
面向对象
查看>>