The keyword extension tells the agent that this configuration entry is an extension that belongs to the extensionGroup. LeafNumber is the extension object number -- i.e., the number you assign to the object in the extensionGroup table. Type is the SNMP type for the OID. Valid types are Integer, Counter, Gauge, Octetstring, TimeTicks, Objectid, and IPAddress. Access is either Read-Only or Read-Write. And finally, Command is the script or program the agent will execute when this particular OID is queried by an NMS. We'll talk more about this shortly. Here are some examples of extension objects:extension LeafNumber Type Access 'Command'
The first item defines a read-only OID of type Integer. The OID is 1.3.6.1.4.1.546.14.1.0. The agent will execute the command /usr/local/bin/exampleScript.sh when this OID is queried. The second entry is similar, except its type is Gauge and its numeric OID is 1.3.6.1.4.1.546.14.2.0. The third example simply shows that LeafNumber doesn't have to be sequential; you can use any number you want, provided that it is unique. Extending the agent allows you to write your own scripts that do whatever you want: you can get information about devices or programs that are not SNMP-capable, as long as you can write a script that queries them for their status. In the example above, /usr/local/bin/Script.sh, /usr/local/bin/Script.pl, and /usr/local/bin/Program are all examples of scripts the agent will execute when the OID assigned to each script is queried. Two requirements must be met by any script or program:extension 1 Integer Read-Only '/usr/local/bin/Script.sh' extension 2 Gauge Read-Only '/usr/local/bin/Script.pl' extension 33 Counter Read-Write '/usr/local/bin/Program'
All you have to do is add the logic that takes some action to retrieve (or set) the appropriate value and return the correct value to the agent. The corresponding entry in sysedge.cf might look something like this:#!/usr/local/bin/perl if ($ARGV[0] == 1) { # OID queried is 1.3.6.1.4.1.546.14.1.0 if ($ARGV[1] eq "SET") { # use $ARGV[2] to set the value of something and return the set value, # followed by a newline character, to the agent } elsif (($ARGV[1] eq "GET") || ($ARGV[1] eq "GETNEXT")) { # get the information to which this OID pertains, then return it, # followed by a newline character, to the agent } } else { return 0; # return 0, since I don't know what to do with this OID }
What we've done so far gives the agent the ability to respond to requests for a new kind of data. We still need to solve the other part of the puzzle: telling the management station that some new kind of data is available for it to retrieve. This requires creating an entry in a MIB file.[56] After adding this entry to the file, you must recompile the MIB into your NMS system so that the NMS will know the access and type of each of the extended objects in the MIB for which it is to perform queries. Here is a MIB entry that corresponds to the previous agent extension:extension 1 Integer Read-Write '/usr/local/bin/skel.pl'
[56]Concord recommends that you keep all your extended MIB objects in a separate file, away from the SystemEDGE MIB file. This makes it easier for you to recompile it into your NMS.
Once this is compiled into the NMS, you can query the object by specifying its full name (iso.org.dod.internet.private.enterprises.empire.extensionGroup.skeletonVariable.0). Alternatively, you can use the numeric OID; for example:skeletonVariable OBJECT-TYPE SYNTAX Integer ACCESS Read-Write DESCRIPTION "This is an example object." ::= { extensionGroup 1 }
Security can be a concern when writing your own extension scripts. On Unix systems, it's a good idea to create a separate user and group to execute your extensions, rather than allowing the root user to run your scripts.$ snmpget server.ora.com public .1.3.6.1.4.1.546.14.1.0
The keyword ntregperf defines this as an NT registry or performance extension object. LeafNumber and Type are the same as for Unix extensions. The keyword Registry identifies this entry as a registry extension. Registry extensions are read-only. Key is a quoted string that specifies the registry key to be accessed. Value is the value you want to read from the key. Here is an example:ntregperf LeafNumber Type Registry 'Key' 'Value'
This creates a registry extension object that returns the path to the crash-control dump file. The OID is 1.3.6.1.4.1.546.5.7.1.0 (iso.org.dod.internet.private.enterprises.empire.nt.ntRegPerf.1.0). To configure a performance extension, use the following syntax:ntregperf 1 OctetString Registry 'SYSTEM\CurrentControlSet\Control\CrashControl' 'DumpFile'
Here again, ntregperf is the keyword that indicates this is an NT registry/performance extension object. LeafNumber and Type should be familiar to you. The keyword Performance indicates that we're reading a value from the performance registry; performance extensions are read-only. Object specifies the performance object to be accessed. Counter specifies the object's performance counter value to be accessed. Finally, PerfInstance specifies the performance counter instance to be accessed. This should be identical to what's listed with perfmon. Here's a typical performance extension:ntregperf LeafNumber Type Performance 'Object' 'Counter' 'PerfInstance'
You can use this extension to watch the total number of TCP segments transmitted by the system. Its OID is 1.3.6.1.4.1.546.5.7.2.0 (iso.org.dod.internet.private.enterprises.empire.nt.ntRegPerf.2.0). Keep in mind that you should create a MIB entry (in a MIB file) for any NT extensions you create, similar to the entry we defined above for skeletonVariable. The examples in this section should be enough to get you up and running with an extended SystemEDGE agent. Be sure to read the SystemEDGE manual for a complete treatment of this topic.ntregperf 2 Counter Performance 'TCP' 'Segments Sent/sec' '1'
Copyright © 2002 O'Reilly & Associates. All rights reserved.