免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 6145 | 回复: 26

[FreeBSD] FreeBSD上安装net-snmp和mrtg [复制链接]

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
发表于 2004-04-09 20:55 |显示全部楼层
安装net-snmpd和mrtg手册
1.        安装和配置net-snmpd
首先使用ports安装net-snmpd,使用如下命令:
cd /usr/ports/net/net-snmp
make install clean
安装完毕之后使用如下命令对snmpd进行配置:
snmpconf -g basic_setup
将会出现一个询问菜单,按如下步骤进行回答:


  1. Do you want to configure the information returned in the system MIB group (contact info, etc)? (default = y): y

  2. The location of the system: Bei Jing, China

  3. The contact information: master@xxx.com

  4. Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): y

  5. does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 1
  6. does this host offer datalink/subnetwork services (eg, like a bridge): 0
  7. does this host offer internet services (eg, supports IP): 1
  8. does this host offer end-to-end services (eg, supports TCP): 1
  9. does this host offer application services (eg, supports SMTP): 1

  10. Do you want to configure the agent's access control? (default = y): y
  11. Do you want to allow SNMPv3 read-write user based access (default = y): n
  12. Do you want to allow SNMPv3 read-only user based access (default = y): n
  13. Do you want to allow SNMPv1/v2c read-write community access (default = y): n
  14. Do you want to allow SNMPv1/v2c read-only community access (default = y): y

  15. The community name to add read-only access for: cme
  16. The hostname or network address to accept this community name from [RETURN for all]: localhost
  17. The OID that this community should be restricted to [RETURN for no-restriction]: (RETURN)

  18. Do you want to configure where and if the agent will send traps? (default = y): n

  19. Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): y
  20. Do you want to configure the agents ability to monitor processes? (default = y): y
  21. Name of the process you want to check on: ncftpd
  22. Maximum number of processes named 'ncftpd' that should be running [default = 0]: 100
  23. Minimum number of processes named 'ncftpd' that should be running [default = 0]: 1

  24. Do another proc line? (default = y): n

  25. Do you want to configure the agents ability to monitor disk space? (default = y): y

  26. Enter the mount point for the disk partion to be checked on: /var
  27. Enter the minimum amount of space that should be available on /var: %100

  28. Do another disk line? (default = y): y

  29. Enter the mount point for the disk partion to be checked on: /usr
  30. Enter the minimum amount of space that should be available on /usr: %100

  31. Do another disk line? (default = y): y

  32. Enter the mount point for the disk partion to be checked on: /home
  33. Enter the minimum amount of space that should be available on /home: %100

  34. Do another disk line? (default = y): n

  35. Do you want to configure the agents ability to monitor load average? (default = y): y

  36. Enter the maximum allowable value for the 1 minute load average: 12
  37. Enter the maximum allowable value for the 5 minute load average: 12
  38. Enter the maximum allowable value for the 15 minute load average: 12

  39. Do another load line? (default = y): n
  40. Do you want to configure the agents ability to monitor file sizes? (default = y): n
复制代码

将会生成具有如下内容的snmpd.conf:

  1. syslocation  "Bei Jing, China"
  2. syscontact  master@xxx.com
  3. sysservices 77
  4. rocommunity  cme localhost
  5. proc  ncftpd 100 1
  6. disk  /var %100
  7. disk  /usr %100
  8. disk  /home %100
  9. load  12 12 12
复制代码

注意:请删除无用的说明部分!

之后执行下列命令:
cp snmpd.conf /usr/local/share/snmp/
vi /etc/rc.conf

向该文件添加如下内容:

  1. snmpd_enable="YES"
复制代码

之后执行:
roboot
重新启动计算机。

如启动时控制台出现
Starting snmpd
则证明安装完成

2.        安装和配置mrtg
使用ports安装mrtg,执行下列命令:
cd /usr/ports/net/mrtg
make install
mkdir -p /usr/local/www/data/mrtg/mrtgicons
cd work/mrtg-2.10.13/images
cp * /usr/local/www/data/mrtg/mrtgicons/
cd ../../..
make clean

mrtg软件安装完毕,执行下列命令:
cd /usr/local/etc/mrtg
cp mrtg.cfg.sample mrtg.cfg
vi mrtg.cfg

将mrtg.cfg文件内容修改如下:

  1. LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
  2. WorkDir: /usr/local/www/data/mrtg
  3. Options[_]: growright,bits
  4. Refresh: 300
  5. Interval: 5
  6. IconDir: /mrtg/mrtgicons/
  7. Language: chinese

  8. Target[network]: -1:cme@localhost
  9. MaxBytes[network]: 1250000
  10. Title[network]: Traffic Analysis for My GateWay Server
  11. PageTop[network]: <H1>;Traffic Analysis for My GateWay Server</H1>;
  12. Options[network]: growright, bits
  13. YLegend[network]: Network Traffic
  14. ShortLegend[network]: b/s
  15. Legend1[network]: Incoming Traffic in Bits per Second
  16. Legend2[network]: Outgoing Traffic in Bits per Second
  17. Legend3[network]: Maximal 5 Minute Incoming Traffic
  18. Legend4[network]: Maximal 5 Minute Outgoing Traffic
  19. LegendI[network]: &In:
  20. LegendO[network]: &Out:
  21. Weekformat[network]: V
  22. Background[network]: #738AA6

  23. Target[mem]: memTotalReal.0&memAvailReal.0:cme@localhost
  24. Options[mem]: growright,nopercent,gauge
  25. kmg[mem]:  K,M,G,T
  26. kilo[mem]:  1024
  27. Unscaled[mem]:  dwym
  28. Title[mem]: Memory Statistics: Physical Memory
  29. PageTop[mem]: <h1>;Memory Statistics: Physical Memory</h1>;
  30. MaxBytes[mem]: 131072
  31. Background[mem]: #738AA6
  32. YLegend[mem]: Physical Memory
  33. ShortLegend[mem]: B
  34. LegendI[mem]: Total Memory
  35. LegendO[mem]: Available Memory
  36. Legend1[mem]: Total Memory
  37. Legend2[mem]: Available Memory

  38. Target[cpu]:ssCpuRawUser.0&ssCpuRawUser.0:cme@localhost + \
  39.                  ssCpuRawSystem.0&ssCpuRawSystem.0:cme@localhost + \
  40.                  ssCpuRawNice.0&ssCpuRawNice.0:cme@localhost
  41. RouterUptime[cpu]: cme@localhost
  42. MaxBytes[cpu]:100
  43. Title[cpu]: CPU LOAD of Quake's Gateway Server
  44. PageTop[cpu]:<H1>;CPU LOAD of Quake's Gateway Server</H1>;
  45. Unscaled[cpu]: ymwd
  46. ShortLegend[cpu]: %
  47. YLegend[cpu]: CPU Utilization
  48. LegendI[cpu]: Active
  49. LegendO[cpu]:
  50. Options[cpu]: growright,nopercent
  51. Background[cpu]: #738AA6

  52. Target[usr]:dskPercent.2&dskPercent.2:cme@localhost
  53. RouterUptime[usr]: cme@localhost
  54. MaxBytes[usr]: 100
  55. Title[usr]: /usr USAGE
  56. PageTop[usr]: <H1>;DISK /usr Usage %</H1>;
  57. Unscaled[usr]: ymwd
  58. ShortLegend[usr]: %
  59. YLegend[usr]: DISK Utilization
  60. Legend1[usr]: /usr disk
  61. LegendI[usr]: /usr disk
  62. LegendO[usr]:
  63. Options[usr]: growright,gauge,nopercent
  64. Background[usr]: #738AA6

  65. Target[var]:dskPercent.1&dskPercent.1:cme@localhost
  66. RouterUptime[var]: cme@localhost
  67. MaxBytes[var]: 100
  68. Title[var]: /var USAGE
  69. PageTop[var]: <H1>;DISK /var Usage %</H1>;
  70. Unscaled[var]: ymwd
  71. ShortLegend[var]: %
  72. YLegend[var]: DISK Utilization
  73. Legend1[var]: /var disk
  74. LegendI[var]: /var disk
  75. LegendO[var]:
  76. Options[var]: growright,gauge,nopercent
  77. Background[var]: #738AA6

  78. #----------------------------------------------------------------------
复制代码

执行下列命令生成mrtg首页
cd /usr/local/etc/mrtg/
indexmaker --title "我的网站" --columns 1 --output /usr/local/www/data/mrtg/index.html mrtg.cfg
不变更目录情况下,连续执行三次下列命令,知道不再报错为止:
mrtg mrtg.cfg
使用浏览器访问该位置,页面正常出现,则mrtg安装完毕

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
发表于 2004-04-13 01:06 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

hoho都没人支持一下………………

论坛徽章:
0
发表于 2004-04-13 09:21 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

不行了呗..
首先, net-snmp是在/usr/ports/net-mgmt, 不是在/usr/ports/net..
另外, 偶试了snmpconf -g basic_setup, 不行d..
详细的看看qq...

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
发表于 2004-04-13 13:05 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

原帖由 "kinux" 发表:
不行了呗..
首先, net-snmp是在/usr/ports/net-mgmt, 不是在/usr/ports/net..
另外, 偶试了snmpconf -g basic_setup, 不行d..
详细的看看qq...

第一个确实是,这是以前写的
第二个嘛
我能说你啥呢,只能说你有RPWT

论坛徽章:
0
发表于 2004-04-13 13:15 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

原帖由 "quakelee" 发表:

第一个确实是,这是以前写的
第二个嘛
我能说你啥呢,只能说你有RPWT


倒..
你这傢伙肯定是有RPWT       ~~~
如果你再试试就知道了..     你的资料太旧了, 偶也试过了mrtg, 沒问题是以前d.. 现在嘛, 要再试试看罗...

# snmpconf -g basic_setup
Not enough arguments for mkdir at /usr/local/bin/snmpconf line 174, near ""$ENV{HOME}/.snmp""
Execution of /usr/local/bin/snmpconf aborted due to compilation errors.

论坛徽章:
0
发表于 2004-04-15 19:25 |显示全部楼层

FreeBSD上安装net-snmp和mrtg


  1. Target[network]: -1:cme@localhost
复制代码

这个对吗?好像-1这个设备编号是不对的哦

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
发表于 2004-04-15 20:12 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

-1是指流量,你可以自己看一下
/usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
这个文件

论坛徽章:
1
操作系统版块每日发帖之星
日期:2016-04-01 06:20:00
发表于 2004-04-16 13:46 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

我曾经按照楼主的配置文件来搞,可是cpu和hd的显示不了!
cpu那部分出错,搞不定!
后来看了一下man,然后搞出来一个mrtg的配置,提供参考!
### Global Config Options

LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
WorkDir: /usr/local/www/data/mrtg

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
Options[_]: growright, bits
Refresh: 300
Interval: 5
IconDir: /mrtg/mrtgicons/
Language: gb2312
EnableIPv6: no

######################################################################
# System: fzfh
# Description: FreeBSD fzfh : Fri Apr  9 23:46:55 GMT 2004     dawnxm@fzfh
# Contact: dawnxm@bsdmail.org
# Location: "Nan Ning, China"
######################################################################


### Interface 1 >;>; Descr: 'rl0' | Name: '' | Ip: '192.168.0.1' | Eth: '' ###

Target[localhost_1]: 1:fzfh@localhost:
SetEnv[localhost_1]: MRTG_INT_IP="192.168.0.1" MRTG_INT_DESCR="rl0"
MaxBytes[localhost_1]: 1250000
Title[localhost_1]: Traffic Analysis for 1 --fzfh
PageTop[localhost_1]: <H1>;Traffic Analysis for 1 --fzfh</H1>;
YLegend[localhost_1]: Network Traffic for 1 --fzfh
ShortLegend[localhost_1]: b/s
Legend1[localhost_1]: Incoming Traffic in Bits per Second
Legend2[localhost_1]: Outgoing Traffic in Bits per Second
Legend3[localhost_1]: Maximal 5 Minute Incoming Traffic
Legend4[localhost_1]: Maximal 5 Minute Outgoing Traffic
LegendI[localhost_1]: &In:
LegendO[localhost_1]: &Out:
Weekformat[localhost_1]: V
Background[localhost_1]: #738AA6
<TABLE>;
   <TR>;<TD>;System:</TD>;     <TD>;fzfh in "Nan Ning, China"</TD>;</TR>;
   <TR>;<TD>;Maintainer:</TD>; <TD>;dawnxm@bsdmail.org</TD>;</TR>;
   <TR>;<TD>;Description:</TD>;<TD>;rl0  </TD>;</TR>;
   <TR>;<TD>;ifType:</TD>;     <TD>;ethernetCsmacd (6)</TD>;</TR>;
   <TR>;<TD>;ifName:</TD>;     <TD>;</TD>;</TR>;
   <TR>;<TD>;Max Speed:</TD>;  <TD>;12500.0 kBytes/s</TD>;</TR>;
</TABLE>;


### Interface 2 >;>; Descr: 'rl1' | Name: '' | Ip: '' | Eth: '' ###

Target[localhost_2]: 2:fzfh@localhost:
SetEnv[localhost_2]: MRTG_INT_IP="" MRTG_INT_DESCR="rl1"
MaxBytes[localhost_2]: 1024000
Title[localhost_2]: Traffic Analysis for 2 -- fzfh
PageTop[localhost_2]: <H1>;Traffic Analysis for 2 -- fzfh</H1>;
YLegend[localhost_2]: Network Traffic for 2 --fzfh
ShortLegend[localhost_2]: b/s
Legend1[localhost_2]: Incoming Traffic in Bits per Second
Legend2[localhost_2]: Outgoing Traffic in Bits per Second
Legend3[localhost_2]: Maximal 5 Minute Incoming Traffic
Legend4[localhost_2]: Maximal 5 Minute Outgoing Traffic
LegendI[localhost_2]: &In:
LegendO[localhost_2]: &Out:
Weekformat[localhost_2]: V
Background[localhost_2]: #738AA6
<TABLE>;
   <TR>;<TD>;System:</TD>;     <TD>;fzfh in "Nan Ning, China"</TD>;</TR>;
   <TR>;<TD>;Maintainer:</TD>; <TD>;dawnxm@bsdmail.org</TD>;</TR>;
   <TR>;<TD>;Description:</TD>;<TD>;rl1  </TD>;</TR>;
   <TR>;<TD>;ifType:</TD>;     <TD>;ethernetCsmacd (6)</TD>;</TR>;
   <TR>;<TD>;ifName:</TD>;     <TD>;</TD>;</TR>;
   <TR>;<TD>;Max Speed:</TD>;  <TD>;1250.0 kBytes/s</TD>;</TR>;
</TABLE>;

#Mem MON
Target[mem]: memTotalReal.0&memAvailReal.0:fzfh@localhost
Options[mem]: growright,nopercent,gauge
kmg[mem]:  K,M,G,T
kilo[mem]:  1024
Unscaled[mem]:  dwym
Title[mem]: Memory Statistics: Physical Memory --fzfh
PageTop[mem]: <h1>;Memory Statistics: Physical Memory --fzfh</h1>;
MaxBytes[mem]: 65536
Background[mem]: #738AA6
YLegend[mem]: Physical Memory
ShortLegend[mem]: B
LegendI[mem]: Total Memory
LegendO[mem]: Available Memory
Legend1[mem]: Total Memory
Legend2[mem]: Available Memory

#CPU MON
Target[cpu]: ssCpuRawUser.0&ssCpuRawUser.0:fzfh@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:fzfh@localhost + ssCpuRawNice.0&ssCpuRawNice.0:fzfh@localhost
RouterUptime[cpu]: fzfh@localhost
MaxBytes[cpu]: 100
Title[cpu]: CPU LOAD --fzfh
PageTop[cpu]: <h1>;CPU Statistics: Active CPU Load % --fzfh</h1>;
ShortLegend[cpu]: %
YLegend[cpu]: CPU Utilization
Legend1[cpu]: Active CPU in % (Load)
Legend2[cpu]:
Legend3[cpu]:
Legend4[cpu]:
LegendI[cpu]:  已使用
LegendO[cpu]:

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
发表于 2004-04-16 23:10 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

Target[cpu]:ssCpuRawUser.0&ssCpuRawUser.0:cme@localhost + \
                 ssCpuRawSystem.0&ssCpuRawSystem.0:cme@localhost + \
                 ssCpuRawNice.0&ssCpuRawNice.0:cme@localhost

ssCpuRawUser.0&ssCpuRawUser.0:fzfh@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:fzfh@localhost + ssCpuRawNice.0&ssCpuRawNice.0:fzfh@localhost

劳驾,咱俩写的这个配置有什么区别呀,你仔细看看,除了用户不一样,使用的SNMP变量一摸一样,除了我用转义符换行了…………
磁盘那个,我不知道你仔细看我的snmpd.conf了没有,如果需要snmp提供磁盘信息的时候,需要在里面做个配置,客户端才能读出来,否则不行

论坛徽章:
1
操作系统版块每日发帖之星
日期:2016-04-01 06:20:00
发表于 2004-04-17 13:47 |显示全部楼层

FreeBSD上安装net-snmp和mrtg

我们写的是没有什么差别,当初我是直接拷贝你的来用的,结果就是不行,总在cpu和hd那里出错。就是那一个“+ \”转义符换行这里有问题。
后来删去那些东西就ok了。
还有我在snmpd.conf配置了hd的东东,但是就是显示不了,无奈之下只好暂时删除了hd那一部分。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP