Instalasi Nagios Core pada Linux¶
Persiapan¶
# Persyaratan
yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
# Unduh Nagios
VERSI_NAGIOS_CORE="nagios-4.4.6"
REPO_NAGIOS_CORE="https://github.com/NagiosEnterprises/nagioscore"
TAUTAN_UNDUH_NAGIOS_CORE="$REPO_NAGIOS_CORE/archive/$VERSI_NAGIOS_CORE.tar.gz"
wget -O $VERSI_NAGIOS_CORE.tar.gz $TAUTAN_UNDUH_NAGIOS_CORE
tar xzf $VERSI_NAGIOS_CORE.tar.gz
# Kompilasi
cd nagioscore-$VERSI_NAGIOS_CORE/
./configure
make all
# Membuat pengguna dan grup
make install-groups-users
usermod -aG nagios apache
# Instal binari
make install
# Instal servis / daemon
make install-daemoninit
systemctl restart httpd
# Install Command Mode
make install-commandmode
# Install Configuration Files
make install-config
# Install Apache Config Files
make install-webconf
# Configure Firewall
firewall-cmd --zone=public --add-port=80/tcp --permanent
# Create nagiosadmin User Account
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# Restart Apache Web Server & Nagios
systemctl restart httpd nagios
Proses¶
Plugin
# Prerequisites
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
# Downloading The Source
VERSI_NAGIOS_PLUGINS="release-2.3.3"
REPO_NAGIOS_PLUGINS="https://github.com/nagios-plugins/nagios-plugins"
TAUTAN_UNDUH_NAGIOS_PLUGINS="$REPO_NAGIOS_PLUGINS/archive/$VERSI_NAGIOS_PLUGINS.tar.gz"
wget --no-check-certificate -O $VERSI_NAGIOS_PLUGINS.tar.gz $TAUTAN_UNDUH_NAGIOS_PLUGINS
tar zxf $VERSI_NAGIOS_PLUGINS.tar.gz
# Compile + Install
cd nagios-plugins-$VERSI_NAGIOS_PLUGINS
./tools/setup
./configure
make
make install
# Service / Daemon Commands
systemctl status nagios
systemctl restart nagios
Penyelesaian¶
cat << EOF >> nagios-cmdcgi.te
module nagios-cmdcgi 1.0;
require {
type httpd_sys_script_t;
type usr_t;
class fifo_file { getattr open read write };
}
#============= httpd_sys_script_t ==============
allow httpd_sys_script_t usr_t:fifo_file { getattr open read write };
EOF
#
checkmodule -m -M -o nagios-cmdcgi.mod nagios-cmdcgi.te
semodule_package --outfile nagios-cmdcgi.pp --module nagios-cmdcgi.mod
semodule -i nagios-cmdcgi.pp
#
NAGIOS_DIREKTORI="/usr/local/nagios"
#setsebool -P httpd_unified 1
matchpathcon -V $NAGIOS_DIREKTORI/*
restorecon -Rv $NAGIOS_DIREKTORI
#
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
#
systemctl restart httpd nagios
sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0