NAME
mibProxy
mibProxy [-f configtFile] [-p propertiesFile] [-i updateInterval]
Uses the protocol specified in the option pass_persist in snmpd.conf
mibProxy -h
Shows the help man page
mibProxy -v
shows the version
DESCRIPTION
The mibProxy is a utility script used as a pass_persist entry for the snmp daemon of NETSNMP.
The main operation is the following:
1) It receives a query of the form via stdin (see pass_persist in snmpd.conf). Alternatively it can also receive a "PING" which is answered by a "PONG". Any unknown request will be answered by a "NONE"
get
.1.3.6.1.4
2) It then tries to translate with the command "snmptranslate" the OID into string format. That is from ".1.3.6.1.4" to "private"
3) It then tries to find the property "private" in the properties specified. Assume that the following line exists in the config file
private=4
4) It then returns the following via stdout The main configuration comes from the configuration file (see the -f switch in the OPTIONS seciont).
.1.3.6.1.4
integer
4
OPTIONS
All the command line options override the options in the configuration file.
COMMAND LINE OPTIONS
- -f configuration file
-
Indicates the configuration file. There is no corresponding configuration file option. The default value is ".logParser", "../etc/logParser.conf", "../conf/logParser.conf", "/etc/logParser.conf"
See Config::Find for the exact rules.
- -p propertiesFile
-
Indicates in which file the properties of the values are stored for retrieval.
The corresponding configuration option is "propertiesFile"
- -i updateInterval
-
Indicates with which frequency (in seconds) should the propertiesFile be reloaded. This only happens if a request is received. That is if no requests were received for the last 10 minutes and the updateInterval is 30 seconds then the file will be uploaded before the next request.
The corresponding configuration option is "updateInterval"
- -h
-
Shows this help page
- -v
-
Shows the version of the script.
CONFIG FILE OPTIONS
The configuration tag used is "mibProxy::Default"
- log4perl
-
This option specifies the log4perl settings for logs. See the Log::Log4perl documentation.
REQUIREMENTS and LIMITATIONS
Currently not known...
EXAMPLE
This is a simple example to implement a MIB of one counter and table with two entries.
The steps are:
- # Create the MIB
- # Put the MIB in a place where SNMP can find it
- # Copy the script to the target machine
- # Edit snmpd.conf and add a MIB file
- # Add the statistic file
- # Test it
Create the MIB
the example MIB that we will use is a subset of the qindel-antivirus MIB:
QINDEL-ANTIVIRUS DEFINITIONS ::= BEGIN
IMPORTS
OBJECT-TYPE
FROM RFC-1212
TRAP-TYPE
FROM RFC-1215
DisplayString
FROM RFC1213-MIB
TimeTicks, Counter, Gauge
FROM RFC1155-SMI
qindel, project, antispam
FROM QINDEL;
antivirus OBJECT IDENTIFIER ::= { antispam 3 }
infectedMessages OBJECT-TYPE
SYNTAX Counter
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The number of messages infected"
::= { antivirus 1 }
virusFoundTable OBJECT-TYPE
SYNTAX SEQUENCE OF virusFoundEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"A list of virus found. The number of
entries is given by the value of differentVirusFound."
::= { antivirus 4 }
virusFoundEntry OBJECT-TYPE
SYNTAX VirusFoundEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"An virus entry containing the number of times
that a particular virus has been found."
INDEX { virusFoundIndex }
::= { virusFoundTable 1 }
AntispamMethodFrequencyEntry ::=
SEQUENCE {
virusFoundIndex INTEGER,
virusFoundDescr DisplayString,
virusFoundCounter Counter
}
virusFoundIndex OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS mandatory
DESCRIPTION
"A unique value for each method. Its value
ranges between 1 and the value of
differentVirusFound. "
::= { virusFoundEntry 1 }
virusFoundDescr OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"A textual string containing information about the
virus, as it appears in the MailScanner log."
::= { virusFoundEntry 2 }
virusFoundCounter OBJECT-TYPE
SYNTAX Counter
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The total number of messages which have
been identified cointaining the virus
specified."
::= { virusFoundEntry 3 }
END
Put the MIB in a place where SNMP can find it
This is usually /usr/share/snmp/mibs/ but it will depend on where your NET-SNMP is installed
Copy the script to the target machine
If you copy the script to /usr/local/bin/mibProxy be aware that the likely place to store the configuration file mibProxy.conf is /usr/local/etc/mibProxy
The configuration file could be something like:
log4perl.logger.mibProxy.Default= DEBUG, A1
#log4perl.appender.A1=Log::Log4perl::Appender::File
log4perl.appender.A1=Log::Dispatch::FileRotate
log4perl.appender.A1.filename=/usr/local/cricket2/var/log/mibProxy.log
log4perl.appender.A1.DatePattern=yyyy-MM-dd-HH
log4perl.appender.A1.mode=append
log4perl.appender.A1.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.A1.layout.ConversionPattern=%d [%c] %m %n
# propertiesFile
# Indicates which file should be used to save %savespace hash
# By default it is /var/lib/logparser/logParser.store
# propertiesFile=/var/lib/logparser/logparser.properties
propertiesFile=/var/lib/logparser/logparser.properties
Edit snmpd.conf and add a MIB file
Add the following line to snmpd.conf:
pass_persist .1.3.6.1.4.1.17171 /usr/local/bin/mibProxy
Add the statistic file
In the /var/lib/logparser/logparser.properties file add the following:
infectedMessages=37
virusFoundIndex.1=1
virusFoundDescr.1="My simple test"
virusFoundCounter.1=38
virusFoundIndex.2=2
virusFoundDescr.2="My simple test2"
virusFoundCounter.2=39
Test it
Restart your SNMP agent and run an snmpwalk against it and see what happens...
INSTALLATION
Required Perl packages
The perl packages installed for this script are:
File-Temp-0.14
File-HomeDir-0.05
File-Which-0.05
Config-Properties-Simple-0.09
SNMP (from NET-SNMP)
BUGS
TODO
At the moment it only supports integers
SEE ALSO
AUTHOR
Nito Martinez <Nito at Qindel dot ES>
5/5/2005
COPYRIGHT & LICENSE
Copyright 2007 by Qindel Formacion y Servicios SL, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.