Automatic Installation of Nagios server and client using shell scripts

Source: Internet
Author: User
A company's project website was launched for a few days because the disk was full and there was a problem. Because its servers were concentrated in a certain IDC, we considered deploying a Nagios monitoring and alarm system, since other project websites may have similar requirements, the installation process should be compiled into scripts to facilitate future work. The automatic installation script of the Nagios server is as follows (this script is used in Centos5.5 | 5.6 | 5.8x86 _ 64): A project website of yum-yinstal, A problem occurs when the disk is full in just a few days after the launch. Because the servers are concentrated in a data center, you need to deploy a Nagios monitoring alarm system, since other project websites may have similar requirements, the installation process should be compiled into scripts to facilitate future work. The automatic Nagios Server installation script is as follows (this script is used in centos 5.5 | 5.6 | 5.8 x86_64 ): yum-y install httpd gcc-c ++ glibc-common gd-devel
Useradd nagios
Groupadd nagcmd
Usermod-G nagcmd nagios
Usermod-G nagcmd apache

Cd/usr/local/src
Wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
Wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
Wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
Tar zxvf nagios-3.0.6.tar.gz
Cd nagios-3.0.6
./Configure -- with-command-group = nagcmd -- prefix =/usr/local/nagios
Make all
Make install
Make install-init
Make install-config
Make install-commandmode
Make install-webconf
Cd ../
Tar zxvf nagios-plugins-1.4.13.tar.gz
Cd nagios-plugins-1.4.13
./Configure -- prefix =/usr/local/nagios -- with-nagios-user = nagios -- with-nagios-group = nagios
Make & make install
Cd ../
Tar zxvf nrpe-2.13.tar.gz
Cd nrpe-2.13
./Configure
Make all
Make install-plugin
Make install-daemon
Make install-daemon-config

Htpasswd-bc/usr/local/nagios/etc/htpasswd. users nagiosadmin nagiosadmin101
Echo "alias nagioscheck = '/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg'">/root/. bashrc
Source/root/. bashrc

Chkconfig nagios on
Chkconfig httpd on
Service httpd start
Service nagios start
# The Basic installation process will not be repeated here. The htpasswd-bc line of code is used to generate an angiosadmin user named nagiosadmin101 without human intervention, later, because/usr/local/nagios/etc/nagios is frequently modified. cfg configuration file, so you need to check its syntax, so the long command is used to generate an alias command named nagioscheck.
The automatic Nagios Client installation script is as follows: useradd nagios
Cd/usr/local/src
Wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
Wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz

Tar zxvf nagios-plugins-1.4.13.tar.gz
Cd nagios-plugins-1.4.13
./Configure
Make
Make install
Chown nagios: nagios/usr/local/nagios
Chown-R nagios: nagios/usr/local/nagios/libexec
Cd ../
Tar zxvf nrpe-2.13.tar.gz
Cd nrpe-2.13
./Configure
Make all
Make install-plugin
Make install-daemon
Make install-daemon-config

Sed-I's @ allowed_hosts = 127.0.0.1 @ allowed_hosts = 114.112.11.11 @ '/usr/local/nagios/etc/nrpe. cfg

/Usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d
Echo "/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d ">/etc/rc. local # allowed_hosts this line replaces the original 127.0.0.1 with the current server address 114.112.11.11 (which has been harmless). You can consider whether to add this line of code based on your actual needs, the next step is to debug the Nagios server. The specific process is skipped here.
In fact, before the machine enters the IDC, client software such as nagios and puppet should be deployed and installed on each online machine, before the machine goes online, it must first focus on Kickstart in the local area network and then initialize it. At this time, the network is stable and debugging is convenient. Therefore, it is convenient and effort-saving to use puppet automatic maintenance, this prevents remote maintenance and installation after the machine goes online, which consumes manpower and increases machine risks.
Note: many of my friends write their own SHELL scripts as the Nagios plug-in to supplement MySQL master-slave synchronization. In fact, Nagios has its own check_mysql and check_mysql_health plug-ins, because check_mysql often reports "segment errors" during deployment, check_mysql_health is mainly used at present, because we do not only monitor the SQL and IO processes on the machine, but more importantly, we need to monitor the latency of the slave.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.