Naemon is a fast, stable, and flexible monitoring system based on the Nagios core. It provides enhanced performance, scalability, and modern features while maintaining compatibility with Nagios plugins and configurations.
| File/Directory | Path | Purpose |
|---|---|---|
| Main config | /etc/naemon/naemon.cfg |
Primary Naemon configuration |
| Objects dir | /etc/naemon/objects/ |
Object configuration files |
| Commands | /etc/naemon/objects/commands.cfg |
Check command definitions |
| Contacts | /etc/naemon/objects/contacts.cfg |
Contact definitions |
| Hosts | /etc/naemon/objects/hosts.cfg |
Host definitions |
| Services | /etc/naemon/objects/services.cfg |
Service definitions |
| Templates | /etc/naemon/objects/templates.cfg |
Object templates |
| Timeperiods | /etc/naemon/objects/timeperiods.cfg |
Time period definitions |
| Resource file | /etc/naemon/resource.cfg |
Macro definitions |
| CGI config | /etc/naemon/cgi.cfg |
CGI configuration |
| Modules | /etc/naemon/modules/ |
Loadable modules |
| Logs | /var/log/naemon/ |
Naemon log files |
| Spool dir | /var/spool/naemon/ |
Check result spool |
| PID file | /var/run/naemon/naemon.pid |
Process ID file |
| Status file | /var/cache/naemon/status.dat |
Status information |
# /etc/naemon/naemon.cfg
###############################################################################
# MAIN CONFIGURATION FILE
###############################################################################
# Log file
log_file=/var/log/naemon/naemon.log
# Logging options
log_rotation_method=d
log_rotation_time=0
log_max_size=1000000
use_syslog=1
log_notifications=1
log_service_retries=1
log_host_retries=1
log_event_handlers=1
log_initial_states=1
log_current_states=1
log_external_commands=1
log_passive_checks=1
# Debug logging (disable in production)
debug_file=/var/log/naemon/naemon.debug
debug_level=0
debug_verbosity=1
###############################################################################
# DIRECTORIES
###############################################################################
cfg_dir=/etc/naemon/objects
cfg_file=/etc/naemon/objects/commands.cfg
cfg_file=/etc/naemon/objects/contacts.cfg
cfg_file=/etc/naemon/objects/timeperiods.cfg
cfg_file=/etc/naemon/objects/templates.cfg
###############################################################################
# OBJECT CACHE FILE
###############################################################################
object_cache_file=/var/cache/naemon/objects.cache
precached_object_file=/var/cache/naemon/objects.precache
###############################################################################
# RESOURCE FILE
###############################################################################
resource_file=/etc/naemon/resource.cfg
###############################################################################
# STATUS FILE
###############################################################################
status_file=/var/cache/naemon/status.dat
status_update_interval=10
###############################################################################
# EXTERNAL COMMANDS
###############################################################################
check_external_commands=1
command_file=/var/cache/naemon/rw/naemon.cmd
command_check_interval=1s
###############################################################################
# EVENT BROKER
###############################################################################
broker_module=/usr/lib/naemon/ndomod.so config_file=/etc/naemon/ndomod.cfg
###############################################################################
# PERFORMANCE DATA
###############################################################################
service_perfdata_file=/var/log/naemon/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
host_perfdata_file=/var/log/naemon/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=30
###############################################################################
# CHECK SETTINGS
###############################################################################
check_result_reaper_frequency=10
max_check_result_reaper_time=30
check_result_path=/var/spool/naemon/checkresults
max_check_result_file_age=3600
###############################################################################
# HOST CHECK SETTINGS
###############################################################################
host_inter_check_delay=0.5
max_host_check_spread=30
host_check_timeout=30
retry_host_check_timeout=30
initial_host_check_delay=5
###############################################################################
# SERVICE CHECK SETTINGS
###############################################################################
service_inter_check_delay_method=s
max_service_check_spread=30
service_check_timeout=60
retry_service_check_timeout=30
service_interleave_factor=s
###############################################################################
# NOTIFICATION SETTINGS
###############################################################################
notification_timeout=30
host_notification_timeout=30
service_notification_timeout=30
notification_logging_options=3
###############################################################################
# EVENT HANDLER SETTINGS
###############################################################################
event_handler_timeout=30
retry_event_handler_timeout=30
###############################################################################
# OCSP/OCHP SETTINGS
###############################################################################
ocsp_timeout=30
ochp_timeout=30
###############################################################################
# FLAP DETECTION
###############################################################################
enable_flap_detection=1
low_host_flap_threshold=5
high_host_flap_threshold=20
low_service_flap_threshold=5
high_service_flap_threshold=20
###############################################################################
# PERFORMANCE OPTIONS
###############################################################################
use_large_installation_tweaks=0
enable_environment_macros=1
free_child_process_memory=1
child_processes_fork_twice=1
###############################################################################
# DATE FORMAT
###############################################################################
date_format=iso8601
###############################################################################
# TIMEZONE
###############################################################################
use_timezone=UTC
###############################################################################
# ALLOWED USERS FOR CGI
###############################################################################
authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
###############################################################################
# MISC OPTIONS
###############################################################################
retain_state_information=1
state_retention_file=/var/cache/naemon/retention.dat
retention_update_interval=60
use_retained_program_state=1
use_retained_scheduling_info=1
retained_host_attribute_mask=0
retained_service_attribute_mask=0
retained_process_host_attribute_mask=0
retained_process_service_attribute_mask=0
transient_host_attribute_mask=0
transient_service_attribute_mask=0
translate_passive_host_checks=0
passive_host_checks_are_soft=0
execute_host_checks=1
execute_service_checks=1
accept_passive_host_checks=1
accept_passive_service_checks=1
enable_notifications=1
enable_event_handlers=1
process_performance_data=1
obsess_over_services=0
ocsp_command=
obsess_over_hosts=0
ochp_command=
check_for_updates=1
bare_update_check=0
admin_email=nagios@example.com
admin_pager=pagenagios@example.com
daemon_dumps_core=0
use_ssl=0
additional_host_dependency_depth=0
# /etc/naemon/resource.cfg
# Plugin directory
$USER1$=/usr/lib/nagios/plugins
# MySQL credentials
$USER2$=monitoring
$USER3$=MonitoringPassword123!
# SNMP community
$USER4$=public
# API credentials
$USER5$=api_user
$USER6$=ApiPassword123!
# Database connection
$USER7$=mysql://monitoring:Password123!@localhost/monitoring
# Slack webhook
$USER8$=https://hooks.slack.com/services/XXX/YYY/ZZZ
# Email settings
$USER9$=smtp.example.com
$USER10$=naemon@example.com
$USER11$=EmailPassword123!
# /etc/naemon/cgi.cfg
# Physical path for CGI scripts
physical_html_path=/usr/share/naemon/cgi
# URL path for CGI scripts
url_html_path=/naemon/cgi
# Context name for Apache
cgi_url=/naemon/cgi
# Main config file
main_config_file=/etc/naemon/naemon.cfg
# Status file
status_file=/var/cache/naemon/status.dat
# P1.pl file
p1_file=/usr/local/bin/p1.pl
enable_embedded_perl=1
use_embedded_perl_implicitly=1
# Refresh rate
refresh_rate=90
# Result limit
result_limit=100
# Escape HTML tags
escape_html_tags=1
# Sound options
sound_enable=1
sound_host_down=hostdown.wav
sound_service_critical=critical.wav
sound_service_warning=warning.wav
sound_service_unknown=unknown.wav
sound_notification=notification.wav
# Target frame
action_url_target=_blank
notes_url_target=_blank
# Lock author names
lock_author_names=1
# Pending states
show_pending_states=1
# /etc/naemon/objects/contacts.cfg
define contact {
contact_name nagiosadmin
alias Naemon Administrator
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email admin@example.com
pager +1234567890
can_submit_commands 1
}
define contact {
contact_name ops-team
alias Operations Team
service_notification_period workhours
host_notification_period workhours
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email ops-team@example.com
can_submit_commands 0
}
define contactgroup {
contactgroup_name admins
alias Naemon Administrators
members nagiosadmin
}
define contactgroup {
contactgroup_name ops
alias Operations Team
members ops-team
}
# /etc/naemon/objects/commands.cfg
define command {
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$\n\n$NOTIFICATIONTYPE$ Host Alert\n\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendmail -f naemon@example.com $CONTACTEMAIL$
}
define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\n\n$NOTIFICATIONTYPE$ Service Alert\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nInfo: $SERVICEOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendmail -f naemon@example.com $CONTACTEMAIL$
}
define command {
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
define command {
command_name check-http
command_line $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$ -s $ARG2$
}
define command {
command_name check-ssh
command_line $USER1$/check_ssh -H $HOSTADDRESS$ -p $ARG1$
}
define command {
command_name check-disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
}
define command {
command_name check-mysql
command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u $USER2$ -p $USER3$
}
define command {
command_name check-snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -C $USER4$ -o $ARG1$
}
# /etc/naemon/objects/timeperiods.cfg
define timeperiod {
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
define timeperiod {
timeperiod_name workhours
alias Work Hours (8AM-6PM)
monday 08:00-18:00
tuesday 08:00-18:00
wednesday 08:00-18:00
thursday 08:00-18:00
friday 08:00-18:00
}
define timeperiod {
timeperiod_name never
alias Never
}
# /etc/naemon/objects/templates.cfg
define host {
name generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 5
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,u,r
contact_groups admins
register 0
}
define host {
name linux-server
use generic-host
check_command check-host-alive
register 0
}
define host {
name windows-server
use generic-host
check_command check-host-alive
register 0
}
define host {
name network-device
use generic-host
check_command check-host-alive
register 0
}
define service {
name generic-service
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 4
notification_period 24x7
notification_interval 60
notification_options w,u,c,r
contact_groups admins
register 0
}
define service {
name http-service
use generic-service
check_command check-http!/
register 0
}
define service {
name ssh-service
use generic-service
check_command check-ssh!22
register 0
}
# /etc/naemon/objects/hosts.cfg
define host {
use linux-server
host_name webserver01
alias Web Server 01
address 192.168.1.10
contact_groups admins,ops
action_url http://webserver01/
notes_url http://wiki.example.com/webserver01
}
define host {
use linux-server
host_name dbserver01
alias Database Server 01
address 192.168.1.20
contact_groups admins,dba
action_url http://dbserver01:3306/
}
define host {
use network-device
host_name switch-core-01
alias Core Switch 01
address 192.168.1.1
contact_groups admins,network
}
# /etc/naemon/objects/services.cfg
define service {
use http-service
host_name webserver01
service_description HTTP
check_command check-http!/!200
}
define service {
use ssh-service
host_name webserver01
service_description SSH
}
define service {
use generic-service
host_name webserver01
service_description Disk /
check_command check-disk!20%!10%!/
}
define service {
use generic-service
host_name dbserver01
service_description MySQL
check_command check-mysql
}
#!/bin/bash
# /usr/local/bin/naemon-notify.sh
NOTIFICATIONTYPE="$1"
HOSTNAME="$2"
SERVICEDESC="$3"
SERVICESTATE="$4"
HOSTADDRESS="$5"
SERVICEOUTPUT="$6"
LONGDATETIME="$7"
CONTACTEMAIL="$8"
SUBJECT="[$NOTIFICATIONTYPE] $HOSTNAME/$SERVICEDESC is $SERVICESTATE"
BODY="$NOTIFICATIONTYPE Alert
Host: $HOSTNAME
Address: $HOSTADDRESS
Service: $SERVICEDESC
State: $SERVICESTATE
Info: $SERVICEOUTPUT
Date/Time: $LONGDATETIME
--
Naemon Monitoring System
"
echo "$BODY" | mail -s "$SUBJECT" "$CONTACTEMAIL"
#!/bin/bash
# /usr/local/bin/naemon-slack.sh
WEBHOOK_URL="https://hooks.slack.com/services/XXX/YYY/ZZZ"
NOTIFICATIONTYPE="$1"
HOSTNAME="$2"
SERVICEDESC="$3"
SERVICESTATE="$4"
SERVICEOUTPUT="$5"
case "$SERVICESTATE" in
"CRITICAL") COLOR="danger"; EMOJI=":rotating_light:" ;;
"WARNING") COLOR="warning"; EMOJI=":warning:" ;;
"OK") COLOR="good"; EMOJI=":white_check_mark:" ;;
*) COLOR="#808080"; EMOJI=":information_source:" ;;
esac
PAYLOAD=$(cat <<EOF
{
"attachments": [
{
"color": "$COLOR",
"title": "Naemon Alert: $NOTIFICATIONTYPE",
"fields": [
{"title": "Host", "value": "$HOSTNAME", "short": true},
{"title": "Service", "value": "$SERVICEDESC", "short": true},
{"title": "State", "value": "$SERVICESTATE", "short": true},
{"title": "Info", "value": "$SERVICEOUTPUT", "short": false}
]
}
]
}
EOF
)
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$WEBHOOK_URL"
# Validate Naemon configuration
sudo naemon -v /etc/naemon/naemon.cfg
# Check for warnings
sudo naemon -v /etc/naemon/naemon.cfg 2>&1 | grep -i warning
# Verify object files
sudo ls -la /etc/naemon/objects/
# Restart Naemon
sudo systemctl restart naemon
# Check service status
sudo systemctl status naemon
# View logs
sudo tail -f /var/log/naemon/naemon.log
# Reload configuration
sudo systemctl reload naemon
# Schedule host check
echo "[$(date +%s)] SCHEDULE_FORCED_HOST_CHECK;webserver01" >> /var/cache/naemon/rw/naemon.cmd
# Schedule service check
echo "[$(date +%s)] SCHEDULE_FORCED_SERVICE_CHECK;webserver01;HTTP" >> /var/cache/naemon/rw/naemon.cmd
# Disable notifications
echo "[$(date +%s)] DISABLE_HOST_NOTIFICATIONS;webserver01;$(date +%s);$(($(date +%s)+3600))" >> /var/cache/naemon/rw/naemon.cmd
# Check Naemon status
sudo systemctl status naemon
# View status file
sudo cat /var/cache/naemon/status.dat | head -50
# Check command file
sudo ls -la /var/cache/naemon/rw/naemon.cmd
# Access web interface
curl http://localhost/naemon/
# Check CGI status
curl http://localhost/naemon/cgi-bin/status.cgi
# Check host status
curl http://localhost/naemon/cgi-bin/extinfo.cgi?type=1&host=webserver01
# Force check execution
echo "[$(date +%s)] SCHEDULE_FORCED_HOST_CHECK;webserver01" >> /var/cache/naemon/rw/naemon.cmd
# View check results
sudo tail -f /var/log/naemon/naemon.log | grep "HOST CHECK"
Every deployment is unique. We provide consulting for:
Get personalized assistance: office@linux-server-admin.com | Contact Page