nagios 监控本机及远程机器

简介:

cd /usr/local/nagios/etc/objects
vim localhost.cfg

define host{
       use                     linux-server                                      
       host_name               localhost
       alias                   localhost
       address                 127.0.0.1
       }

# Define an optional hostgroup for Linux machines

define hostgroup{
       hostgroup_name  linux-servers ; The name of the hostgroup
       alias           Linux Servers ; Long name of the group
       members         localhost     ; Comma separated list of hosts that belong to this group
       }

# Define a service to "ftp" the local machine 

define service{
       use                             local-service         ; Name of service template to use 
       host_name                       localhost
       service_description             FTP
       check_command                   check_ftp
       }

# Define a service to "nfs" the local machine 

define service{
       use                             local-service         ; Name of service template to use 
       host_name                       localhost
       service_description             NFS
       check_command                   check_tcp!2049
       }


监控远程主机

==============================================================================

cd /usr/local/nagios/etc/objects
cp localhost.cfg 192.168.0.164.cfg
vim 192.168.122.100

define host{
       use                     linux-server    
       host_name               testserver
       alias                   host196
       address                 192.168.122.100
       }

#define hostgroup{
#        hostgroup_name  testserver ; The name of the hostgroup
#        alias           host; Long name of the group
#        members         localhost   ; Comma separated list of hosts that belong to this group
#}

define service{
       use                             local-service 
       host_name                       testserver
       service_description             PING
       check_command                   check_ping!100.0,20%!500.0,60%
       }

define service{
       use                             local-service  
host_name                       testserver
       service_description             HTTP
       check_command                   check_http
#       notifications_enabled           0
       }

define service{
       use                             local-service
       host_name                       testserver
       service_description             NFS
       check_command                   check_tcp!2049
#       notifications_enabled           0
       }

=============================================================================

更改主配置文件

vim /usr/local/nagios/etc/nagios.cfg

添加一行
cfg_file=/usr/local/nagios/etc/objects/192.168.122.100.cfg

检测新的配置文件是否正确

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0 
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
=============================================================================


wKioL1M3sSWT_cJpAANHKP17Etw344.jpg


wKiom1M3seuSA4U6AASXUNl3_GM102.jpg











本文转自zhang25yun51CTO博客,原文链接: http://blog.51cto.com/1585654/1386857,如需转载请自行联系原作者



相关文章
|
11天前
|
弹性计算 运维 Shell
远程其他主机安装httpd 软件
【4月更文挑战第29天】
8 1
|
监控 网络协议 网络安全
LXJ
|
监控
端口监控脚本
端口监控脚本
LXJ
118 0
|
监控 网络安全
|
安全 网络安全 Apache