Snmp mrtg
SNMP
SNMP und IPTABLES
http://www.linuxquestions.org/questions/linux-networking-3/iptables-and-snmp-707581/
SNMP und ntop
http://www.aboutdebian.com/monitor.htm
SNMP Code-Schnipsel
apt-get install snmpd snmp-mibs-downloader
Einfacher snmpwalk
snmpwalk -v1 -c public localhost IP-MIB::ipAdEntIfIndex snmpwalk -v1 -c public localhost if
iptables Ausnahme
http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/mrtg_config_step_8.php
[Previous section] Step # 8 Block ports 161 & 162 at firewall
You do not want to give access to everyone to your snmp server for security reasons. SNMP server uses UDP 161, 162 ports for communication. Use Linux IPTABLES firewall to restrict access to SNMP server
(a) Allow outgoing SNMP server request from your Linux computer. This is useful when you query remote host/router (replace SERVER IO with your real IP):
SERVER="xxx.xxx.xxx.xxx" iptables -A OUTPUT -p udp -s $SERVER --sport 1024:65535 -d 0/0 --dport 161:162 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A INPUT -p udp -s 0/0 --sport 161:162 -d $SERVER --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
(b )Allow incoming SNMP client request via iptables. This is useful when you wish to accept queries for rest of the world (replace SERVER IP with your real IP):
SERVER="xxx.xxx.xxx.xxx" iptables -A INPUT -p udp -s 0/0 --sport 1024:65535 -d $SERVER --dport 161:162 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p udp -s $SERVER --sport 161:162 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
Pleae note that above two are just SNMP specific iptables rules. Please consult iptables(8) man page for complete information on iptables
Cacti
- [http://www.cacti.net/ Cacti Homepage
MRTG
- How to use RRDtool with MRTG
- RRD Tutorial
- RRD Tut (scheint mir besser)
- Linux Magazin übers RRDtool
- Advanced_MRTG_for_Linux
- Debianhelp MRTG Seite
- mrtgexamples.com Beispielscripts
apt-get install mrtg mrtg-rrd lm-sensors bzw. libsensors3 chown www-data /etc/mrtg.cfg chown www-data /var/www/mrtg
Sample Script
#!/bin/sh # Created by Tobias Weiss # http://www.tobias-weiss.com/ # # This script is licensed under the GPL http://www.gnu.org/copyleft/gpl.html # ######################### ### Sample /etc/mrtg.cfg usage # Title[server-value]: Server Mail log size # PageTop[server-value]: Server Mail log size # Target[server-value]: `/usr/local/sbin/test.sh $1` # MaxBytes[server-value]: 1208032 # YLegend[server-value]: Size # ShortLegend[server-value]: Bytes # LegendO[server-value]: Bytes # Options[server-value]: perminute, growright l=`ls -l $1 | awk '{print $5}'` #% usage /dev/sda1 #l=`df -h | grep /dev/sda1 | awk '{print $5}' | tr -d %` #Absolute mem usage #l=`free | grep "Mem" | awk '{print $4}'` echo $l echo $l hostname;
Failed SSH Logins
#!/bin/bash cat /var/log/auth.log | grep 'Failed password' | wc -l echo echo $HOSTNAME
Sensors
Do you want to add these lines to /etc/modules automatically? (yes/NO)yes vpn-obdf:/var/www/mrtg# sensors No sensors found! Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are. vpn-obdf:/var/www/mrtg# sensors-detect vpn-obdf:/var/www/mrtg# modprobe it87 i2c-piix4 vpn-obdf:/var/www/mrtg# sensors it8712-isa-0228 Adapter: ISA adapter VCore 1: +1.31 V (min = +4.08 V, max = +4.08 V) ALARM VCore 2: +3.30 V (min = +4.08 V, max = +4.08 V) ALARM +3.3V: +2.61 V (min = +4.08 V, max = +4.08 V) ALARM +5V: +5.00 V (min = +6.85 V, max = +6.85 V) ALARM +12V: +12.42 V (min = +16.32 V, max = +16.32 V) ALARM -12V: -27.36 V (min = +3.93 V, max = +3.93 V) ALARM -5V: -13.64 V (min = +4.03 V, max = +4.03 V) ALARM Stdby: +4.97 V (min = +6.85 V, max = +6.85 V) ALARM VBat: +3.28 V fan1: 1776 RPM (min = 811 RPM, div = 8) ALARM fan2: -1 RPM (min = 0 RPM, div = 8) fan3: -1 RPM (min = 0 RPM, div = 8) M/B Temp: +46°C (low = -1°C, high = -1°C) sensor = thermistor ALARM CPU Temp: +55°C (low = -1°C, high = -1°C) sensor = thermistor ALARM Temp3: +35°C (low = -1°C, high = -1°C) sensor = thermistor ALARM
MRTG Code-Schnipsel
cfgmaker --global "workdir: /var/www/mrtg" -ifref=ip --output /etc/mrtg.cfg --global 'options[_]: growright,bits' public@localhost
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
if [ -x /usr/bin/mrtg ] && [ -r /etc/mrtg.cfg ]; then mkdir -p /var/log/mrtg ; env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1 | tee -a /var/log/mrtg/mrtg.log ; fi
Links
http://www.debianadmin.com/mrtg-installation-and-configuration-in-debian-based-distributions-2.html CPU / MEM / ETC Mon
http://felixtriller.de/2006/12/14/mrtg-unter-debian/ Erweitertes Tut mit Samplescripts zum Download
http://blog.alonso.ch/paste-bin/howto-snmpd-unter-debian-squeeze/
http://www.my-guides.net/en/guides/linux/23-how-to-install-mrtg-under-linux
http://www.debianadmin.com/mrtg-installation-and-configuration-in-debian-based-distributions-2.html