Nagios and NSCA installation

来源:互联网 发布:学软件软件好的学校 编辑:程序博客网 时间:2024/05/17 01:45


(一) Nagios installation guide0. Prerequisites    https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-fedora.htmlDuring portions of the installation you'll need to have root access to your machine. Make sure you've installed the following packages before continuing. -Apache-PHP-GCC compiler-GD development libraries  -Apacheyum install httpd -PHPyum install php-GCC compileryum install gcc glibc glibc-common-GD development librariesyum install gd gd-devel1. Download Nagios   1) Create Account Information Become the root user. su -lCreate a new nagios user account and give it a password. /usr/sbin/useradd -m nagiospasswd nagiosCreate a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group. /usr/sbin/groupadd nagcmd/usr/sbin/usermod -a -G nagcmd nagios/usr/sbin/usermod -a -G nagcmd apache2) Download Nagios and the Plugins wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.1.1/nagios-4.1.1.tar.gzwget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz 3) Compile and Install Nagios Extract the Nagios source code tarball.  tar xzvf  nagios-4.1.1.tar.gzcd nagios-4.1.1./configuremake all Install binaries, init script, sample config files and set permissions on the external command directory. sudo make installsudo make install-initsudo make install-configsudo make install-commandmodeDon't start Nagios yet - there's still more that needs to be done... 4) Customize Configuration Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed... Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts. vi /usr/local/nagios/etc/objects/contacts.cfg5) Configure the Web Interface Install the Nagios web config file in the Apache conf.d directory. make install-webconfCreate a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later. htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadminRestart Apache to make the new settings take effect. service httpd restartNote Note: Consider implementing the ehanced CGI security measures described here to ensure that your web authentication credentials are not compromised. 6) Compile and Install the Nagios Plugins Extract the Nagios plugins source code tarball. tar xzvf nagios-plugins-2.1.1.tar.gzcd nagios-plugins-2.1.1Compile and install the plugins. ./configure --with-nagios-user=nagios --with-nagios-group=nagiosmakesudo make install7) Start Nagios Add Nagios to the list of system services and have it automatically start when the system boots. chkconfig --add nagioschkconfig nagios onVerify the sample Nagios configuration files. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgIf there are no errors, start Nagios. service nagios start8) Modify SELinux Settings Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs. See if SELinux is in Enforcing mode. getenforcePut SELinux into Permissive mode. setenforce 0To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot. Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode: chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/chcon -R -t httpd_sys_content_t /usr/local/nagios/share/For information on running the Nagios CGIs under Enforcing mode with a targeted policy, visit the Nagios Support Portal or Nagios Community Wiki. 9) Login to the Web Interface You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier. http://localhost/nagios/Click on the "Service Detail" navbar link to see details of what's being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time. 10) Other Modifications Make sure your machine's firewall rules are configured to allow access to the web server if you want to access the Nagios interface remotely. Configuring email notifications is out of the scope of this documentation. While Nagios is currently configured to send you email notifications, your system may not yet have a mail program properly installed or configured. Refer to your system documentation, search the web, or look to the Nagios Support Portal or Nagios Community Wiki for specific instructions on configuring your system to send email messages to external addresses. More information on notifications can be found here. 11) You're Done Congratulations! You sucessfully installed Nagios. Your journey into monitoring is just beginning. You'll no doubt want to monitor more than just your local machine, so check out the following docs... (二)Nagios and NSCA (Network topology)Remote Host:Monitored  Client with send_nscaMonitoring Host: Monitor  Server with nscaNagios  : central server on Monitoring HostNsca: server side of NSCA on Mointoring Host Send_nsca: client side to send information to NSCA _____________________             ____________________________________|                     |         |                                    ||  Nagios  <---   Nsca|  <------  |    Send_nsca <--- program/script   ||_____________________|           |____________________________________|         Monitoring Host                    Remote Host(三) NSCA plugin   --NSCA plugin should be downloaded and compiled on both Monitoring Host and Remote Host1)download NSCA wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz2)Compile and Install NSCA  tar xzvf nsca-2.7.2.tar.gz  cd nsca-2.7.2  ./configure   make all  --generated executable binary(nsca and send_nsca) can be found under src directory  ------------------$ lsaclocal.m4  config.guess  config.status  configure     include      init-script.in  LEGAL     Makefile.in  nsca_tests  sample-config  src    subst.inChangelog   config.log    config.sub     configure.in  init-script  install-sh      Makefile  nsca.spec    README      SECURITY       subst  update-version$ ls srcMakefile  Makefile.in  netutils.c  nsca  nsca.c  send_nsca  send_nsca.c  utils.c  -------------------(四)Nagios and NSCA (Server Side)0)Copy NSCA to Nagios bin directory and modify configurations cd nsca-2.7.2 sudo cp src/nsca  /usr/local/nagios/bin sudo cp sample-config/nsca.cfg /usr/local/nagios/etc  --modify NSCA configuration  vi /usr/local/nagios/et/nsca.cfg    ...  server_address=192.168.200.100  password=hello123  debug=1  ...   --change the owner of nsca and nsca.cfg   sudo chown nagios:nagcmd /usr/local/nagios/etc/nsca   sudo chown nagios:nagcmd /usr/local/nagios/bin/nsca.cfg   --add as service   cd nsca-2.7.2    sudo cp init-script /etc/init.d/nsca   sudo chmod a+x /etc/init.d/nsca1)Modify Nagios configuration  cd /usr/local/nagios/etc  --make sure the following options are set to nagios.cfg:  check_external_commands=1   accept_passive_service_checks=1  ...2)Modify Nagios templates  cd /usr/local/nagios/etc/objects  --add the following service to templates.cfg: define service{name                        passive_serviceuse                         generic-servicemax_check_attempts          1       active_checks_enabled       0  passive_checks_enabled      1  normal_check_interval       5  retry_check_interval        1notifications_enabled       1notification_interval       5notification_period         24x7notification_options        w,u,c,rcontact_groups              adminsregister                    0   }--notification_options----------------------------------------------host_notification_options:d = notify on DOWN host states,u = notify on UNREACHABLE host statesr = notify on host recoveries (UP states)f = notify when the host starts and stops flappings = send notifications when host or service scheduled downtime starts and endsn (none) as an option, the contact will not receive any type of host notifications.service_notification_options:w = notify on WARNING service statesu = notify on UNKNOWN service statesc = notify on CRITICAL service statesr = notify on service recoveries (OK states)f = notify when the service starts and stops flappingn (none) as an option, the contact will not receive any type of service notifications.常用的设置host_notification_options:d,u,rservice_notification_options:w,u,c,r--contact_groups-----------------------------------------------  contact_groups should be defined in /usr/local/nagios/etc/objects/contacts.cfg3)Add Nagios command  cd /usr/local/nagios/etc/objects  --add the following command to commands.cfg:define command{command_name    check_dummycommand_line    /usr/local/nagios/libexec/check_dummy $ARG1$}  --about check_dummy  -- check_dummy can only support 4 parameters$ sudo /usr/local/nagios/libexec/check_dummy 0OK$ sudo /usr/local/nagios/libexec/check_dummy 1WARNING$ sudo /usr/local/nagios/libexec/check_dummy 2CRITICAL$ sudo /usr/local/nagios/libexec/check_dummy 3UNKNOWN$ sudo /usr/local/nagios/libexec/check_dummy 4UNKNOWN: Status 4 is not a supported error state$ sudo /usr/local/nagios/libexec/check_dummy 5UNKNOWN: Status 5 is not a supported error state$ 4) define a local passive service:  cd /usr/local/nagios/etc/objects  --add the following service to templates.cfg: define service{use                             passive_servicehost_name                       localhostservice_description             CheckDummycheck_command                   check_dummy!0notifications_enabled           1}5) validate Nagios configuration    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg6) start Nagios and NSCA   --if Nagios or NSCA started before ,stop them first and then start   sudo service nagios  start   sudo service nsca start(五)Nagios and NSCA (Client Side)1)download NSCA wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz2)Compile and Install NSCA  tar xzvf nsca-2.7.2.tar.gz  cd nsca-2.7.2  ./configure   make all  --generated executable binary(nsca and send_nsca) can be found under src directory  ------------------$ lsaclocal.m4  config.guess  config.status  configure     include      init-script.in  LEGAL     Makefile.in  nsca_tests  sample-config  src    subst.inChangelog   config.log    config.sub     configure.in  init-script  install-sh      Makefile  nsca.spec    README      SECURITY       subst  update-version$ ls srcMakefile  Makefile.in  netutils.c  nsca  nsca.c  send_nsca  send_nsca.c  utils.c  -------------------1)setup send_nsca and modify configurations cd nsca-2.7.2 --modify send_nsca configuration   vi /usr/local/nagios/et/send_nsca.cfg   ...  password=hello123 ...2) test Nagios passive monitor   cd nsca-2.7.2   --execute following command   echo "localhost;CheckDummy;0;testOK"|./src/send_nsca -H 192.168.110.233 -d ";" -c /tmp/nsca-2.7.2/sample-config/send_nsca.cfg     while:   localhost:   host name configured for NSCA daemon   CheckDummy:  service name for NSCA passive mode   0: state. 0 means OK   testOK: additonal information   -H: server_address in NSCA configuration   -d: seperator character. default is TAB key   -c: configuration file name used by send_nsca   --alternative test:   you can edit a file, for example test.txt, has one line text with the format as below:   localhost[TAB]CheckDummy[TAB]0[TAB]testOK./src/send_nsca -H 192.168.110.233 -d ";" -c /tmp/nsca-2.7.2/sample-config/send_nsca.cfg  < test.txt Reference: (1)https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-fedora.html(2)https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/passivechecks.html(3)http://www.ibm.com/developerworks/cn/linux/1309_luojun_nagios/index.html(4)http://blog.csdn.net/heianemo/article/details/8289840(5)http://blog.csdn.net/u012375924/article/details/44851773 

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 被心机婊陷害了怎么办 分手了还被骚扰怎么办 苹果手机屏幕出现冷暖屏怎么办 我感觉媳妇不漂亮怎么办 90后赚不到钱怎么办 处对象感觉好累怎么办 谈朋友感觉好累怎么办 家庭条件不好娶老婆难办怎么办? 异地恋闹矛盾了怎么办 有人威胁要杀我全家怎么办 分手了借我的钱怎么办 脸打架打肿了怎么办 人家不加我qq好友怎么办 一个好友被删了怎么办 dnf脸黑怎么办还有办法 我想登别人微信怎么办 昌硕工资没到怎么办 昌硕离职不批怎么办 昌硕工资不到卡怎么办 上海人去苏州工作社保怎么办 娶个个脾气暴躁的媳妇怎么办 满脸的黑头痘痘怎么办 脚底磨起泡不敢走路怎么办 老婆老是找异性朋友怎么办 喜欢的人有对象怎么办 遇到了更喜欢的怎么办 8岁骨龄11岁怎么办啊 13岁初中生有思想不听话怎么办 交朋友找对象喜欢颜值高的怎么办 儿子找对象不听父母怎么办 缺爱怎么办的搞笑回答 对象说有人追她怎么办 说了一句话媳妇非常生气怎么办 柔顺后头发太臭怎么办 积分兑换手机被骗了怎么办 老板对你的上级不满怎么办 如果老板不给工资怎么办 手机号码被标记为其他公司怎么办? 被标记为骚扰电话怎么办 手机被标记骚扰电话怎么办 360摄像头不支持5g怎么办