sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail unzip
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd www-data
cd /home/jxyu
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
tar -xzf nagios-4.3.4.tar.gz
ll
cd nagios-4.3.4
./configure --with-nagios-group=nagios --with-command-group=nagcmd
make all
make install
make install-commandmode
make install-init
make install-config
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
cd /home/jxyu/
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -xzf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
make
make install
vim /usr/local/nagios/etc/nagios.cfg
mkdir -p /usr/local/nagios/etc/servers
a2enmod rewrite
a2enmod cgi
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/
service apache2 restart
service nagios start
nagios start
nagios3 start
/usr/local/nagios/bin/nagios start
cd /etc/init.d/
cp /etc/init.d/skeleton /etc/init.d/nagios
vim /etc/init.d/nagios
chmod +x /etc/init.d/nagios
service apache2 restart
servuce nagios start
service nagios start
systemctl daemon-reload
service nagios start
ifconfig
apt install npre
apt-cache search npre
apt-cache search nrpe
apt install nagios-nrpe-plugin nagios-nrpe-server -y
service nagios restart
service nagios stop
systemctl status nagios
systemctl start nagios
systemctl status nagios
vim /etc/nagios/nrpe.cfg
service nagios-nrpe-server restart
systemctl restart nagios
vim /usr/local/nagios/etc/servers/ubuntu_host.cfg
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios-nrpe-server restart
service apache2 restart
service nagios restart
# config:
# Ubuntu Host configuration file
define host {
use linux-server
host_name ubuntu_host
alias Ubuntu Host
address 127.0.0.1
register 1
}
define service {
host_name ubuntu_host
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check Users
check_command check_local_users!20!50
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Local Disk
check_command check_local_disk!20%!10%!/
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check SSH
check_command check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Total Process
check_command check_local_procs!250!400!RSZDT
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
# Check config
service nagios checkconfig