linux监控平台nagios的使用(四)监控端添加服务

被监控端工作已经做好了,现在就只要在监控端进行操作了;

注意一下:被监控中mysql记得要设密码啊

添加服务类型也是2种:

1.web服务器

2.mysql服务器

下面是添加web服务的脚本:

webservices () {
 read -p " Please input the web server IP: " webip
 read -p "please input the web alias name : "  host
 echo "define host{
         host_name                       $host
         alias                           web-server
         address                         $webip
         check_command                   check-host-alive
         max_check_attempts              5
         check_period                    24x7
         contact_groups                  web-server
         notification_interval           10
         notification_period             24x7
         notification_options            d,u,r
         }" >> /usr/local/nagios/etc/objects/hosts.cfg
 sed -i "6,10{/members/s/$/,$host/}" /usr/local/nagios/etc/objects/hostgroups.cfg    

 echo "
 define hostescalation{
                 host_name               $host
                 first_notification      5
                 last_notification       0
                 notification_interval   10
                 contact_groups          web-server
                 }
 define serviceescalation{
                 host_name               $host
                 service_description     Nginx-Listener
                 first_notification      5
                 last_notification       0
                 notification_interval   10
                 contact_groups          web-server
                 }
 define serviceescalation{
                 host_name               $host
                 service_description     Linux-PHP-procs
                 first_notification      5
                 last_notification       0
                 notification_interval   10
                 contact_groups          web-server
                 }
 define serviceescalation{
                 host_name               $host
                 service_description     Linux-iftraffic
                 first_notification      5
                 last_notification       0
                 notification_interval   10
                 contact_groups          web-server
                 }
 define serviceescalation{
                 host_name               $host
                 service_description     check-ips
                 first_notification      5
                 last_notification       0
                 notification_interval   10
                 contact_groups          web-server
                 } " >> /usr/local/nagios/etc/objects/escalations.cfg     

 echo "
     define service{
         host_name               $host
         service_description     check-host-alive
         check_command           check-host-alive
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     disk-/
         check_command           check_local_disk!10%!5%!/
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     SSH-Listener
         check_command           check_tcp!22
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Nginx-Listener
         check_command           check_tcp!80
         max_check_attempts      4
         normal_check_interval   2
         retry_check_interval    1
         check_period            24x7
         notification_interval   2
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-Memory
         check_command           check_nrpe!check_mem
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-load
         check_command           check_nrpe!check_load
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-total-procs
         check_command           check_nrpe!check_total_procs
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-PHP-procs
         check_command           check_nrpe!check_php_procs
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   5
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-CPU
         check_command           check_nrpe!check_cpu
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-user
         check_command           check_nrpe!check_users
         max_check_attempts      4
         normal_check_interval   3
         retry_check_interval    2
         check_period            24x7
         notification_interval   10
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     check-ips
         check_command           check_nrpe!check_ips
         max_check_attempts      4
         normal_check_interval   2
         retry_check_interval    2
         check_period            24x7
         notification_interval   8
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
      define service{
         host_name               $host
         service_description     Linux-iftraffic
         check_command           check_nrpe!check_iftraffic!"eth0"!50!100!50!m
         max_check_attempts      4
         normal_check_interval   4
         retry_check_interval    2
         check_period            24x7
         notification_interval   5
         notification_period     24x7
         notification_options    w,u,c,r
         contact_groups          web-server
         }
 " >> /usr/local/nagios/etc/objects/services.cfg
 echo "###############  Add web-server services completed ########" 

 }

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索notification
, checked
, check
, attempting
, Interval
, notifications
Notification用法
nagios监控linux主机、nagios 监控linux、nagios监控linux内存、nagios监控远程linux、nagios添加监控主机,以便于您获取更多的相关知识。

时间: 2024-07-30 10:02:53

linux监控平台nagios的使用(四)监控端添加服务的相关文章

建设DevOps统一运维监控平台,全面的系统监控你做好了吗?

随着Devops.云计算.微服务.容器等理念的逐步落地和大力发展,机器越来越多,应用越来越多,服务越来越微,应用运行基础环境越来多样化,容器.虚拟机.物理机不一而足.面对动辄几百上千个虚拟机.容器,数十种要监控的对象,现有的监控系统还能否支撑的住?来自于容器.虚拟机.物理机.网络设备.中间件的指标数据如何采用同一套方案快速.完整的收集和分析告警?怎样的架构.技术方案才更适合如此庞大繁杂的监控需求呢 一.统一监控平台架构解析 先做一下回顾,统一监控平台由七大角色构成:监控源.数据采集.数据存储.数

linux监控平台nagios的使用(三)被监控端的环境部署

这次被监控主要有2种: 1.web服务器 2.mysql服务器 所以得先保证nginx/apache 或者mysql服务的启动: 下面是mysql监控端部署的函数installmysql () 脚本如下 installmysql () { yum install xinetd -y service xinetd start cd $path useradd -s /sbin/nologin nagios tar -zxvf nagios-plugins-1.4.14.tar.gz cd nagi

linux监控平台nagios的使用(二)监控端环境部署

这个只是总体脚本中的监控端的一个函数 installserver () 具体脚本如下: #!/bin/bash #this is nagios server or client install shell #at 2012/10/29 path=`pwd` httppath=/usr/local/apache2 mysqlpath=/usr/local/mysql nagiospath=/usr/local/nagios installserver () { yum install -y xin

linux监控平台nagios的使用(一)lamp环境

环境OS:centos 5.8 x86_64 这次脚本比上篇有些许修改,脚本如下 #mkdir /etc/yum.repos.d/backup #mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ #mv /tmp/lamp/ftp.repo /etc/yum.repos.d/ #yum clean all #yum makecache path=`pwd` yum -y install gcc gcc-c++ screen autoconf

linux监控平台nagios的使用(五)使用以及相关说明

使用及相关如下: 使用脚本如下配套之前的函数: addservices () { echo "you can add services for web-server or mysql-server " echo "1,web-server" echo "2,mysql-server" echo "3,exit" read abc case $abc in 1) webservices ;; 2) echo "you

轻松监控上万台服务器:企业运维监控平台架构设计与实践指南

一.Cacti/Nagios/Zabbix/centreon/Ganglia之抉择  1.cacti   Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具.   简单的说Cacti 就是一个PHP 程序.它通过使用SNMP 协议获取远端网络设备和相关信息,(其实就是使用Net-SNMP软件包的snmpget 和snmpwalk 命令获取)并通过RRDTOOL 工具绘图,通过PHP 程序展现出来.我们使用它可以展现出监控对象一段时间内的状态或者性能趋势

Centos下构建Nagios监控平台提示无权限访问nagios

今天在搭建Nagios监控平台时,发现正常配置完成后,首先无法打开apache默认页面,其次报"You don' t have permission to access /nagios/ on this server",由于刚刚开始搞Linux ,也不是太熟悉,而且 Nagios也是刚开始学习怎么搭,所以在搭建时有时经常会遇到莫名其妙的问题,但是当时非常奇怪,和之前的 两个监控平台的配置和安装方法一样,怎么会报这种错误呢? 没办法,推倒重新搭整个服务器?好像 这个不是个好方法,最好的方

用python和redis构建高性能监控平台思路与框架升级过程

关于python应用监控平台的话题 先说明,这不是人人业务的监控框架,是我在上一家公司,我所在部门的监控框架... 刚入行的时候,对于监控方面,用的是nagios和cacti. 两个都很强大的监控平台,可扩展性也都很不错.要是想用一个平台实现报警和性能信息的展示的话,他俩都需要加点东西.两个的合体可以考虑zabbix.操作和理解都挺简单的.唯一让人不爽的是存在myql里面,国外有个老外可以改到我钟爱的mongodb里面,但是我看不懂,也没有操作成功... php  这个真不会... 后来到了大公

大众点评开源分布式监控平台 CAT 深度剖析

一.CAT介绍 CAT系统原型和理念来源于eBay的CAL的系统,CAT系统第一代设计者吴其敏在eBay工作长达十几年,对CAL系统有深刻的理解.CAT不仅增强了CAL系统核心模型,还添加了更丰富的报表.自2014年开源以来,CAT在携程.陆金所.猎聘网.找钢网等多家互联网公司生产环境应用. CAT是一个实时和接近全量的监控系统,它侧重于对Java应用的监控,基本接入了美团点评上海侧所有核心应用.目前在中间件(MVC.RPC.数据库.缓存等)框架中得到广泛应用,为美团点评各业务线提供系统的性能指