Jeżeli potrzebujesz oprogramowania do monitorowania sieci, wspaniałym rozwiązaniem jest Nagios, poniżej krok po kroku jak go zainstalować:
1.Instalacja Apache2 + PHP (Pomiń, jeżeli już posiadasz):
apt-get install apache2 libapache2-mod-php7.0 php7.0 # włącz cgi a2enmod rewrite headers cgi systemctl restart apache2 # ustaw poprawną strefę czasową in php mcedit /etc/php/7.0/apache2/php.ini # ustaw date.timezone zgodnie z http://php.net/manual/en/timezones.php systemctl restart apache2 # info.php echo '<?php phpinfo(); ?>' >/var/www/html/info.php # otwórz preglądarkę i wejdź na apache_server_ip/info.php następnie sprawdź 'default timezone'
2.Instalacja Nagios core:
# przygotowanie do kompilacji:
apt-get install autoconf gcc libc6 make apache2-utils libgd-dev
# ściągnij źródło z https://www.nagios.org/downloads/nagios-core/
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
tar xzf nagios-4.3.4.tar.gz
cd nagios-4.3.4/
./configure --with-httpd-conf=/etc/apache2/sites-enabled
# W rezultacie powinniśmy zobaczyć coś takiego:
*** Configuration summary for nagios 4.3.4 2017-08-24 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: /run/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/apache2/sites-enabled
Mail program: /usr/bin/mail
Host OS: linux-gnu
IOBroker Method: epoll
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /usr/sbin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
##################
# następnie uruchamiamy 'make' ;-)
make all
# Rezultat make powinien wyglądać tak:
Enjoy.
# stwórzmy użytkownika nagios
useradd nagios
# dodajmy go do grupy apacha (najczęściej www-data)
usermod -a -G nagios www-data
# na koniec 'przeprowadź instalację'
make install
# Na zakończenie zobaczymy:
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/archives
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/spool/checkresults
chmod g+s /usr/local/nagios/var/spool/checkresults
*** Main program, CGIs and HTML files installed ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-init
- This installs the init script in /etc/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs sample config files in /usr/local/nagios/etc
##############
# stwórzmy init script
make install-init
# włączmy init script
systemctl enable nagios.service
# utwórzmy i ustawmy odpowiednie prawa dla komend:
make install-commandmode
# dodajmy przykładowy konfig, żeby Nagios wystartował:
make install-config
# dodajmy ustawienia nagiosa dla apacha:
make install-webconf
# stwórzmy konto administratora nagiosa
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# szybki restart apacha i odpalenie nagiosa:
systemctl restart apache2
systemctl start nagios
# otwórz przeglądarke i wejdź na: nagios_adres_ip/nagios/
3.Instalacja Nagios Plugins (potrzebne, nie ignoruj !)
# pre-require apt-get install libmcrypt-dev make libssl-dev bc gawk dc build-essential snmp libnet-snmp-perl gettext libldap2-dev smbclient fping default-libmysqlclient-dev # pobierz źródła z https://github.com/nagios-plugins/nagios-plugins/releases wget https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz tar zxvf release-2.2.1.tar.gz cd nagios-plugins-release-2.2.1/ ./tools/setup ./configure make make install # wszystkie komendy zainstalują się tutaj: /usr/local/nagios/libexec/ ls /usr/local/nagios/libexec/ # zrestatujmy nagiosa, żeby wczytał wtyczki: systemctl restart nagios.service
4.Włączanie SSL dla Nagios-a (i nie tylko)
# włącz moduł
a2enmod ssl
systemctl restart apache2
# przekieruj ruch http do ssl-a
mcedit /etc/apache2/sites-enabled/000-default.conf
# do VirtualHost dodaj:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}/$1
# po modyfikacji plik wygląd tak:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}/$1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# włączmy plik konfiguracyjny, bez niego będziemy wiedzieć SSL_ERROR_RX_RECORD_TOO_LONG error
a2ensite default-ssl.conf
# szybki restart apache
systemctl restart apache2.service