Python 自动化运维(3)--Nagios使用

添加一个监控主机

  1. 编辑 /usr/local/nagios/etc/objects/contacts.cfg 增加报警联系人信息
    1.
  2. 编辑 /usr/local/nagios/etc/objects/templates.cfg 增加报警策略信息
  3. 编辑 /usr/local/nagios/etc/objects/localhost.cfg 增加被监控主机信息

检测配置文件是否正确

1
2
/etc/init.d/nagios restart # 重新启动
nagios -v /etc/nagios/nagios.cfg # 检查配置文件
  1. 配置文件有错的启动: Running configuration check… CONFIG ERROR! Restart aborted. Check your Nagios configuration
  2. 检测配置文件: nagios -v /etc/nagios/nagios.cfg

客户端安装nagios

  1. 在被监控的机器上安装nagios: yum install nagios
  2. 启动nrpe: systemctl start nagios

客户端进程nrpe

nrpe主要是用来搜集主机相关信息

  1. 在被监控的机器上安装nrpe: yum install nrpe
  2. 启动nrpe: systemctl start nrpe
  3. 修改 /usr/local/nagios/etc/cgi.cfg 配置里的use_authentication 为0
  4. 重启nagios: systemctl restart nagios

图形化工具

nagios只显示当前状态,图形显示很差,可以用以下工具

  1. nagiosQL 图形化配置管理工具
  2. pnp4nagios 监控信息图标工具
  3. nagiosgraph 监控信息图标工具

插件下载

  1. https://exchange.nagios.org/

插件使用

  1. 编辑command.cfg, 增加一个command
  2. 在hosts文件中使用这个command