nagios配置出错记录
最近捣腾NAGIOS,不是特别顺利,应该说在网上找个说明基本照着做就差不多了,但是往往一些教程里面丢三落四,纰漏不少,导致难以达到预期的目的,现就几个小问题记录一下,以备忘。
1。pnp4nagios图形问题,点击小太阳图标出来的总不是想要的东西,仔细观察链接不对,再一研究发现是配置文件里面是错误的,应该是graph的地方写成了index.php。
2。检测频率问题。检测频率等于nagios.cfig文件里面interval_length的值和模板文件templates.cfg里面normal_check_interval的值的乘积,我将interval_length设为1 ,即1秒,normal_check_interval的值就可以根据需要自由定义了,需要检测频繁的就定义小一些,不需要频繁的可以定义大一些。
3。邮件报警问题,这个我是用sendmail来作为邮件服务器,看系统已经调用了报警,但是就是收不到邮件,用mail命令测试发送时绝对OK的,百思不得其解。昨天试了下还可以,今天又不行了。经过百度和GOOGLE,发现这个跟机器的域名或者主机名有一定关系,总是不稳定,不过自己写的备份脚本发邮件倒是一直OK。干脆找了个python脚本。
#!/usr/bin/python
#Script is Sendmail
#Version 1.0.2
#coding=utf-8
import smtplib
import string
import sys
import getopt
def usage():
print """sendmail is a send mail Plugins
Usage:
sendmail [-h|--help][-t|--to][-s|--subject][-m|--message]
Options:
--help|-h)
print sendmail help.
--to|-t)
Sets sendmail to email.
--subject|-s)
Sets the mail subject.
--message|-m)
Sets the mail body
Example:
./sendmail -t '[email protected]' -s 'hello eric' -m 'hello eric,this is sendmail test!'"""
sys.exit(3)
try:
options,args = getopt.getopt(sys.argv[1:],"ht:s:m:",["help","to=","subject=","message="])
except getopt.GetoptError:
usage()
for name,value in options:
if name in ("-h","--help"):
usage()
if name in ("-t","--to"):
# accept message user
TO = value
TO = TO.split(",")
if name in ("-s","--title"):
SUBJECT = value
if name in ("-m","--message"):
MESSAGE = value
MESSAGE = MESSAGE.split('\\n')
MESSAGE = '\n'.join(MESSAGE)
#smtp HOST
HOST = "smtp.xxx.com.cn"
#smtp port
PORT = "25"
#FROM mail user
USER = "[email protected]"
#FROM mail password
PASSWD = "******"
#FROM EMAIL
FROM = "[email protected]"
try:
BODY = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
"",
MESSAGE),"\r\n")
smtp = smtplib.SMTP()
smtp.connect(HOST,PORT)
smtp.login(USER,PASSWD)
smtp.sendmail(FROM,TO,BODY)
smtp.quit()
except:
print "UNKNOWN ERROR"
print "please look help"
print "./sendmail -h"