Re: Retrieving page fault events trough SNMP protocol...
Max <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Here is a short script I wrote that is called using the old style of
Net-SNMP oid/script extension that calls vmstat, takes a few samples,
then returns the numbers in a style that is Cacti-compatible. Should
be easy to make this work for page faults if you don't want to do a
real sub-agent / MIB extension.
I am including a little shell library I use with the script. Again,
this is not an optimal way to do this, but is an easy way if you are
not concerned about a script being forked every few minutes on the
client system.
Hope you don't find this example too strange / hard to understand to be useful.
-= Max
What the configuration to call a script looks like in snmpd.conf:
exec 1.3.6.1.4.1.YOUR.OID.HERE s22-vmstat.sh /usr/local/bin/s22-vmstat.sh
esf-lib.sh:
#!/bin/bash
glob_count() {
local pat="$1"
perl -e 'BEGIN{$t=0};$t++ for glob("'"$pat"'");END{print $t}'
return 0;
}
output_oid_conf() {
local script="$1"
local oid="$2"
local name=$(basename $script)
echo exec $oid $name $script
return 0;
}
and the script:
s22-vmstat.sh:
#!/bin/bash
. ./esf-lib.sh || exit 1
if [ "$1" == "--snmp-conf" ]
then
output_oid_conf /usr/local/bin/s22-vmstat.sh 1.3.6.1.4.1.YOUR.OID.HERE
.22
exit 0
fi
vmstat 2 4 | awk '
{ line++; }
line > 3 {
r += $1;
b += $2;
si += $7;
so += $8;
io += $(NF);
} END {
printf("r:%d b:%d si:%d so:%d io:%d",
int(r/3), int(b/3), int(si/3), int(so/3), int(io/3));
}'
exit 0
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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