ich stehe vor folgendem Problem.
Ich möchte mit Hilfe von Net-SNMP einen eigenen SNMP-Agent in perl schreiben, der auf Anfragen antwortet. Zum Testen verwende ich aktuell einen Beispiel Agent, den ich jedoch schon nicht korrekt ans Laufen bringen kann.
Anbei meine Konfiguration:
Code: Alles auswählen
ors /etc/snmp/snmpd.conf
agentAddress udp:127.0.0.1:161
# system + hrSystem groups only
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
view all included .1.3.6.1.4.1.8072.9999.9999.123
view all included .1.3.6.1.4.1.8072.999
view all included .1.3.6.1.4.1.39178.100.1.1.1.2
# Full access from the local host
# Default access to basic system info
rocommunity public default -V systemonly
# Full access from an example network
# Adjust this network address to match your local
# settings, change the community string,
# and check the 'agentAddress' setting above
# Full read-only access for SNMPv3
rouser authOnlyUser
# Full write access for encrypted requests
# Remember to activate the 'createUser' lines above
sysLocation Sitting on the Dock of the Bay
sysContact Me <me@example.org>
# Application + End-to-End layers
sysServices 72
# At least one 'mountd' process
proc mountd
# No more than 4 'ntalkd' processes - 0 is OK
proc ntalkd 4
# At least one 'sendmail' process, but no more than 10
proc sendmail 10 1
# 10MBs required on root disk, 5% free on /var, 10% free on all other disks
disk / 10000
disk /var 5%
includeAllDisks 10%
# Unacceptable 1-, 5-, and 15-minute load averages
load 12 10 5
# send SNMPv1 traps
trapsink localhost public
# send SNMPv2c traps
# send SNMPv2c INFORMs
# Remember to activate the 'createUser' lines above
iquerySecName internalUser
rouser internalUser
# generate traps on UCD error conditions
defaultMonitors no
# generate traps on linkUp/Down
linkUpDownNotifications yes
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
extend eth0-names /home/duff/scripts/BT/ethtool-stats eth0 names
pass .1.3.6.1.4.1.8072.9999.9999.123 /usr/bin/perl /home/duff/scripts/BT/simple-snmp-agent.pl
# Run as an AgentX master agent
master agentx
# Listen for network connections (from localhost)
# rather than the default named socket /var/agentx/master
agentXSocket tcp:localhost:705
Code: Alles auswählen
cat simple-snmp-agent.pl
#!/usr/bin/perl
use SNMP::Agent;
use NetSNMP::ASN qw/ASN_GAUGE/;
sub do_one { return int(rand(10)) }
sub do_two { return "two" }
my $root_oid = '1.3.6.1.4.1.8072.9999.9999.123';
my %handlers = (
'1' => { handler => \&do_one, type => ASN_GAUGE },
'2' => { handler => \&do_two }, # default type ASN_OCTET_STR
);
my $agent = new SNMP::Agent('my_agent', $root_oid, \%handlers);
$agent->run();
Code: Alles auswählen
./simple-snmp-agent.pl
NET-SNMP version 5.4.3 AgentX subagent connected
Code: Alles auswählen
duff@squeeze:~/.snmp/mibs$ snmpget -v1 -c public localhost .1.3.6.1.4.1.8072.9999.9999.123
Error in packet
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: NET-SNMP-MIB::netSnmpPlaypen.123
duff@squeeze:~/.snmp/mibs$
Code: Alles auswählen
Feb 15 11:36:12 marge snmpd[31989]: Connection from UDP: [127.0.0.1]:58049->[127.0.0.1]
Kann mir jemand weiterhelfen???
Danke.