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

Linux下Nagios的安装与配置<< 二 >>

[复制链接]

尚未签到

发表于 2019-1-14 11:18:38 | 显示全部楼层 |阅读模式

  篇幅所限,看“Linux下Nagios的安装与配置>”之前请先看“Linux下Nagios的安装与配置>”
未完,还有Linux下Nagios的安装与配置>



localhost.cfg


Definehost{
Use   linux-server  ; Name of host template to use
       ; This host definition will inherit all variables that are defined
       ; in (or inherited by) the linux-server host template definition.
Host_name  Nagios-Server
Alias   Nagios-Server
Address   127.0.0.1
}
definehostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
Alias  Linux Servers ; Long name of thegroup
members  Nagios-Server ; Comma separated listof hosts that belong to this group
}
defineservice{
Use    local-service  ; Name of service template to use
Host_name   Nagios-Server
service_description  PING
check_command   check_ping!100.0,20%!500.0,60%
}
Defineservice{
use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  Root Partition
check_command   check_local_disk!20%!10%!/
}
defineservice{
use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  Current Users
check_command   check_local_users!20!50
}
defineservice{
use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  Total Processes
check_command   check_local_procs!250!400!RSZDT
}
Defineservice{
Use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  Current Load
check_command   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
defineservice{
use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  Swap Usage
check_command   check_local_swap!20!10
}
defineservice{
Use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  SSH
check_command   check_ssh
notifications_enabled  0
}
defineservice{
Use    local-service  ; Name of service template to use
host_name   Nagios-Server
service_description  HTTP
check_command   check_http
notifications_enabled  0
}


windows.cfg,本实验主要采用组进行配置,此文档不删掉不使,下面配置供参考。


definehost{
use  windows-server ; Inherit default values from a template
host_name Nagios-Windows ; The name we're giving to this host
alias  My Windows Server ; A longer name associated with the host
address  192.168.1.113 ; IP address of the host
}
definehostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias  Windows Servers ; Long name of thegroup
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description NSClient++ Version
check_command  check_nt!CLIENTVERSION
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description Uptime
check_command  check_nt!UPTIME
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description CPU Load
check_command  check_nt!CPULOAD!-l 5,80,90
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description Memory Usage
check_command  check_nt!MEMUSE!-w 80 -c 90
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description C:\ Drive Space
check_command  check_nt!USEDDISKSPACE!-l c -w 80 -c90
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description W3SVC
check_command  check_nt!SERVICESTATE!-d SHOWALL -lW3SVC
}
defineservice{
use   generic-service
host_name  Nagios-Windows
service_description Explorer
check_command  check_nt!PROCSTATE!-d SHOWALL -lExplorer.exe
}


e. services.cfg文件
此文件默认也不存在,需要手动创建,services.cfg文件主要用于定义监控的服务和主机资源,例如监控http服务、ftp服务、主机磁盘空间、主机系统负载等等。Nagios-Server Nagios-Windows 相关服务已在相应的配置文件中定义,所以这里只需要定义Nagios-Linux 相关服务即可,这里只定义一个检测是否存活的服务来验证配置文件的正确性,其他服务的定义将在后面讲到。
define service{
use   local-service  ; #引用local-service服务的属性值,local-servicetemplates.cfg文件中进行了定义。
host_name  Nagios-Linux  ; #指定要监控哪个主机上的服务,“Nagios-Server”在hosts.cfg文件中进行了定义。
service_description PING   ; #对监控服务内容的描述,以供维护人员参考。
contact_groups  linuxcontact
check_command  check-host-alive ; #指定检查的命令。
}
define service{
use   local-service
host_name  Nagios-Linux
service_description CurrentLoad
contact_groups  linuxcontact
check_command  check_nrpe!check_load
}
define service{
use   local-service
host_name  Nagios-Linux
service_description TotalProcesses
contact_groups  linuxcontact
check_command  check_nrpe!check_total_procs
}
define service{
use   local-service
host_name  Nagios-Linux
service_description CurrentUsers
contact_groups  linux contact
check_command  check_nrpe!check_users
}
define service{
use   local-service
host_name  Nagios-Linux
service_description CheckZombie Procs
contact_groups  linuxcontact
check_command  check_nrpe!check_zombie_procs
}
define service{
use   local-service
host_name  Nagios-Linux
service_description Check Swap
contact_groups  linux contact
check_command  check_nrpe!check_swap
}
# SERVICE DEFINITIONS
#
###############################################################################
# Create a service for monitoring the versionof NSCLient++ that is installed
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description NSClient++Version
contact_groups  windowscontact
check_command  check_nt!CLIENTVERSION
}
# Create a service for monitoring the uptimeof the server
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description Uptime
contact_groups  windowscontact
check_command  check_nt!UPTIME
}


# Create a service for monitoring CPU load
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description CPU Load
contact_groups  windowscontact
check_command  check_nt!CPULOAD!-l 5,80,90
}


# Create a service for monitoring memoryusage
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description MemoryUsage
contact_groups  windowscontact
check_command  check_nt!MEMUSE!-w 80 -c 90
}


# Create a service for monitoring C:\ diskusage
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description C:\ DriveSpace
contact_groups  windowscontact
check_command  check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}


# Create a service for monitoring the W3SVCservice
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description W3SVC
contact_groups  windowscontact
check_command  check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}


# Create a service for monitoring theExplorer.exe process
# Change the host_name to match the name ofthe host you defined above


define service{
use   generic-service
host_name  Nagios-Windows
service_description Explorer
contact_groups  windowscontact
check_command  check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
f. contacts.cfgcontactgroup.cfg文件,默认不存在,需手动创建!
contacts.cfg是一个定义联系人和联系人组的配置文件,当监控的主机或者服务出现故障,nagios会通过指定的通知方式(邮件或者短信)将信息发给这里指定的联系人或者使用者。contactgroup.cfg定义联系人组的配置文件,注意:members选项里面的联系人在contacts.cfg里面要要定义,多个联系从之间用逗号隔开。
contacts.cfg下面的配置文档
definecontact{
contact_name   echo   ; Short name of user
use    generic-contact  ; Inheritdefault values from generic-contact template (defined above)
alias    linux contact  ; Full name of user


email    test1@163.com  ;

运维网声明 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-663134-1-1.html 上篇帖子: Linux下Nagios的安装与配置<< 一 >> 下篇帖子: 检查指定进程内存使用情况的nagios脚本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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