1、nagios图形监控显示和报警管理nagios图形监控显示和报警管理服务端1、 yum安装pnp软件需要基础包图形依赖库yuminstallcairopangozlibzlib-develfreetypefreetype-develgdgd-devel-y2、 rrdtools依赖安装 软件都在oldboy_training_nagios_soft.zipcd /toolstarxflibart_lgpl-2.3.17.tar.gzcdlibart_lgpl-2.3.17./configuremakemakeinstall/bin/cp-r/usr/local/include/libart-2
2、.0/usr/includecd./ 3、安装rrdtool软件 轮循数据库,专门画图tarxfrrdtool-1.2.14.tar.gzcdrrdtool-1.2.14./configure-prefix=/usr/local/rrdtool-disable-python-disable-tcl#WARNING:TheRRDsPerlModulesarenotfoundonyourSystem#UsingRRDswillspeedupthingsinlargerInstalltions.#configure后出现上面的提示可以不用理会。makemakeinstallcd./ls-l/usr/
3、local/rrdtool/bin 4、安装pnp pnp收集数据给rrdtool画图 rrdtool画完再给pnp展示tarzxfpnp-0.4.14.tar.gzcdpnp-0.4.14./configure-with-rrdtool=/usr/local/rrdtool/bin/rrdtool#=真正的出图的命令-with-perfdata-dir=/usr/local/nagios/share/perfdata/#=出图所用的数据路径#WARNING:TheRRDsPerlModulesarenotfoundonyourSystem#UsingRRDswillspeedupthings
4、inlargerInstalltions.#makeallmakeinstallmakeinstall-configmakeinstall-initll/usr/local/nagios/libexec/|grepprocess 排错的:tarzxfpnp-0.4.14.tar.gzcdpnp-0.4.14./configure-with-rrdtool=/usr/local/rrdtool/bin/rrdtool-with-perfdata-dir=/usr/local/nagios/share/perfdata/#WARNING:TheRRDsPerlModulesarenotfoundo
5、nyourSystem#UsingRRDswillspeedupthingsinlargerInstalltions.#makeallmakeinstallmakeinstall-configmakeinstall-initll/usr/local/nagios/libexec/|grepprocess问题:configure报错checkingforlinkerflagsforloadablemodules.-sharedcheckingforPerlModuleTime:HiRes.noconfigure:error:PerlModuleTime:HiResnotavailable解决:y
6、uminstallperl-Time-HiResy(一般不会发生)5、cd /usr/local/nagios/etc/cp nagios.cfg nagios.cfg.orivi nagios.cfg +835833process_performance_data=1834835836837#HOSTANDSERVICEPERFORMANCEDATAPROCESSINGCOMMANDS838#Thesecommandsarerunaftereveryhostandservicecheckis839#performed.Thesecommandsareexecutedonlyifthe840#
7、enable_performance_dataoption(above)issetto1.Thecommand841#argumentistheshortnameofacommanddefinitionthatyou842#defineinyourhostconfigurationfile.ReadtheHTMLdocsfor843#moreinformationonperformancedata.844845host_perfdata_command=process-host-perfdata #取消注释846service_perfdata_command=process-service-
8、perfdata 删除之前的内容删除两个命令定义:process-host-perfdata、process-service-perfdata添加如下 #process-host-perfdatacommanddefinitiondefinecommandcommand_nameprocess-host-perfdatacommand_line/usr/local/nagios/libexec/process_perfdata.pl#process-service-perfdatacommanddefinitiondefinecommandcommand_nameprocess-service
9、-perfdatacommand_line/usr/local/nagios/libexec/process_perfdata.pl 检查语法,重启服务/etc/init.d/nagios checkconfig/etc/init.d/nagios reload/etc/init.d/httpd start访问:http:/10.0.0.11/nagios/pnp/index.php 主机出图在vi hosts.cfg define host use linux-server host_name 204-zhuangjiajun alias 204-zhuangjiajun address 1
10、0.0.0.204 action_url /nagios/pnp/index.php?host=$HOSTNAME$ 也可以添加在模板vi templates.cfg搜索/linux-serverdefine host name linux-server ; The name of this host template check_period 24x7 ; By default, Linux hosts are checked round the clock check_interval 5 ; Actively check the host every 5 minutes retry_in
11、terval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each Linux host 10 times (max) check_command check-host-alive ; Default command to check Linux hosts notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day ; Note th
12、at the notification_period variable is being overridden from ; the value that is inherited from the generic-host template! notification_interval 120 ; Resend notifications every 2 hours notification_options d,u,r ; Only send notifications for specific host states contact_groups admins ; Notification
13、s get sent to the admins by default register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!action_url /nagios/pnp/index.php?host=$HOSTNAME$ 效果:服务出图vi services.cfgdefine service use generic-service host_name 204-zhuangjiajun service_description memory check_command check_nr
14、pe!check_memory.pl action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$同样也可以配置到模板vi templates.cfg搜索/servicedefine service name generic-service ; The name of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service chec
15、ks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) obsess_over_service 1 ; We should obsess over this service (if necessary) check_freshness 0 ; Default is to NOT check service freshness notifications_ena
16、bled 1 ; Service notifications are enabled event_handler_enabled 1 ; Service event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled failure_prediction_enabled 1 ; Failure prediction is enabled process_perf_data 1 ; Process performance data retain_status_information 1 ; Retain
17、status information across program restarts retain_nonstatus_information 1 ; Retain non-status information across program restarts is_volatile 0 ; The service is not volatile check_period 24x7 ; The service can be checked at any time of the day max_check_attempts 3 ; Re-check the service up to 3 time
18、s in order to determine its final (hard) state normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined contact_groups admins ; Notifications get sent out to everyone in
19、the admins group notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events notification_interval 60 ; Re-notify about service problems every hour notification_period 24x7 ; Notifications can be sent out at any time register 0 ; DONT REGISTER THIS DEFINIT
20、ION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$ 实现效果:nagios报警邮件报警邮件转短信短信网关 =老男孩推荐如果有值班 页面显示,由人打电话微信绑定邮箱对于不紧急的选择邮件报警,重要紧急的报警选择邮件+短信老男孩思想:花一定的费用,把业务做到最好,如果报警报不出来,损失更大重要报警思想该报的报出来,不该报的一点不要报出来配置报警步骤1、 开发短信报警脚本(短信网关需要收费的)rootoldboy-Alibexe
21、c#pwd/usr/local/nagios/libexecrootoldboy-Alibexec#catsms_send#!/bin/shPROGNAME=basename$0PROGPATH=echo$0|sed-es,/*$,print_usage()echoUsage:echo/bin/sh$PROGNAMEtitlecontactexit1if$#-ne2;thenprint_usagefialert_date=$(date+%y-%m-%d%H:%M)TITLE=$1#FORMATHost$HOSTSTATE$alertfor$HOSTNAME$CONTACT=$2#curl方式c
22、url-dcdkey=3RTY-EMY-0980-MTUQ2-dpassword=189162-dphone=$CONTACT-dmessage=$TITLE$alert_dateoldboysa#wget-quiethttp:/s.ccme.cc/qxt/send.jsp?circle=159net_131&pwd=oldboy123&mobile=18911718229&service=f1fb0546-ebb6-0987-8f20-560524c1f88d&msgid=3956724&message=$TITLE$alert_dateoldboysan 2、 添加联系人联系组contacts.cfg3、 添加报警的命令commands.cfg4、 调整联系人模板,添加报警的命令(来自于commands.cfg命令)(逗号,后面再加命令)5、 host.cfg,services.cfg添加报警联系人及组,或者对应模板加contact_groups admin,sa本周作业:1、 监控RAID,CPU温度2、 自定义插件出图3、 完成cacti部署,出图
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1