nagios监控安装配置文档+139邮箱报警
# vi /usr/local/nagios/etc/nagios.cfg
#cfg_file=/usr/local/nagios/etc/localhost.cfg //在前面加#
cfg_file=/usr/local/nagios/etc/contacts.cfg //联系人配置文件路径
cfg_file=/usr/local/nagios/etc/contactgroups.cfg //联系人组配置文件路径
cfg_file=/usr/local/nagios/etc/commands.cfg //命令配置文件路径
cfg_file=/usr/local/nagios/etc/hosts.cfg //主机配置文件路径
cfg_file=/usr/local/nagios/etc/hostgroups.cfg //服务器组配置文件
cfg_file=/usr/local/nagios/etc/templates.cfg //模板配置文件路径
cfg_file=/usr/local/nagios/etc/timeperiods.cfg //监视时段配置文件路径
cfg_file=/usr/local/nagios/etc/services.cfg //服务配置文件
define host{
host_name Nagios-Server#设置主机的名字,该名字会出现在hostgroups.cfg 和services.cfg中。alias Nagios Server #别名
address 192.168.18.20 #主机的IP 地址
check_command check-host-alive #检查的命令
check_interval 5 #检测的时间间隔
retry_interval 1 #检测失败后重试的时间间隔
max_check_attempts 5 #最大重试次数
check_period 24x7 #检测的时段
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup #联系组
notification_interval 30 #通知的时间间隔
notification_period 24x7 #通知的时间段
notification_options d,u,r #通知的选项
#w—报警(warning),u—未知(unkown)
#c—严重(critical),r—从异常情况恢复正常
define host{
host_name Nagios-Client
alias Nagios Client
address 192.168.18.40
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
define hostgroup {
hostgroup_name Nagios-Example #主机组名字
alias Nagios Example #主机组别名
members Nagios-Server,Nagios-Client #主机组成员,用逗号隔开
}
host_name Nagios-Server #主机名
check_period 24x7 #检测的时间段
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check-host-alive #调用的命令
}
define service {
host_name Nagios-Client
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check-host-alive
}
servicegroup_name Host-Alive
members Nagios-Server,check-host-alive,Nagios-Client,check-host-alive
}
contact_name nagiosadmin
use generic-contact
alias System Administrator
email nagios@localhost
}
define contactgroup{
contactgroup_name sagroup
alias Nagios Administrators
members nagiosadmin
}
command_name check_nrpe #用于远程监控的命令
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_/]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
4.4 修改Nagios 服务器服务定义文件
# vi /usr/local/nagios/etc/objects/services.cfg
添加服务
host_name Nagios-Client
service_description check-users
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_users
}
host_name Nagios-Client
service_description check-load
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_load
}
host_name Nagios-Client
service_description check-/
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_/
}
contact_name nagiosadmin
use generic-contact
alias System Administrator
email 138xxxxxxxx@139.com
mysql> flush privileges;
declare -a slave_is
slave_is=($(/usr/local/mysql/bin/mysql -unagios -pnagios -e "show slave status\G"|grep Running |awk '{print $2}'))
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]
then
echo "OK -slave is running"
exit 0
else
echo "Critical -slave is error"
exit 2
fi
host_name Nagios-db-slave230
service_description check_mysql_slave
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_mem
}
USAGE="`basename $0` [-w|--warning]<percent free> [-c|--critical]<percent free>"
THRESHOLD_USAGE="WARNING threshold must be greater than CRITICAL: `basename $0` $*"
calc=/tmp/memcalc
percent_free=/tmp/mempercent
critical=""
warning=""
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
# print usage
if [[ $# -lt 4 ]]
then
echo ""
echo "Wrong Syntax: `basename $0` $*"
echo ""
echo "Usage: $USAGE"
echo ""
exit 0
fi
# read input
while [[ $# -gt 0 ]]
do
case "$1" in
-w|--warning)
shift
warning=$1
;;
-c|--critical)
shift
critical=$1
;;
esac
shift
done
# verify input
if [[ $warning -eq $critical || $warning -lt $critical ]]
then
echo ""
echo "$THRESHOLD_USAGE"
echo ""
echo "Usage: $USAGE"
echo ""
exit 0
fi
# Total memory available
total=`free -m | head -2 |tail -1 |gawk '{print $2}'`
# Total memory used
used=`free -m | head -2 |tail -1 |gawk '{print $3}'`
# Calc total minus used
free=`free -m | head -2 |tail -1 |gawk '{print $2-$3}'`
# normal values
#echo "$total"MB total
#echo "$used"MB used
#echo "$free"MB free
# make it into % percent free = ((free mem / total mem) * 100)
echo "5" > $calc # decimal accuracy
echo "k" >> $calc # commit
echo "100" >> $calc # multiply
echo "$free" >> $calc # division integer
echo "$total" >> $calc # division integer
echo "/" >> $calc # division sign
echo "*" >> $calc # multiplication sign
echo "p" >> $calc # print
percent=`/usr/bin/dc $calc|/bin/sed 's/^\./0./'|/usr/bin/tr "." " "|/usr/bin/gawk {'print $1'}`
#percent1=`/usr/bin/dc $calc`
#echo "$percent1"
if [[ "$percent" -le $critical ]]
then
echo "CRITICAL - $free MB ($percent%) Free Memory"
exit 2
fi
if [[ "$percent" -le $warning ]]
then
echo "WARNING - $free MB ($percent%) Free Memory"
exit 1
fi
if [[ "$percent" -gt $warning ]]
then
echo "OK - $free MB ($percent%) Free Memory"
exit 0
fi
host_name Nagios-Client
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_mem.sh
}
转载于:https://blog.51cto.com/lidzh1109/831065
nagios监控安装配置文档+139邮箱报警相关推荐
- nagios配置文档
nagios配置文档 关于nagios Nagios是一款用于系统和网络监控的应用程序.它可以在你设定的条件下对主机和服务进行监控,在状态变差和 变好的时候给出告警信息. Nagios最初被设计为在 ...
- 监控系统安装配置文档(Nagios+Cacti+Nconf)
监控系统安装配置文档(Nagios+Cacti+Nconf) 一:Nagios环境的搭建 1.为以后的配置搭建安装环境 # yum install -y http* # yum install -y ...
- oracle12c配置文档,Oracle12C安装配置文档
Oracle12C安装配置文档 Oracle12C安装配置文档 准备软件: 开始安装: 打开从官网下载下来的两个压缩包,进行解压 打开解压好的后缀为2of2的文件夹 找到路径为database下的&q ...
- Java日志框架-Logback手册中文版以及官方配置文档教程
Logback手册中文版:(链接: https://pan.baidu.com/s/1bpMyasR 密码: 6u5c),虽然版本有点旧,但是大体意思差不多,先用中文版了解个大概,然后一切最新的配置以 ...
- Nginx配置文档具体解释
Nginx的配置文档具体解释.在这儿做个总结,以便以后使用的时间查看. 下面大部分自己整理.部分来自參考 #设置用户 #user nobody; #启动进程数(一般和server的CPU同样) #能 ...
- 我的Debian 8.0 (jessie)配置文档
2019独角兽企业重金招聘Python工程师标准>>> 我的Debian 8.0 (jessie)配置文档 1,添加软件源 su到root用户 vi /etc/apt/sou ...
- Postfix配置文档
环境:RedHat Linux+Postfix+Cyrus-sasl+Dovecot+Stunnel 在安装Linux时,如果选择全部安装的话,Postfix与Dovecot以及Stunnel将会自动 ...
- Linux keypad 设备树,SC7731客户配置文档.pdf
SC7731客户配置文档 SC7731 客户配置文档 2014-07-09 目录 02 Add your texts here SC7731 0101 03 SC7731 软件架构简介 02 Pinm ...
- Java代码规范、格式化和checkstyle检查配置文档
为便于规范各位开发人员代码.提高代码质量,研发中心需要启动代码评审机制.为了加快代码评审的速度,减少不必要的时间,可以加入一些代码评审的静态检查工具,另外需要为研发中心配置统一的编码模板和代码格式化模 ...
最新文章
- Java个人学生信息的录入_java录入学生信息
- 10gocm-gt;session3-gt;数据备份与恢复
- [HTML]HTML5实现可编辑表格
- C语言指针操作字符数组demo
- 1-2:学习shell之导航文件系统
- 一些算法竞赛参考书及豆瓣评分
- 2022-01-10总结
- apache cxf 测试webservice接口
- 第 7 章 Neutron - 069 - 理解 Neutron Server 分层模型
- 博科300 java配置,博科300 光纤交换机如何设置为SSH登录?
- Linux中将多块新硬盘合并成一个,挂载到/data目录下
- 用计算机分析卫星云图属于什么应用,卫星云图在天气分析及预报中的应用
- 用手机打开word图表位置很乱_word排版技巧:论文图表目录制作步骤
- Go的宕机与宕机恢复
- 文件宝局域网传输/播放功能Windows10系统经验贴(感谢文件宝用户@卡卡罗特 和@24K 純情)...
- Transferable Joint Attribute-Identity Deep Learning for Unsupervised Person Re-Identification阅读总结
- current sink/source, current mirror and current reference
- 极光推送 使用实例 (一)服务端
- 计算机办公应用考试,全国计算机信息技术考试办公软件应用模块(Windows XP)操作员级考试考试大纲...
- Python爬虫——下载PPT模板
热门文章
- 虚拟人,数字人,虚拟数字人的定义区别
- 【mac使用技巧】程序坞上的下载不见了该如何解决呢?
- 将本地文件上传到GitLab中,遇到The authenticity of host ‘gitlab.*.org (192.168.*.*)‘ can‘t be established.问题解决
- 芜湖市小学生c语言培训班,芜湖少儿学编程-地址-电话
- 网格员计算机应用基础知识,计算机应用基础(第3版)周南岳(win7office10)期末复习及答案.doc...
- Ocr识别之扫描笔应用
- Swift: iOS底层基础知识-文件目录结构
- 2022年最新二手华为手机价格表
- 【sdp】抓包查看RTP头扩展id
- 谈谈程序员如何快速提升职业技能