Selasa, 15 Januari 2008

SNMP and MRTG on Linux

1. I use CenTos 3.4 Distribution

2. Paket that must install on the system is:
[root@dell root]# rpm -qa grep snmp
net-snmp-5.0.9-2.30E.12
net-snmp-utils-5.0.9-2.30E.12
net-snmp-devel-5.0.9-2.30E.12
net-snmp-libs-5.0.9-2.30E.12
net-snmp-perl-5.0.9-2.30E.12

3. Dont forget to backup snmp.conf file:
[root@dell root]# cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak

4. Write new snmp.conf scripts:
com2sec public default public
group public v1 public
group public v2c public
group public usm public
view all included .1
access public "" any noauth exact all none none

5. Run SNMP service:
[root@dell root]# /etc/rc.d/init.d/snmpd start

6. Ceck SNMP service :
[root@dell root]# ps ax grep snmp
24433 ? S 0:00 /usr/sbin/snmpd -s -l /dev/null -P /var/run/snmpd -a
24437 pts/0 S 0:00 grep snmp

7. Ceck SNMP port:
[root@dell root]# netstat -pln grep snmp
tcp 0 0 0.0.0.0:199 0.0.0.0:* LIST EN 24433/snmpd
udp 0 0 0.0.0.0:161 0.0.0.0:* 24433/snmpd

8. Run Web server (I have use apache 2 version):
[root@dell root]# /usr/local/apache2/bin/apachectl start

9. Create directory mrtg on apache's root_directory:
[root@dell root]# mkdir /usr/local/apache2/htdocs/mrtg

10.U msut have mrtg paket on your linux:
[root@dell root]# rpm -qa grep mrtg
mrtg-2.9.29-4.ent

11.Create/run cfgmaker:
(example: snmp server installed on pc with IP address 192.168.100.218)

[root@dell snmp]# cfgmaker --global "WorkDir: /usr/local/apache2/htdocs/mrtg" --
global "Options[_]:growright,bits" public@192.168.100.218 > /etc/mrtg/192.168.10
0.218.cfg
--base: Get Device Info on public@192.168.100.218:
--base: Vendor Id:
--base: Populating confcache
--snpo: confcache public@192.168.100.218: Descr lo --> 1
--snpo: confcache public@192.168.100.218: Descr eth0 --> 2
--snpo: confcache public@192.168.100.218: Ip 127.0.0.1 --> 1
--snpo: confcache public@192.168.100.218: Ip 192.168.100.218 --> 2
--snpo: confcache public@192.168.100.218: Type 24 --> 1
--snpo: confcache public@192.168.100.218: Type 6 --> 2
--snpo: confcache public@192.168.100.218: Eth --> 1
--snpo: confcache public@192.168.100.218: Eth 00-12-3f-2e-83-b0 --> 2
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifSpeed

12.Edit 192.168.100.218.cfg file:
[root@dell root]# vi /etc/mrtg/192.168.100.218.cfg

# add this lines
# for UNIX
# WorkDir: /home/http/mrtg
WorkDir: /usr/local/apache2/htdocs/mrtg

# dan tambahkan baris berikut:
RunAsDaemon:Yes
Interval:5
Refresh:300

13. Run on 192.168.100.218.cfg file:
[root@dell snmp]# env LANG=C mrtg /etc/mrtg/192.168.100.218.cfg
Rateup WARNING: /usr/bin/rateup could not read the primary log file for 192.168.
100.218_2
Rateup WARNING: /usr/bin/rateup The backup log file for 192.168.100.218_2 was in
valid as well
Rateup WARNING: /usr/bin/rateup Can't remove 192.168.100.218_2.old updating log
file
Rateup WARNING: /usr/bin/rateup Can't rename 192.168.100.218_2.log to 192.168.10
0.218_2.old updating log file

14. SNMP server and MRTG installed on same machine, so u can open your browser whith url:
http://192.168.100.218/mrtg/

15.Dont forget create schedule with crontab , run mrtg for 5 menit
[root@dell root]# crontab -e
*/5 * * * * /usr/bin/mrtg /etc/mrtg/192.168.100.218.cfg --logging=/var/log/server1.log


' easy ????'

Tidak ada komentar: