SNMP extensions user guide

         

SNMP extensions user guide

 

The following howto meant to help you understand Allprobe extensions structure, change extensions behavior and configure your own extensions located on your own repositories.

 

Extensions name format:

 

The name of the extension control the extension params, for exmaple:

 

Extension name - "APR-vmstat-cs" would mean

 

APR - extensions type (APR=allprobe, USR=user defined extension)

vmstat - the extension subject or set of values, this part also states the file name of the pulled extension,

So in this case if running the integrator, the exension will be pulled from allprobe repository

 

https://cdn.allprobe.com/bash/v1/ext/snmp/vmstat.sh

 

and be placed at /etc/apr/snmp/system/vmstat.sh

 

Then pull

 

https://cdn.allprobe.com/bash/v1/ext/cron/vmstat.sh

 

and be placed at /etc/apr/cron/system/vmstat.sh

 

then configure the cron (this is cron based extension)

 

* * * * * root /bin/bash -c "/etc/apr/cron/system/vmstat.sh; sleep 30 ; /etc/apr/cron/system/vmstat.sh"

 

Configure SNMP configuration (e.g: /etc/snmp/snmpd.conf) by placing each extension as new extension, in this case:

 

extend APR-vmstat-cs /etc/apr/snmp/system/vmstat.sh cs

 

The value produced in this extension is the output of the command:

 

/etc/apr/snmp/system/vmstat.sh cs

 

The argument "cs" is the third part of the extension name.

 

Other extensions options:

The following values can be configured for each extensions.

 

 

 

 

* Croned / Not Croned:

 

Extensions supports 3 cron mode types:

 

1 - Not croned - There is no cron to support the CLI command run by SNMP daemon

 

2 - One cron foreach grouped category, there is a cron for each subject such as vmstat, there is 1 cron that producing all of the vmstat extensions values

So in the vmstat example there is many values produced by the cron and the CLI run from the SNMP daemon as extension will fetch each value with different argument, APR-vmstat-cs will get "Context Switches" , APR-vmstat-interrupts will get Interrupts

 

3 - Lang - Lang of the extension code / Python, Perl, Bash, PHP - control the file extension and the way the extension will be running(default mode is bash, file extension sh)

 

4 - URL - The repository of the extension - default value if not set is

 

https://cdn.allprobe.com/bash/v1/

So in the extension name "APR-vmstat-cs" which is croned (grouped type) and lang "BASH" the files fetched by the integrator or manualy will be

 

https://cdn.allprobe.com/bash/v1/snmp/vmstat.sh

https://cdn.allprobe.com/bash/v1/cron/vmstat.sh

 

If you place it manualy then snmp file will have to go to:

 

/etc/apr/snmp/system/

 

and the cron file will be placed at:

 

/etc/apr/cron/system/

 

Creating your own extensions:

 

1 - Need to decide the cron type of the extension

 

None croned, grouped cron, single cron

 

You set this by the exnesion properties. if we take the example extension vmstat mensioned above it is cron type of "grouped"

The vmstat extension based on the output of the vmstat command which has many values, we can re-use all of this values

In different argument passed by SNMP daemon.

 

The cron is configured to run once every 30 seconds by the integrator or manualy, then output is beeing written to a buffer file at:

 

/etc/apr/buffer/vmstat

The CLI that the SNMP daemon is calling is

 

/etc/apr/snmp/user/vmstat.sh

Which is a simple BASH script that uses the buffer file created by the cron, thus just fast open with FS cache

 

#!/bin/bash

BUFFER="/etc/apr/buffer"

case $1 in
    user)
        CMD=`cat $BUFFER/vmstat | awk '{print $13}'`
        ;;
    system)
        CMD=`cat $BUFFER/vmstat | awk '{print $14}'`
        ;;
    idle)
        CMD=`cat $BUFFER/vmstat | awk '{print $15}'`
        ;;
    watime)
        CMD=`cat $BUFFER/vmstat | awk '{print $16}'`
        ;;
    cs)
        CMD=`cat $BUFFER/vmstat | awk '{print $12}'`
        ;;
    interrupts)
        CMD=`cat $BUFFER/vmstat | awk '{print $11}'`
        ;;
    si)
        CMD=`cat $BUFFER/vmstat | awk '{print $7}'`
        ;;
    so)
        CMD=`cat $BUFFER/vmstat | awk '{print $8}'`
        ;;
    bi)
        CMD=`cat $BUFFER/vmstat | awk '{print $9}'`
        ;;
    bo)
        CMD=`cat $BUFFER/vmstat | awk '{print $10}'`
        ;;
    running)
        CMD=`cat $BUFFER/vmstat | awk '{print $1}'`
        ;;
    blocked)
        CMD=`cat $BUFFER/vmstat | awk '{print $2}'`
        ;;
    *)
        echo "Unknown argument"
esac

OUTPUT=$CMD

if [ $? -eq 0 ]; then
    echo $OUTPUT
else
    echo "0"
fi

 

The extension would then look like that on snmpd.conf when all uses the same script that uses the same buffer with category's values pre fetched:

 

extend APR-vmstat-so /etc/apr/snmp/system/vmstat.sh so
extend APR-vmstat-watime /etc/apr/snmp/system/vmstat.sh watime
extend APR-vmstat-user /etc/apr/snmp/system/vmstat.sh user
extend APR-vmstat-system /etc/apr/snmp/system/vmstat.sh system
extend APR-vmstat-running /etc/apr/snmp/system/vmstat.sh running
extend APR-vmstat-si /etc/apr/snmp/system/vmstat.sh si
extend APR-vmstat-bo /etc/apr/snmp/system/vmstat.sh bo
extend APR-vmstat-interrupts /etc/apr/snmp/system/vmstat.sh interrupts
extend APR-vmstat-blocked /etc/apr/snmp/system/vmstat.sh blocked
extend APR-vmstat-cs /etc/apr/snmp/system/vmstat.sh cs
extend APR-vmstat-bi /etc/apr/snmp/system/vmstat.sh bi

 

If it is user defined exension, simply replace APR with USR short for USER on the exension name,

The files of the exnesion(exension and / or cron) scripts are also placed in user folders e.g

 

/etc/apr/snmp/user/vmstat.sh
/etc/apr/cron/user/vmstat.sh

 

 

 

Helpful Resources