linux指令, 架設等
文章: 1302
註冊時間: 2008年 11月 26日, 00:49


文章 tim » 2012年 8月 1日, 19:29

引用自: http://blog.up-link.ro/freebsd-how-to-i ... n-freebsd/

Simple Network Management Protocol (SNMP) is a UDP-based network protocol. It is used in network management systems to monitor network-attached devices for conditions that warrant administrative attention.

1. SNMP installation using ports

Install net-snmp using this commands:

# cd /usr/ports/net-mgmt/net-snmp
# make install clean


2. SNMP basic configuration

Copy the default configuration file to the right location.

# cp /usr/local/share/snmp/snmpd.conf.example /usr/local/etc/snmpd.conf

Open /usr/local/etc/snmpd.conf and set up the community and network access.

Click here to download an example configuration file.

Open /etc/rc.conf in your favorite editor and make sure snmpd is enabled:


Type the following command to start snmpd:

# /usr/local/etc/rc.d/snmpd start

At this point you should be able to snmpwalk your host

# snmpwalk -v1 -c public

This will get you up and running with a basic snmp configuration. Next, we'll use snmpconf utility to set up an advanced configration. The next step is optional.

3. SNMP advanced configuration using snmpconf

There is a handy utility called 'snmpconf' that can be run to help you generate the snmp.conf (optional) and snmpd.conf files. This will give you more options and help you with the security.

# snmpconf -i

I can create the following types of configuration files for you.
Select the file type you wish to create:

1: snmp.conf
2: snmptrapd.conf
3: snmpd.conf

snmp.conf dictates how Net-SNMP applications should operate, snmptrapd.conf configures the snmptrapd daemon which is used for ongoing monitoring via SNMP, and snmpd.conf defines how the snmp daemon which we will be using, is configured.
Choose option '3'.

The main menu:

1: System Information Setup
2: Access Control Setup
3: Trap Destinations
4: Monitor Various Aspects of the Running Host
5: Extending the Agent
6: Agent Operating Mode

Choose option '1', and at the 'System Information Setup' menu, choose '1' again. You will be asked to enter the location of your system. This can be the country, locality, site name, or any other data you would use to describe the location of the system. After you enter this, you will be returned to the 'System Information Setup' menu.
Choose option '2' and enter the contact information for the administrator of the machine.
Finally, when you choose option '3', you will be asked a number of "Yes/No" questions to determine what the proper value for the sysServices object. This is used to determine what services your machine offers. Reply with a '1' for yes, or '0' for no.
When you are done with the 'System Information Setup' menu, type 'finished' to return to the main menu.

From the main menu, choose option '2' for 'Access Control Setup'

1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name

For the purpose of simplicity, we will set up a read-only SNMPv1 server which listens only on localhost. SNMPv2 and v3 provide some added security in the form of user names and passwords.
To continue, choose option '3'. You will be asked to enter a community name for read-only access. This can be any one-word string you wish (for example pub), and is simply used as a weak method of authentication to restrict access to the service.
Then choose 'localhost' as the hostname from which to accept that community string, and press ENTER for no-restrictions on what the user of that community string can read.

Next we will confirm where the daemon should be listening. From the main menu, choose option '6' for 'Agent Operating Mode'

1: Should the agent operate as a master agent or not.
2: The system user that the agent runs as.
3: The system group that the agent runs as.
4: The IP address and port number that the agent will listen on.

Choose option '4', and enter as the address at which snmpd will listen. Return to the main menu, and choose 'finished' again. You will be shown to the original menu asking which file you would like to edit. choose to 'quit'.

Finally, we have to copy the configuration to the right location and then restart snmpd:

# cp /usr/local/share/snmp/snmpd.conf /usr/local/etc/snmpd.conf
# /usr/local/etc/rc.d/snmpd restart.
多多留言, 整理文章, 把經驗累積下來.....

文章: 1302
註冊時間: 2008年 11月 26日, 00:49

Re: [FreeBSD]安裝及啟動snmpd服務

文章 tim » 2015年 9月 29日, 10:58

CentOS 的 snmpd 服務安裝與起動 - http://www.liquidweb.com/kb/how-to-inst ... on-centos/

for snmpd.conf

代碼: 選擇全部

# Map 'idv90we3rnov90wer' community to the 'ConfigUser'
# Map '209ijvfwer0df92jd' community to the 'AllUser'
#       sec.name        source          community
com2sec ConfigUser      default         idv90we3rnov90wer
com2sec AllUser         default         209ijvfwer0df92jd
# Map 'ConfigUser' to 'ConfigGroup' for SNMP Version 2c
# Map 'AllUser' to 'AllGroup' for SNMP Version 2c
#                       sec.model       sec.name
group   ConfigGroup     v2c             ConfigUser
group   AllGroup        v2c             AllUser
# Define 'SystemView', which includes everything under . (or .
# Define 'AllView', which includes everything under .1
#                       incl/excl       subtree
view    SystemView      included        .
view    SystemView      included        .
view    AllView         included        .1
# Give 'ConfigGroup' read access to objects in the view 'SystemView'
# Give 'AllGroup' read access to objects in the view 'AllView'
#                       context model   level   prefix  read            write   notify
access  ConfigGroup     ""      any     noauth  exact   SystemView      none    none
access  AllGroup        ""      any     noauth  exact   AllView         none    none
多多留言, 整理文章, 把經驗累積下來.....

文章: 1302
註冊時間: 2008年 11月 26日, 00:49

Re: [FreeBSD]安裝及啟動snmpd服務

文章 tim » 2015年 9月 29日, 13:07

UBUNTU 安裝 snmpd



代碼: 選擇全部

agentAddress  udp:
rocommunity mycomm
syslocation somewhere
syscontact [email protected]
restart: /etc/init.d/snmpd restart
多多留言, 整理文章, 把經驗累積下來.....