bsnmp-regex
— an
SNMP module which produces counters from logs or other text
bsnmp-regex
is a module for
bsnmpd(1)
which allows you to make SNMP counters from log files or other text. For
example you could count the number of occurances of a certain string in a
text file. You can also match specific numbers or text to build SNMP
values.
bsnmp-regex
has a configuration file which
contains regular expressions for the text you'd like to match. See
bsnmp-regex.conf(5)
for details on this file.
bsnmp-regex
opens a UNIX domain socket
which text is piped into. The text is matched line by line against the
regular expressions in the configuration file and the appropriate counter or
value is updated. The
sockin(1)
utility is useful for piping text into this socket.
The counters will be available as a table under the following
MIB:
Or if the appropriate MIB.txt files have been installed:
enterprises.fokus.begemot.regex
The following SNMP MIBs are available for use (where X is the
counter index):
- regex.regexCount.0
- The number of counters available.
- regex.regexEntry.regexIndex.X
- The index of the counter.
- regex.regexEntry.regexDescr.X
- The description of the counter.
- regex.regexEntry.regexLast.X
- How long ago the counter was last updated.
- regex.regexEntry.regexInteger.X
- The current value or counter as a integer.
- regex.regexEntry.regexString.X
- The current value as a string.
- regex.regexEntry.regexCounter.X
- The current counter value as a 64 bit integer.
To activate the bsnmp-regex
module you
must load the module in /etc/snmpd.config and
configure the location for the UNIX socket and
bsnmp-regex.conf(5)
file. See the examples section below.
- regexConfig
- The location of the
bsnmp-regex.conf(5)
file. This option must be specified.
- regexSocket
- The location of the UNIX socket on which this module will listen for logs
or text to match.
For a simple bsnmp-regex
configuration add
the following to /etc/snmpd.config:
begemotSnmpdModulePath."regex" = "/usr/local/lib/snmp_regex.so"
%regex
regexConfig = "/usr/local/etc/bsnmp-regex.conf"
regexSocket = "/var/run/bsnmp-regex.sock"
For details on what
/usr/local/etc/bsnmp-regex.conf should contain, see
the
bsnmp-regex.conf(5)
man page.
To pipe logs or text to match into the socket use the
sockin(1)
utility, run something like this:
# sockin /var/run/bsnmp-regex.sock tail -f /var/log/maillog
To have
syslogd(8)
send all logs for matching add a line like this to the
/etc/syslog.conf file:
*.* | sockin /var/run/bsnmp-regex.sock
Stef Walter
⟨stef@memberwebs.com⟩