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
- Nagios and NSCA installation
- Nagios的插件-nsca
- nagios之nsca被动监控
- Gradient Descent and NSCA
- nagios的nsca被动模式及自动添加nsca服务
- nagios使用nsca实现被动监控
- 实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- Nagios Server端
- 实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- 被监控端
- Brif Nagios installation in Centos
- mod_dav Installation and Configuration
- Grub installation and configuration
- IC610 and MMSIM61 installation
- Installation Prerequisites and Guidelines
- EIBD installation and usage
- Owncloud, installation and setup
- Mininet overview and installation
- JSP installation and configuration
- imagemagick and zbar installation
- hdu 1558 并查集+计算几何
- 匈牙利算法
- 23设计模式之建造者模式(Builder)
- Android手机通用检测指令
- PHOTOSHOP 开发脚本初入 批量修改文字样式
- Nagios and NSCA installation
- 23设计模式之解释器模式(Interpreter)
- C++类的构造函数、析构函数
- LRUCache原理及HashMap LinkedHashMap内部实现原理
- HashMap Hashtable区别
- 23设计模式之命令模式(Command)
- ScrollView嵌套ListView只显示一行解决方案
- 关于Java多线程Thread的join用法
- 搭建ionic环境创建新的工程