RE: Stuck in the way of quering a private MIB (extension using perl)
"Chayvialle, Daniel (External)" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <8547EEE12ED66942A5870CB421AEAC733F6343@SMFIDF806B.main.fr.ds.corp> |
I have read the FAQ you mentioned, as well as other related to this topic a few days ago, and I can't says it was all clear to me. OK, so here are the said files in full version, including changes you suggested below. Daniel -----Message d'origine----- De : [email protected] [mailto:[email protected]] De la part de Dave Shield Envoyé : mercredi 6 juin 2012 15:14 À : Chayvialle, Daniel (External) Cc : [email protected] Objet : Re: Stuck in the way of quering a private MIB (extension using perl) On 6 June 2012 14:02, Chayvialle, Daniel (External) <[email protected]> wrote: > My intention was to have a perl sub-agent. The pass version was added > just in case it would work by chance (the kind of things that rarely happen, > but for which I get blamed if I don't try). Fair enough - but I have to say that it was wildly optimistic. The pass-through mechanism and the perl-subagent approach are completely different, and use very different styles of coding. If you're using the perl sub-agent, then stick with that. > The access control settings are > > % ls -l .snmp/mibs/tcs-agent-module.pl ~ > -rw-rw-r-- 1 daniel daniel 3134 5 juin 14:51 .snmp/mibs/tcs-agent-module.pl > % ls -l /etc/snmp/snmpd.conf ~ > -rw------- 1 root root 7362 6 juin 10:05 /etc/snmp/snmpd.conf No. That's not what I meant. What are the access control settings *within* the snmpd.conf file. Have you read the FAQ entry that I mentioned yet? > The TCS-MIB as you'd expect from below in my mail in the said private MIB. > > Here is an extract from the ~/.snmp/mibs/TCS-MIB.mib file Hmmm... I really dislike being given "extracts" of a file. I never know whether the bits that have been omitted might actually be important. > TCS-MIB DEFINITIONS ::= BEGIN > > IMPORTS > OBJECT-TYPE, MODULE-IDENTITY, enterprises, Integer32, > Counter32, Gauge32, TimeTicks > FROM SNMPv2-SMI > TruthValue, TimeStamp FROM SNMPv2-TC > MODULE-COMPLIANCE,OBJECT-GROUP FROM SNMPv2-CONF > ; > > -- Gauge32 est un alias de Gauge > > -- EnumVal defini comme un alias de INTEGER > EnumVal ::= INTEGER (0..4294967295) > > tcs MODULE-IDENTITY > LAST-UPDATED "201205230000Z" > DESCRIPTION > "Example MIB objects for agent module example implementations" > REVISION "201205230000Z" > DESCRIPTION > "First draft" > ::= { eads 3665 } > -- IANA assigned OID 16304 to EADS, but I can't find this in Cafuro, so it's stated here > eads OBJECT IDENTIFIER ::= { enterprises 16304 } I'm not sure offhand how well the Net-SNMP MIB parser copes with this sort of back-reference. It might be safer to use tcs MODULE-IDENTITY : ::= { enterprises 16304 3665 } > -- > -- test string > -- > tcsTestString OBJECT-TYPE > SYNTAX OctetString > MAX-ACCESS read-write > STATUS current > DESCRIPTION > "This is a test string." > DEFVAL { "et comme ca ca marche?" } > ::= { tcs 0 } Don't use 0 as the final element of an object's OID. This should be positive - typically starting at 1 [See RFC 2578, section 7.10, final para] > After applying what you adviced to the conf files, I still get > > % snmpget -v1 -c public localhost sysDescr.0 sysUpTime.0; snmpget -v1 -c public localhost tcsTestString.0 > SNMPv2-MIB::sysDescr.0 = STRING: Linux debian 2.6.32-5-686 #1 SMP Mon Mar 26 05:20:33 UTC 2012 i686 > DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (5758) 0:00:57.58 > tcsTestString.0: Unknown Object Identifier (Sub-id not found: (top) -> tcsTestString) Don't be so hasty. We know that you can query the system group, but you still haven't checked whether you can query other standard objects. Don't even think about looking at your TCS-MIB objects until something like snmpgetnext -v1 -c public localhost ifName works. Dave ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
snmpd.conf
(application/octet-stream, 7.2 KB)
###############################################################################
#
# EXAMPLE.conf:
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
# See the 'snmpd.conf(5)' man page for details
#
# Some entries are deliberately commented out, and will need to be explicitly activated
#
###############################################################################
#
# AGENT BEHAVIOUR
#
# 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
###############################################################################
#
# SNMPv3 AUTHENTICATION
#
# Note that these particular settings don't actually belong here.
# They should be copied to the file /var/lib/snmp/snmpd.conf
# and the passwords changed, before being uncommented in that file *only*.
# Then restart the agent
# createUser authOnlyUser MD5 "remember to change this password"
# createUser authPrivUser SHA "remember to change this one too" DES
# createUser internalUser MD5 "this is only ever used internally, but still change the password"
# If you also change the usernames (which might be sensible),
# then remember to update the other occurances in this example config file to match.
###############################################################################
#
# ACCESS CONTROL
#
# 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
# Full access from the local host
#rocommunity public localhost
# 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
#rocommunity secret 10.0.0.0/16
# Full read-only access for SNMPv3
rouser authOnlyUser
# Full write access for encrypted requests
# Remember to activate the 'createUser' lines above
#rwuser authPrivUser priv
# It's no longer typically necessary to use the full 'com2sec/group/access' configuration
# r[ou]user and r[ow]community, together with suitable views, should cover most requirements
###############################################################################
#
# SYSTEM INFORMATION
#
# Note that setting these values here, results in the corresponding MIB objects being 'read-only'
# See snmpd.conf(5) for more details
sysLocation Sitting on the Dock of the Bay
sysContact Me <[email protected]>
# Application + End-to-End layers
sysServices 72
#
# Process Monitoring
#
# 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
# Walk the UCD-SNMP-MIB::prTable to see the resulting output
# Note that this table will be empty if there are no "proc" entries in the snmpd.conf file
#
# Disk Monitoring
#
# 10MBs required on root disk, 5% free on /var, 10% free on all other disks
disk / 10000
disk /var 5%
includeAllDisks 10%
# Walk the UCD-SNMP-MIB::dskTable to see the resulting output
# Note that this table will be empty if there are no "disk" entries in the snmpd.conf file
#
# System Load
#
# Unacceptable 1-, 5-, and 15-minute load averages
load 12 10 5
# Walk the UCD-SNMP-MIB::laTable to see the resulting output
# Note that this table *will* be populated, even without a "load" entry in the snmpd.conf file
###############################################################################
#
# ACTIVE MONITORING
#
# send SNMPv1 traps
trapsink localhost public
# send SNMPv2c traps
#trap2sink localhost public
# send SNMPv2c INFORMs
#informsink localhost public
# Note that you typically only want *one* of these three lines
# Uncommenting two (or all three) will result in multiple copies of each notification.
#
# Event MIB - automatically generate alerts
#
# Remember to activate the 'createUser' lines above
iquerySecName internalUser
rouser internalUser
# generate traps on UCD error conditions
defaultMonitors yes
# generate traps on linkUp/Down
linkUpDownNotifications yes
###############################################################################
#
# EXTENDING THE AGENT
#
#
# Arbitrary extension commands
#
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
#extend-sh test3 /bin/sh /tmp/shtest
# Note that this last entry requires the script '/tmp/shtest' to be created first,
# containing the same three shell commands, before the line is uncommented
# Walk the NET-SNMP-EXTEND-MIB tables (nsExtendConfigTable, nsExtendOutput1Table
# and nsExtendOutput2Table) to see the resulting output
# Note that the "extend" directive supercedes the previous "exec" and "sh" directives
# However, walking the UCD-SNMP-MIB::extTable should still returns the same output,
# as well as the fuller results in the above tables.
#
# "Pass-through" MIB extension command
#
#pass .1.3.6.1.4.1.8072.2.255 /bin/sh PREFIX/local/passtest
#pass .1.3.6.1.4.1.8072.2.255 /usr/bin/perl PREFIX/local/passtest.pl
# Note that this requires one of the two 'passtest' scripts to be installed first,
# before the appropriate line is uncommented.
# These scripts can be found in the 'local' directory of the source distribution,
# and are not installed automatically.
# Walk the NET-SNMP-PASS-MIB::netSnmpPassExamples subtree to see the resulting output
#DC/20120525: ajout d'un agent TCS-MIB
doDebugging 1
disablePerl false
# do not use if willing to do a sub-agent! pass 1.3.6.1.4.1.16304.3665 /usr/bin/perl /home/syncmux/.snmp/mibs/tcs-agent-module.pl
perl print "salete d'extension perl snmp qui ne veut pas se lancer!\n";
#perl do "/home/syncmux/.snmp/mibs/tcs-agent-module.pl";
perl 'do /home/syncmux/.snmp/mibs/tcs-agent-module.pl';
#DC/20120525: fin ajout
#
# AgentX Sub-agents
#
# 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
TCS-MIB.mib
(application/octet-stream, 4.4 KB) - not displayed