snmp is an internet protocol that allows you to retrieve management information from a remote device or to set configuration settings on a remote device.
Examples: CPU load, RAID statusAn snmp system is generally considered to have 3 components:
# apt-get install snmp snmpd
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1' SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -p /var/run/snmpd.pid localhost,gracie'
$ snmpget -v2c -c public localhost 18.104.22.168.22.214.171.124.0
Snmpget and snmwalk allow you to query system information via snmp. Examples:
snmpget -v2c -c public localhost 126.96.36.199.188.8.131.52.0
snmpwalk -v2c -c public localhost 184.108.40.206.2
$ snmpget -v2c -c public localhost sysUpTime.0 # snmpget -v2c -c public localhost sysUpTime.0 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (8172473) 22:42:04.73 $ qalc '8172473/60/60/100' ((8172473 / 60) / 60) / 100 = approx. 22.701314 $ uptime 11:32:18 up 22:43, 3 users, load average: 0.18, 0.17, 0.11
# snmpconfigAuthentication and access control were added in version 3.
# /etc/init.d/snmpd restart
# /etc/init.d/snmpd stop # net-snmp-config --create-snmpv3-userA more detailed look at snmp security is beyond the scope of this discussion.
# /etc/init.d/snmpd start # snmpget -v 3 -u nemo -l authNoPriv -a MD5 -A qwerty1234 localhost sysUpTime.0
Nagios is a network monitoring tool which canissue alerts when it detects a problem on a machine it is monitoring. It can also issue an alert if the problem goes away. Nagios consistes of three parts:
apt-get install nagios3
On a debian system, local configuration files for nagios are uin /etc/nagios3/conf.d/. The default configuration monitors localhost for several problems iincluding heavy load, low disk space, or too many processes. You will want to create files to define your own users, hosts, and possibly your own commands.
On a debian system, a package named nagios-plugins is installed as a dependency when you install nagios3. This is a collection of perl scripts that do the system monitoring. The scripts are stored in /usr/lib/nagios/plugins/.
You can get an idea of what a script does by running it with the -h option:
cd /usr/lib/nagios/plugins/ ./checksnmp -h
Nagios comes with an enormous number of scripts. There are many more on the nagios wiki at http://nagioswiki.com/. But the day may come when you need to write your own plugin. Tips: