王者DFI!LANParty创意LOGO票选活动 || DFI-ABS.OCER.net
四大品牌P45适用人群之OCER建议 | | 挑战不可能,DFI LANParty DK P45 & JR P45横测 | ASUS P6T Deluxe征服“i7”
MSI 4870X2 2GB,4850/4870 CF同门大乱斗 | | 映泰 TA790GX A2+超值登场 | | 高频不低能!威刚DDR3-1600+轻松OC2000+
OC小板典范DFI LP JR P45 | | ABS让OC更容易 DK P45 636外频达成 | | 超频网"Core i7"最亲民测试 | | GIGA X58-EXTREME抢鲜看
 26 12
发新话题
打印

Linux mrtg configure how to

Linux mrtg configure how to

不要骂,就是欺负你看不懂~~~这是老黄语录。

Linux mrtg configure how to
Step # 1 : Make sure snmp server installed
Please note that snmpd configuration does not require using mrtg with remote network devices such as Routers and switches. If you just want mrtg graphs for router or switch then please refer to step # 4 (as all these devices comes preconfigured with snmpd software).
Run rpm commands query option to find out snmp server installed or not:
# rpm -qa | grep snmp
If snmp installed then please refer step # 2; otherwise snmp server and utils were not present and your need to install them using following steps (login as a root user):
(a) Visit rpmfind.net to get snmp server and utilities rpms. If you are fedora user then use yum command as follows to install it:
# yum install net-snmp-utils net-snmp
(b) If you are RHEL subscriber then use up2date command as follows to install:
#up2date -v -i net-snmp-utils net-snmp


Step # 2 : Determine if snmp server is running or not
Run 'ps' command to see if snmp server is running or not:
# ps -aux | grep snmp
Output:
root   5512  0.0  2.3  5872 3012 pts/0    S    22:04   0:00 /usr/sbin/snmpd
Alternatively, you can try any of the following two commands as well:
# lsof -i :199
Output:
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
snmpd   5512 root    4u  IPv4  34432       TCP *:smux (LISTEN)
or try out netstat command:
# netstat -natv | grep ':199'
Output:
tcp        0      0 0.0.0.0:199             0.0.0.0:*               LISTEN
If you found service is running or listing on port 199 then please see step #3; otherwise start service using following command:
# service snmpd start
Make sure snmpd service starts automatically, when linux comes us (add snmpd service):
# chkconfig --add snmpd

Step # 3 : Make sure snmp server configured properly
Run snmpwalk utility to request for tree of information about network entity. In simple words query snmp server for your IP address (assigned to eth0, eth1, lo etc):
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2
If you can see your IP address then please proceed to step 4; else it is a time to configure snmp server as follows (by default RHEL and RH 8/9 are not configured for snmp server for security reason):
Configure SNMP
(1) Edit file /etc/snmp/snmpd.conf using text editor:
# vi /etc/snmp/snmpd.conf
Change/Modify line(s) as follows:
Find following Line:
com2sec notConfigUser  default       public
Replace with (make sure you replace 192.168.0.0/24 replace with your network IPs) following lines:
com2sec local     localhost           public
com2sec mynetwork 192.168.0.0/24      public
Scroll down bit and change:
Find Lines:
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
Replace with:
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork
Again scroll down bit and locate following line:
Find line:
view    systemview     included      system
Replace with:
view all    included  .1                               80
Again scroll down bit and change:
Find line:
access  notConfigGroup ""      any       noauth    exact  systemview none none
Replace with:
access MyROGroup ""      any       noauth    exact  all    none   none
access MyRWGroup ""      any       noauth    exact  all    all    none
Scroll down bit and change:
Find lines:
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
Replace with (make sure you supply appropriate values):
syslocation Linux (RH3_UP2), Home Linux Router.
syscontact Vivek G Gite <vivek@nixcraft.com>
For your convenient, here is my /etc/snmp/snmpd.conf file. Feel free to use this file. Make sure you make backup of your existing file if you use this file as it is.
Start your snmp server and test it:
(a) Make sure when linux comes up snmpd always starts:
# chkconfig snmpd on
(b) Make sure service start whenever Linux comes up (after reboot):
# service snmpd start
(c) Finally test your snmp server:
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

Step # 4 : Install mrtg if not installed
Mrtg software may install during initial installation; you can verify if MRTG installed or not with following RPM command:
rpm -qa | grep mrtg
If mrtg already installed please see step # 5; else use rpmfind.net to find MRTG rpm or up2date command to install MRTG software:
# up2date -v -i mrtg
Fedora Linux user can use yum command as follows to install MRTG:
# yum install mrtg

Step # 5 : Commands to Configure mrtg
(a) Create document root to store mrtg graphs/html pages:
# mkdir -p /var/www/html/mymrtg/
(b) Run any one of the following cfgmaker command to create mrtg configuration file:
#cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@localhost
or (make sure your FQDN resolves, in following example i'm using rh9.test.com which is my router FQDN address)
# cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg1.cfg public@rh9.test.com
(c) Create default index page for your MRTG configuration:
# indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg
(d) Copy all tiny png files to your mrtg path:
# cp -av /var/www/html/mrtg/*.png /var/www/html/mymrtg/

Step # 6 First test run of mrtg
(a) Run mrtg command from command line with your configuration file:
# mrtg /etc/mrtg/mymrtg.cfg
Note: You may get few warning message for first time; ignore them.
(b) Fire your favorite web browser (like FireFox :D ) and type url http://www.your.com/mymrtg/ or http://your-ip/mymrtg/

Step # 7 Create crontab entry so that mrtg graph / images get generated every 5 minutes
(a) Login as a root user or login as a mrtg user and type following command:
# crontab -e
(b) Add mrtg cron job entry to configuration file (append following line to it):
*/5 * * * * /usr/bin/mrtg /etc/mrtg/mymrtg.cfg --logging /var/log/mrtg.log

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
Step # 9 Optional: Protect your MRTG graphs/html pages with password protected directory
Once again, you would like to restrict access to your MRTG reports. This can easily accomplished with Apache webserver's .htaccess file. If you are on webhosting server with control panel (such as ensim or plesk) then you can use control panel itself to create password-protected directory.
Below is process outlined to protect graphs using apache's .htaccess file and htpasswd command:
Step # 1: Create .htaccess file in /var/www/html/mymrtg/ directory (add text as follows):
vi /var/www/html/mymrtg/.htaccess
Add following text to file:
AuthName "MRTG Graphs/Html restricted access"
AuthType Basic
AuthUserFile /var/members/.htpasswd
require user mrtgadmin
Step # 2: Create a user and password name (-c assumes first time you are using .htpasswd file):
# htpasswd -c /var/members/.htpasswd mrtgadmin
For more information please see Apache Webserver Authentication and access control mini-howto.

MRTG: References and further reading
Use following resources to find out more Linux help, links to general information and help for MRTG, snmp under Linux/UNIX/Windows OSes:
•    MRTG home page: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/
•    SNMP home page: http://net-snmp.sourceforge.net/
•    MRTG authors installation by compiling source code: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg-unix-guide.html
•    SNMP How-to: http://www.rescomp.berkeley.edu/about/training/senior/progs/SNMP-HOWTO/SNMP-HOWTO.html
•    Linux (UNIX) Man pages : snmpd.conf(5), snmpwalk(1), cfgmaker(1), indexmaker(1), mrtg(1), rpm(8), crontab(1)
•    Other MRTG tutorial: Links to tons of mrtg config docs & tutorial
•    Special Case: MRTG Red hat enterprise Linux Virtuozzo VPS configuration
•    See Recommend books for SNMP & MRTG
Problem with MRTG configuration issues
When you come across a problem with MRTG and SNMP configurations, I would like to hear about it. You can send all your questions regarding snmp and mrtg configuration, problem to nixCraft forum for further discussion. Well it is true that MRTG is for network monitoring and it can be use to see how much traffic your server/router or ADSL router actually generated, however it will not tell you how much megabytes or gigabytes the daily traffic was. For all such home user and people having dedicated single Linux box hosted somewhere remote at IDC/ISP there is a tool called vnStat (see image below), see Special configuration: Keeping a log of daily network traffic for ADSL or dedicated remote Linux box
vnstat - Display traffic for days

vnstat - Displays traffic for each months:
本帖最近评分记录
  • Linux-lq 现金 +49 精品文章 2008-8-28 20:19
  • Linux-lq 威望 +1 精品文章 2008-8-28 20:19
       
Fedora

老黄要干嘛?
引用:
原帖由 qiang_liu8183 于 2008-8-28 20:14 发表
Fedora

老黄要干嘛?
不干啥,在逛牛人的博客呢
       
引用:
原帖由 gmx168 于 2008-8-28 20:19 发表
不干啥,在逛牛人的博客呢
老哥给我个XP SP3 MSDN版的下载链接
企鹅?
怎么要windows?
Yesterday is history. Tomorrow is mystery.
Today is a gift.
That's why it is called present!
引用:
原帖由 Linux-lq 于 2008-8-28 20:20 发表


老哥给我个XP SP3 MSDN版的下载链接
我不用MSDN版的,VLK版的要不?从MS老巢下载的原汁原味。
       
只有英文版的哦
       
引用:
原帖由 gmx168 于 2008-8-28 20:27 发表
我不用MSDN版的,VLK版的要不?从MS老巢下载的原汁原味。
MSDN和VLK有啥区别?!VLK是不是就是VOL?
引用:
原帖由 gmx168 于 2008-8-28 20:29 发表
只有英文版的哦
为啥没有中文?
引用:
原帖由 Linux-lq 于 2008-8-28 20:29 发表


MSDN和VLK有啥区别?!VLK是不是就是VOL?
是啊,就是大客户版
       
引用:
原帖由 gmx168 于 2008-8-28 20:30 发表
是啊,就是大客户版
那大客户版和MSDN有啥区别?
MSDN是什么意思?
引用:
原帖由 Linux-lq 于 2008-8-28 20:30 发表


为啥没有中文?
狗日的不提供中文下载
       
VLK用不用激活?!
引用:
原帖由 Linux-lq 于 2008-8-28 20:33 发表
VLK用不用激活?!
不用
       
看过了,还没法给你,是个exe文件,不是iso的包。
你急么?不急的话我现在就去微软下一个,明天放ftp上。
       
不懂,来凑热闹
amd8450  U120E OC280*10.5
GIGA GA-MA790GP-DS4H
KST1G DDR2 667 1G*2神条OC1080
HIS ICEQ4 4850 T-RAD2
联志T10
台达dps-700fb
Razer 炼狱蝰蛇+螳螂控制王
引用:
原帖由 gmx168 于 2008-8-28 20:36 发表
看过了,还没法给你,是个exe文件,不是iso的包。
你急么?不急的话我现在就去微软下一个,明天放ftp上。
我想找个中文版
引用:
原帖由 PlutoXX 于 2008-8-28 20:25 发表
企鹅?
怎么要windows?
给一姑娘装~~~
引用:
原帖由 Linux-lq 于 2008-8-28 20:37 发表


我想找个中文版
中文sp2的行不?
       
引用:
原帖由 gmx168 于 2008-8-28 20:39 发表
中文sp2的行不?
中文SP2我这有OEM的正版
引用:
原帖由 qiang_liu8183 于 2008-8-28 20:40 发表


中文SP2我这有OEM的正版
那不就得啦,装好sp2再打sp3嘛。