闻道有先后 术业有专攻

[首页] [邮件] [博客] [相册] [笔记] [手册] [软件] [链接] [文档] [安全] [朋友] [电影] [公共] [工具]

SNMP

ߣCameron Laird 
NSFocus Security Team
siteupdate.magazine
ҳhttp://www.nsfocus.com
ڣ2002-04-12


 лл stardust  ṩIJԻԼPerlűϵİ


 SNMPʷ

SNMPǼЭд

ϸ80ڣͨʹpingtraceroutetcpdumpԼƵĹ
ߡʱģСԶûкôӡ1987꣬ Request For
Comments (RFC) 1024"Simple Gateway Monitoring Protocol"(SGMP)SGMP
һƽ̨޹صı׼ڼص״̬ԼRFC 1067
SNMP

 SNMP͸

ASN.1: һSNMPϢͨ﷨Ƿ1(Abstract Syntax Notation, version 1)
졣ASN.1һʽԡ

BER : ASN.1ʾoctet stringsĻ

MIB : Ϣ⡣һ

sysUpTime OBJECT-TYPE
SYNTAX TimeTicks
ACCESS read-only
STATUS mandatory
DESCRIPTION 
"һϵͳʱ"

OID : ʶΨһĵִ".1.3.6.1.2.1.4.3.0"

PDU : ЭݵԪSNMPϢе

SMI : ϢṹһSNMPηϢı׼ASN.1MIB
SMIҪÿnamesyntaxencoding֡־OID﷨
ͣ"integer""string of octets"ȵȡָΪ
˽ƽ̨޹תνݵл(RPC/XDRдƸ)

 SNMP

SNMP豸֮ͻ/ģʽļͨЭ顣·ӡ
HUBȵȶԳΪSNMPϵͳеķSNMPϵͳеĿͻǵ
һ̨ѯ豸¼صݡһ̨
ͻΡ

SNMPúٵڴռܶõϵͳݡ

SNMPṩһͳһġƽ̨豸취

 NET-SNMP

Դhttp://net-snmp.sourceforge.net/ȡNET-SNMPRPMԼԴ롣
ѹ

su -
cd ucd-snmp-4.2.3
./configure --prefix=/usr 

-- ȱʡ/usr/local
make clean all
make install

 ռ

SNMP agentSNMPϵͳеĵķǰInternetϵɼSNMP agent
ڳڰȫԭ򣬷ǽõõǿֻLANڲSNMPˡ

snmpget  public system.sysDescr.0

ӦÿԿһϵͳļ

system.sysDescr.0 = Sun SNMP Agent, Ultra-60

еpublicΪSNMP agentĿ"community string"
豸ϵͳ"public"Ϊȱʡ"community string"DZڴȫ
⡣Ӧ޸ȱʡ"community string"

д

snmpget  public .1.3.6.1.2.1.1.1.0

"system.sysDescr.0"ֻ".1.3.6.1.2.1.1.1.0"һֱʽջҪת
ʽOID(ʶ)FQDNIPַĹϵ

DNSϵͳFQDNIP֮תSNMPͨϢ(MIB)תMIB
һıļܶSNMPϢаOIDתϢMIBsйõģҲ
רõġRFC 1213sysDescrOIDssysUpTime(һ
ϵͳʱ)sysLocation(豸λ). 

MIBs

snmptranslate -Td -OS system.sysDescr.0

-----------------------------------------------------------------------
.1.3.6.1.2.1.1.1.0
sysDescr OBJECT-TYPE
-- FROM SNMPv2-MIB, RFC1213-MIB
-- TEXTUAL CONVENTION DisplayString
SYNTAX OCTET STRING (0..255) 
DISPLAY-HINT "255a"
MAX-ACCESS read-only
STATUS current
DESCRIPTION "A textual description of the entity. This value should
include the full name and version identification of the
system's hardware type, software operating-system, and
networking software."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) sysDescr(1) 0 }
------------------------------------------------------------------------

snmptranslateҲOIDıת

snmptranslate -Td -OS .1.3.6.1.2.1.1.1.0

һ̨x86/FreeBSD 4.3-RELEASE

snmpwalk localhost public interfaces.ifTable.ifEntry.ifDescr
snmpwalk localhost public .1.3.6.1.2.1.2.2.1.2

--------------------------------------------------------------------------
interfaces.ifTable.ifEntry.ifDescr.1 = fxp0
interfaces.ifTable.ifEntry.ifDescr.2 = fxp1
interfaces.ifTable.ifEntry.ifDescr.3 = fxp2
interfaces.ifTable.ifEntry.ifDescr.4 = lo0
--------------------------------------------------------------------------

ʾ˳/sbin/ifconfig -lһ¡

snmptranslate -Td -OS interfaces.ifTable.ifEntry.ifDescr.1

--------------------------------------------------------------------------
.1.3.6.1.2.1.2.2.1.2.1
ifDescr OBJECT-TYPE
-- FROM IF-MIB, RFC1213-MIB
-- TEXTUAL CONVENTION DisplayString
SYNTAX OCTET STRING (0..255) 
DISPLAY-HINT "255a"
MAX-ACCESS read-only
STATUS current
DESCRIPTION "A textual string containing information about the
interface. This string should include the name of the
manufacturer, the product name and the version of the
interface hardware/software."
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) interfaces(2) ifTable(2) ifEntry(1) ifDescr(2) 1 }
--------------------------------------------------------------------------

 SNMP

NET-SNMPṩ֧SNMPC⣬ԿԼSNMPӦóȻPerl
PythonTclĽűԿʼSNMP̸ףǶSNMP֧֡

--------------------------------------------------------------------------
#! /usr/local/bin/perl
#
# File : list_if.pl
# Test : SPARC/Solaris 7
# Author : Laurent Girod / Philip Morris Products S.A. / Neuchatel / Switzerland
#

use BER;
use SNMP_util "0.92";

# Uptime in absolute value
$BER::pretty_print_timeticks = 0;

my $host = shift @ARGV || &usage;
my $community = shift @ARGV || 'public';
&usage if $#ARGV >= 0;
$host = "$community\@$host" if !( $host =~ /\@/ );

my $oid_name = 'interfaces.ifTable.ifEntry.ifDescr';

print "\nCollecting [$oid_name]\n";
@ret = &snmpwalk( $host, $oid_name );
foreach $desc ( @ret )
{
( $oid, $desc ) = split( ':', $desc, 2 );
print "$oid = $desc\n";
}

sub usage
{
die "Usage: $0 hostname [community]\n";
}
--------------------------------------------------------------------------

ע: ΪPerl򣬿ҪذװSNMP_Session-0.92.tar.gzԻȡ
PerlչģSNMP_util.pm

űоָӿڣ/sbin/ifconfig -a˳һ

# ./list_if.pl public@localhost
-- ӴпԿ÷

Collecting [interfaces.ifTable.ifEntry.ifDescr]
1 = lo0
2 = hme0
#

"community@host"snmpwalk()һβҪĸʽ

 ȱ

SNMPصͬʱصİȫȱݡSNMPִ
Ļ߻XMLݷdzѡSNMPιϵͳԱͳ
Աʵ̫ˡ

ܴ⣬SNMPƻǴڡЩʱSNMPv3RFC̨
صİȫȱݡ

 οԴ

1) The NET-SNMP Project Home Page (source code is available from this site)
http://net-snmp.sourceforge.net/

2) MRTG: The Multi Router Traffic Grapher
http://www.mrtg.org/

3) Big Brother System and Network Monitor
http://maclawran.ca/bb-dnld

4) The Distributed Management Task Force, Inc. (DMTF)
http://www.dmtf.org/

5) Web-Based Enterprise Management (WBEM) Initiative
http://www.dmtf.org/standards/standard_wbem.php 

6) SNMP4tPC -- SNMP RFC Information and Links
http://www.wtcs.org/snmp4tpc/snmp_rfc.htm

7) Essential SNMP
http://www.oreilly.com/catalog/esnmp 

8) Index of the CPAN (Perl) SNMP Library Directory
http://www.cpan.org/modules/by-module/SNMP

9) RFC 1213 -- MIBs
http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc1213.html



[Docs]

OpenBSD FAQ
Rsync Manual
OpenBSD Installation Guide
使用NetMeeting远程协助
Coda分布式文件系统
coda的安装和配置
Linux下的逻辑卷管理
LVS项目介绍
LVS集群的体系结构
LVS集群中的IP负载均衡技术
LVS集群的负载调度
FTP的安全扩展
FTP安全考虑
用rsync对网站进行镜像备份
使用FileZilla进行加密的FTP协议认证
OpenAFS 帮助聚集分布式数据

域名BSDMAP.COM于2005年申请,BSDMAP.ORG于2006年申请。
本站由花开于07/26/2004建立.其建立的目的纯粹是为了研究、学习系统应用技术.