顯示具有 snmp 標籤的文章。 顯示所有文章
顯示具有 snmp 標籤的文章。 顯示所有文章

2014年11月11日 星期二

Ubuntu install snmpd

# apt-get install snmp snmpd

# vi /etc/snmp/snmpd.conf
#  Listen for connections from the local system only
#agentAddress  udp:127.0.0.1:161
#  Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
# /etc/init.d/snmpd restart




References :
How To Install and Configure an SNMP Daemon and Client on Ubuntu 14.04 | DigitalOcean

 

2014年8月21日 星期四

Python SNMP trap receiver 範例

PySNMP Examples: Native/low-level API to SNMPv1/v2c operartions

snmptrapd 接收 trap 設定

# apt-get install snmptrapd 
# vi /etc/default/snmptrapd
TRAPDRUN=yes

# 預設 log 儲存在 syslog,若要更改要指定 -Lf
TRAPDOPTS='-Lsd -p /run/snmptrapd.pid -Lf /var/log/snmptrapd.log'

# vi /etc/snmp/snmptrapd.conf
format1 "%a %N %T"                                                                                        
authCommunity log public
authCommunity execute public
traphandle default /usr/bin/php /tmp/snmptrap.php
disableAuthorization yes


發送 trap 測試
$ snmptrap -v 1 -c public 127.0.0.1 '' 127.0.0.1 6 1 '1111'




References :

2014年6月28日 星期六

SNMP 概念

管理者 Manager (Server)
代理者 Agent (Client)


SNMP Version :
1, 2c, 3
3 : 確保 community 間通訊均爲加密
 
 
SNMP Community :
類似密碼
預設 "public" community 具有 read-only 功能
預設 "private" community 具有 read-write 以及讀取某些限制性數值的功能


管理者以 snmpget, snmpwalk 向代理者要求值
管理者以 snmpset 向代理者傳送值
代理者以 snmptrap 向管理者 snmptrapd 主動傳送值 (如:電池電量低訊息)

2014年2月22日 星期六

mbrowser configure: error: SNMP checks failed

***
*** Found snmp headers, but could not locate the libraries.
***
*** Try using the following switch:
***   --with-snmp-prefix=PFX
***   --with-snmp-lib=DIR
***
configure: error: SNMP checks failed




# apt-get install libsnmp-mib-compiler-perl

2014年2月15日 星期六

python snmp

pysnmp :
pysnmp : getCmd, setCmd, nextCmdsnmp <---> get-request, set-request, get-next-request

# pip install pysnmp 

from pysnmp.entity.rfc3413.oneliner import cmdgen

errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd(
      cmdgen.CommunityData('my-agent', 'public', 0),                                                                  
      cmdgen.UdpTransportTarget(('192.168.1.8', 161)),
      'iso.3.6.1.2.1.1.1.0'
      )
print varBinds

netsnmp:
# apt-get install python-netsnmp

import netsnmp

session = netsnmp.Session(DestHost='192.168.1.8', Version=1 , Community='public')                      
vars = netsnmp.VarList(netsnmp.Varbind('iso.3.6.1.2.1.1.1.0'))
print(session.get(vars))





References :
pysnmp学习(一) - AncerHaides的专栏 - 博客频道 - CSDN.NET
http://ben.akrin.com/?p=1234
http://stackoverflow.com/questions/8601324/how-to-get-data-form-snmp-with-python

Linux snmpwalk

# apt-get install snmp

$ snmpwalk -v1 -c public 192.168.1.4 
$ snmpwalk -v1 -c public 192.168.1.4 iso.3.6.1.2.1.1.1.0




References :
SNMP - Debian Wiki
Probing a device: SNMP WALKs

2011年11月12日 星期六

snmp 測試

確定安裝、啟動 snmpd 或 net-snmpd

# netstat -anlup | grep 161
udp        0      0 0.0.0.0:161             0.0.0.0:*                           4756/snmpd

使用 snmpwalk 獲取資料
$ snmpwalk -v 2c -c your_community(public) localhost [MIB|OID]