- 论坛徽章:
- 1
|
安装net-snmpd和mrtg手册
1. 安装和配置net-snmpd
首先使用ports安装net-snmpd,使用如下命令:
cd /usr/ports/net/net-snmp
make install clean
安装完毕之后使用如下命令对snmpd进行配置:
snmpconf -g basic_setup
将会出现一个询问菜单,按如下步骤进行回答:
- Do you want to configure the information returned in the system MIB group (contact info, etc)? (default = y): y
- The location of the system: Bei Jing, China
- The contact information: master@xxx.com
- Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): y
- does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 1
- does this host offer datalink/subnetwork services (eg, like a bridge): 0
- does this host offer internet services (eg, supports IP): 1
- does this host offer end-to-end services (eg, supports TCP): 1
- does this host offer application services (eg, supports SMTP): 1
- Do you want to configure the agent's access control? (default = y): y
- Do you want to allow SNMPv3 read-write user based access (default = y): n
- Do you want to allow SNMPv3 read-only user based access (default = y): n
- Do you want to allow SNMPv1/v2c read-write community access (default = y): n
- Do you want to allow SNMPv1/v2c read-only community access (default = y): y
- The community name to add read-only access for: cme
- The hostname or network address to accept this community name from [RETURN for all]: localhost
- The OID that this community should be restricted to [RETURN for no-restriction]: (RETURN)
- Do you want to configure where and if the agent will send traps? (default = y): n
- Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): y
- Do you want to configure the agents ability to monitor processes? (default = y): y
- Name of the process you want to check on: ncftpd
- Maximum number of processes named 'ncftpd' that should be running [default = 0]: 100
- Minimum number of processes named 'ncftpd' that should be running [default = 0]: 1
- Do another proc line? (default = y): n
- Do you want to configure the agents ability to monitor disk space? (default = y): y
- Enter the mount point for the disk partion to be checked on: /var
- Enter the minimum amount of space that should be available on /var: %100
- Do another disk line? (default = y): y
- Enter the mount point for the disk partion to be checked on: /usr
- Enter the minimum amount of space that should be available on /usr: %100
- Do another disk line? (default = y): y
- Enter the mount point for the disk partion to be checked on: /home
- Enter the minimum amount of space that should be available on /home: %100
- Do another disk line? (default = y): n
- Do you want to configure the agents ability to monitor load average? (default = y): y
- Enter the maximum allowable value for the 1 minute load average: 12
- Enter the maximum allowable value for the 5 minute load average: 12
- Enter the maximum allowable value for the 15 minute load average: 12
- Do another load line? (default = y): n
- Do you want to configure the agents ability to monitor file sizes? (default = y): n
复制代码
将会生成具有如下内容的snmpd.conf:
- syslocation "Bei Jing, China"
- syscontact master@xxx.com
- sysservices 77
- rocommunity cme localhost
- proc ncftpd 100 1
- disk /var %100
- disk /usr %100
- disk /home %100
- load 12 12 12
复制代码
注意:请删除无用的说明部分!
之后执行下列命令:
cp snmpd.conf /usr/local/share/snmp/
vi /etc/rc.conf
向该文件添加如下内容:
之后执行:
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文件内容修改如下:
- LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
- WorkDir: /usr/local/www/data/mrtg
- Options[_]: growright,bits
- Refresh: 300
- Interval: 5
- IconDir: /mrtg/mrtgicons/
- Language: chinese
- Target[network]: -1:cme@localhost
- MaxBytes[network]: 1250000
- Title[network]: Traffic Analysis for My GateWay Server
- PageTop[network]: <H1>;Traffic Analysis for My GateWay Server</H1>;
- Options[network]: growright, bits
- YLegend[network]: Network Traffic
- ShortLegend[network]: b/s
- Legend1[network]: Incoming Traffic in Bits per Second
- Legend2[network]: Outgoing Traffic in Bits per Second
- Legend3[network]: Maximal 5 Minute Incoming Traffic
- Legend4[network]: Maximal 5 Minute Outgoing Traffic
- LegendI[network]: &In:
- LegendO[network]: &Out:
- Weekformat[network]: V
- Background[network]: #738AA6
- Target[mem]: memTotalReal.0&memAvailReal.0:cme@localhost
- Options[mem]: growright,nopercent,gauge
- kmg[mem]: K,M,G,T
- kilo[mem]: 1024
- Unscaled[mem]: dwym
- Title[mem]: Memory Statistics: Physical Memory
- PageTop[mem]: <h1>;Memory Statistics: Physical Memory</h1>;
- MaxBytes[mem]: 131072
- 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
- Target[cpu]:ssCpuRawUser.0&ssCpuRawUser.0:cme@localhost + \
- ssCpuRawSystem.0&ssCpuRawSystem.0:cme@localhost + \
- ssCpuRawNice.0&ssCpuRawNice.0:cme@localhost
- RouterUptime[cpu]: cme@localhost
- MaxBytes[cpu]:100
- Title[cpu]: CPU LOAD of Quake's Gateway Server
- PageTop[cpu]:<H1>;CPU LOAD of Quake's Gateway Server</H1>;
- Unscaled[cpu]: ymwd
- ShortLegend[cpu]: %
- YLegend[cpu]: CPU Utilization
- LegendI[cpu]: Active
- LegendO[cpu]:
- Options[cpu]: growright,nopercent
- Background[cpu]: #738AA6
- Target[usr]:dskPercent.2&dskPercent.2:cme@localhost
- RouterUptime[usr]: cme@localhost
- MaxBytes[usr]: 100
- Title[usr]: /usr USAGE
- PageTop[usr]: <H1>;DISK /usr Usage %</H1>;
- Unscaled[usr]: ymwd
- ShortLegend[usr]: %
- YLegend[usr]: DISK Utilization
- Legend1[usr]: /usr disk
- LegendI[usr]: /usr disk
- LegendO[usr]:
- Options[usr]: growright,gauge,nopercent
- Background[usr]: #738AA6
- Target[var]:dskPercent.1&dskPercent.1:cme@localhost
- RouterUptime[var]: cme@localhost
- MaxBytes[var]: 100
- Title[var]: /var USAGE
- PageTop[var]: <H1>;DISK /var Usage %</H1>;
- Unscaled[var]: ymwd
- ShortLegend[var]: %
- YLegend[var]: DISK Utilization
- Legend1[var]: /var disk
- LegendI[var]: /var disk
- LegendO[var]:
- Options[var]: growright,gauge,nopercent
- Background[var]: #738AA6
- #----------------------------------------------------------------------
复制代码
执行下列命令生成mrtg首页
cd /usr/local/etc/mrtg/
indexmaker --title "我的网站" --columns 1 --output /usr/local/www/data/mrtg/index.html mrtg.cfg
不变更目录情况下,连续执行三次下列命令,知道不再报错为止:
mrtg mrtg.cfg
使用浏览器访问该位置,页面正常出现,则mrtg安装完毕 |
|