# IML Checks for Icinga / Nagios

[Home](readme.md)

---

## check SNMP data

### Introduction

**check_snmp_data** is a plugin for fetching performance data with a set of given OIDs.

It can handle current values (i.e. load or cpu usage) and counter values (i.e. network io).

### Syntax

``$ check_snmp_data -h HOSTNAME [-C COOMMUNITYSTRING] -v -m METHOD``

#### Parameters

Starting the script without parameters shows a help.

```

SNMP performance data v1.0

University of Bern * Institute of Medical Education
GNU GPL 3.0

USAGE:
    ./check_snmp_data -h hostname [-C communitystring] -m method

PARAMETERS:
    -h  hostname       as fqdn or ip address
    -C  communitystr   optional: community string for snmp; default is public
    -v                 verbose output
    -m  method         what to show
                       method is one of ...
                          cpu        CPU usage                                         
                          load       System load                                       
                          netio      Network IO (experimental)                         
                          synotemp   Synology NAS temperature                          

EXAMPLE:
    ./check_snmp_data -h 192.168.100.12 -v -m cpu

```

### Examples

#### Get values

``./check_snmp_data -h 192.168.100.12 -v -m cpu``
    
Shows the current cpu usage of host *192.168.100.12*.
The output is something like that:

```
OK: SNMP performance data :: CPU usage 
cpu-user       0 %
cpu-system     0 %
cpu-idle       99 %

 |cpu-user=0;;;0; cpu-system=0;;;0; cpu-idle=99;;;0;
```

The 3 lines with values starting from line 2 are written with *-v* option only.

The performance data (last line) always will be sent.

#### Get counter data

``./check_snmp_data -h 192.168.100.12 -v -m netio``
    
If there is a check with counter data using *-v* option you see the counter value and the delta speed. It is calculated by

```
              [current_counter] - [last_counter]
delta_speed = ----------------------------------
                time_since_last_check_in_sec
```
The output looks like that:
```
OK: SNMP performance data :: Network IO (experimental) 
in             total: 2669086814     delta:      1  per sec
out            total: 2212665608     delta:      0  per sec

 |in=1;;;0; out=0;;;0;
```


### Configuration

check_snmp_data is a Bash script. If you open / view it you see a DATA section as comment lines on the top.

It starts with a short description:
```
# SYNTAX:
# label    --> DATA:[method]:label:[text]
# n x data --> DATA:[method]:data:[perf-label]:[oid]:[optional unit]
```
... followed by the configuration data of the checks.
```
#
# DATA:cpu:label:CPU usage
# DATA:cpu:data:cpu-user:1.3.6.1.4.1.2021.11.9.0:%
# DATA:cpu:data:cpu-system:1.3.6.1.4.1.2021.11.10.0:%
# DATA:cpu:data:cpu-idle:1.3.6.1.4.1.2021.11.11.0:%
```

To fetch configuration data the text in $0 is grepped by ``^#\ DATA:``.

There is a single line with **label** to define a short description of the check.

There can be severeal lines with **data** to define the values to get. Each data line must have a uniq label within the same check.