Nagios on Debian 9 - fourslick/notes GitHub Wiki
apt-get install -y fcgiwrap
systemctl enable fcgiwrap.socket
systemctl start fcgiwrap.socket
apt install -y build-essential autoconf gcc libc6 make wget unzip libgd-dev
wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.2.tar.gz
tar zxvf nagios-4.4.2.tar.gz
./configure
make all
make install-groups-users
usermod -a -G nagios www-data
make install
make install-config
make install-init
make install-commandmode
apt-get -y install apache2-utils
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
apt install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
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
location /nagios {
alias /usr/local/nagios/share;
allow all;
auth_basic "Private";
auth_basic_user_file /usr/local/nagios/etc/htpasswd.users;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ \.cgi$ {
root /usr/local/nagios/sbin;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}
mkdir /usr/local/nagios/etc/devices
nano /usr/local/nagios/etc/nagios.cfg
add this configuration
cfg_dir=/usr/local/nagios/etc/devices
cfg_file=/usr/local/nagios/etc/objects/aliensky.cfg
#########################################################################################################
#
# TEMPLATES
#
#########################################################################################################
define contact {
name aliensky-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
service_notification_commands notify-service-by-telegram ; send service notifications via telegram
service_notifications_enabled 1
host_notification_period 24x7 ; host notifications can be sent anytime
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
host_notification_commands notify-host-by-telegram ; send host notifications via telegram
host_notifications_enabled 1
register 0 ; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}
define host {
name aliensky-device ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 1 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period 24x7 ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 15 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups aliensky-admins ; Notifications get sent to the admins by default
register 0 ; DON'T REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
##############################################################################
#
# CONTACT
#
##############################################################################
define contact {
contact_name fourslick
use aliensky-contact
pager -1001303106339
}
define contactgroup {
contactgroup_name aliensky-admins
alias Aliensky Administrators
members fourslick
}
################################################################################
#
# COMMANDS
#
################################################################################
define command {
command_name notify-host-by-telegram
command_line /usr/local/nagios/py/telegram_nagios.py --token xxxxxxxxx:AAFZErAnG3zjMgSBBGSOs_4webckYqaJTZo --object_type host --contact "$CONTACTPAGER$" --notificationtype "$NOTIFICATIONTYPE$" --hoststate "$HOSTSTATE$" --hostname "$HOSTNAME$" --hostaddress "$HOSTADDRESS$" --output "$HOSTOUTPUT$"
}
define command {
command_name notify-service-by-telegram
command_line /usr/local/nagios/py/telegram_nagios.py --token xxxxxxxxx:AAFZErAnG3zjMgSBBGSOs_4webckYqaJTZo --object_type service --contact "$CONTACTPAGER$" --notificationtype "$NOTIFICATIONTYPE$" --servicestate "$SERVICESTATE$" --hostname "$HOSTNAME$" --servicedesc "$SERVICEDESC$" --output "$SERVICEOUTPUT$"
}