check_snmp_data.md 3.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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.