Friday, May 19, 2017

How To Configure SNMP Logging on RHEL 7

Overview

In this guide we will go over different SNMP logging facility configuration on a Linux based operating system.

We will also go over different SNMPD startup options as per the business / IT Operations requirements.

We will also get to know as to  how we can configure logging levels based on the "Logging Facility" and when to utilize it.

Applies To

  • Ubuntu
  • RHEL 6.5
  • RHEL 7

Pre-Requisites

  • Net-SNMP packages are installed on the server.

SNMP Daemon – Configuration File – Startup Options

Listed below is the configuration file “snmpd.conf” location on different operating systems.

Operating System File Location
Ubuntu /etc/default/snmpd
RHEL / CentOS /etc/sysconfig/snmpd

SNMP Daemon – Configuration File – View

Once you configure the snmp daemon startup options you can also validate / view configuration by running the below command;

On Ubuntu – run the command;

lsb_release -d
cat /etc/default/snmpd | grep SNMPDOPTS





On RHEL / CentOS – run the command;

cat /etc/redhat-release
cat /etc/sysconfig/snmpd | grep OPTIONS











SNMP Daemon – Configuration File – Reconfiguration

In case the default / custom configuration file is missing or corrupted, you can recreate a new snmp.conf configuration file; to reconfigure / re-create run the command below;

snmpconf


























With this command you can also reconfigure / create new configuration file(s); When you run the command, it will read the current configuration file;

  1. /etc/snmp/snmp.conf
  2. /etc/snmp/snmpd.conf
  3. /etc/snmp/snmptrapd.conf
Upon re-configuring is done with “snmpconf” command; you can perform these actions;
  • overwrite
  • rename
  • append
  • skip

SNMP Daemon – Startup Options

By default, SNMP daemon is started with the configuration file “/etc/default/snmpd”, “/etc/sysconfig/snmp” in Ubuntu, RHEL OS respectively with startup options as below;

# RHEL OS

cat /etc/sysconfig/snmp
# OPTIONS="-LS0-6d"











# Ubuntu OS

cat /etc/default/snmpd
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -g root 0.0.0.0'




Startup Options Purpose

SNMP daemon startup attribute(s) purpose are shown below table.

Options Purpose
L Logging
S Syslog
D Daemon
-Ls Log messages via syslog
-Lf Log messages to the specified file
U User
I Initialize
smux SNMP Multiplexing Protocol (disabled by default)
P Process ID
G Group ID

Syslog Daemon Options

Syslog daemon startup can be configured with different options, few of them are listed in the below table;

Logging Options Purpose
-Lsd Log Syslog Daemon (default)
-Lsd Log Syslog Warning Message
-LSwd or -Ls4d Log Syslog Error Message
-Lf /dev/null Redirect to Null file

Logging Facility Table

Table below gives logging facility that can be configured.

Numeric Value Character Value Log Type Logging Scenario / Purpose
0 ! LOG_EMERG Emergencies – System is unusable
1 a LOG_ALERT Alerts – Immediate action needed
2 b LOG_CRIT Critical – Critical conditions
3 c LOG_ERR Error – Error conditions
4 e LOG_WARNING Warnings – Warning conditions
5 n LOG_NOTICE Notifications – Informational messages
6 i LOG_INFO Informational – Normal but significant conditions
7 d LOG_DEBUG Debug – Debugging messages

SNMP Daemon Management

To manage snmpd daemon, run the command based on the SysVinit or Service Manager enabled on the server(s);

SysVinit Enabled OSSystemd Enabled OS
service snmpd startsystemctl start snmpd
service snmpd stopsystemctl stop snmpd
service snmpd restartsystemctl restart snmpd
service snmpd statussystemctl status snmpd

Managing SNMPD Daemon

SNMP Daemon – Start

To start snmpd daemon, run the command;

systemctl start snmpd
















SNMP Daemon – Stop

To stop snmpd daemon, run the command;

systemctl stop snmpd




SNMP Daemon – Restart

To restart snmpd daemon, run the command;

systemctl restart snmpd




SNMP Daemon – Status

To know the stuats of snmpd daemon, run the command;

systemctl status snmpd






Slideshare Info

A step by step guide with screenshots is uploaded to slideshare.


1 comment: