Nagios client-server — SNMP Monitoring

Ravinayag
4 min readJun 14, 2021

--

Here we going to install the SNMP service on the client side.

Please do refer my previous post on Nagios Core setup

Note: There are two methods to monitor the client from nagios server. (SNMP and Nagios native packages.)
1, Nagios native packages and plugins
monitoring-plugins “ and “nagios-nrpe-plugin”

2, Snmp Packages — using SNMPD protocols.

In this document, we follow the SNMP protocol.

Install SNMP On The Remote Linux Machine

Before monitoring a Linux machine using SNMP, we’ll need to install and configure the necessary packages.

Let’s install the net-snmp package on the Linux machine. Login to the client Linux machine as the root user to complete the next steps.

$ sudo apt-get install snmpd libsnmp-dev

configure access permissions for SNMP on the Linux machine.

Brief info about SNMP v3

Access is granted with a username, permission, security level, authentication, and privacy passphrases its more complicated but also more secure

▪ This documentation will use the following values:

  • Username: nagios
  • Permission: rouser
  • Security Level: authPriv
  • Authentication Protocol: SHA
  • Authentication Pass-phrase: Str0ng@uth3ntic@ti0n
  • Privacy Protocol: AES
  • Privacy Pass-phrase: Str0ngPriv@cy

All of them are changeable parameters, if you are not sure what you doing, then I suggest changing only the user name and pass-phrase as your wish.

Ubuntu 20.x systems execute the following

sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.bak 
sudo systemctl stop snmpd.service
sudo sh -c “echo '' > /etc/snmp/snmpd.conf”
sudo net-snmp-create-v3-user -ro -a SHA -A Str0ng@uth3ntic@ti0n -x AES -X Str0ngPriv@cy nagios
sudo systemctl start snmpd.service

If firewall configured, then

sudo ufw allow snmp 
sudo ufw reload

that's all from the client machine. now we have to configure nagios server with client details.
We need three parameters from the client servers.

1, the hostname with fqdn

2, IPaddress of the client-server.

3, snmp user credentials that wecreated in the above step.

For Learning purposes, I have the above information as below.

1, client-lx-snmp-host.example.com

2, 192.168.10.15

3, user name = nagios , auth pass = Str0ng@uth3ntic@ti0n and priv pass = Str0ngPriv@cy

Add Hosts Configuration to the Nagios Server

Back to the Nagios server terminal, go to the “/usr/local/nagios/etc” directory and create a new configuration “server/client-lx-snmp-host.example.com.cfg”.

cd /usr/local/nagios/etc
vi servers/
client-lx-snmp-host.example.com.cfg

Change the IP address and the hostname with your own and paste the configuration into it.

# Ubuntu Host configuration 

define host {
use linux-server
host_name client-lx-snmp-host.example.com
alias Linux SNMP Host
address 192.168.10.15
register 1
}

define service {
host_name client-lx-snmp-host.example.com
service_description PING
check_command check_nrpe!check_ping
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 client-lx-snmp-host.example.com
service_description Check Users
check_command check_nrpe!check_users
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 client-lx-snmp-host.example.com
service_description Check SSH
check_command check_nrpe!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 client-lx-snmp-host.example.com
service_description Check Root / Disk
check_command check_nrpe!check_root!
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 client-lx-snmp-host.example.com
service_description Check APT Update
check_command check_nrpe!check_apt
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 client-lx-snmp-host.example.com
service_description Check HTTP
check_command check_nrpe!check_http
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
}

Save and close.

Now define the snmp v3 auth to all commands by editing the configuration file “objects/commands.cfg”.update the following configuration to the command_line “ -l nagios -x Str0ng@uth3ntic@ti0n -X Str0ngPriv@cy -L SHA,AES

vi objects/commands.cfg

Do this for all commands that you listed in commands.cfg file

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -l nagios -x Str0ng@uth3ntic@ti0n -X Str0ngPriv@cy -L SHA,AES -c $ARG1$
}

Save and close, and the Nagioscore configuration has been completed.

Now restart the Nagios Server.

sudo systemctl restart nagios

Checking

Back to your browser and wait for few minutes.

Click on the “Hosts” menu and you will get the “client-lx-snmp-host” has been added.

Now you’ve added Host to monitor to the Nagios Server using SNMP v3 protocol

And the installation of Nagios 4.4.x on Ubuntu 20.04 Server has been completed successfully.

--

--

Ravinayag

Blockchain enthusiast & Research | DevOps Explorer | Hyperledger Explorer