check_snmp_data.md 3.04 KB
Newer Older
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
1
# check SNMP data
2

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
3
## Introduction
4
5
6
7
8

**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).

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
9
## Syntax
10
11
12

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

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
13
### Parameters
14
15
16

Starting the script without parameters shows a help.

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
17
```txt
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

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

```

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
43
44
45
## Examples

### Get values
46

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
47
`./check_snmp_data -h 192.168.100.12 -v -m cpu`
48
49
50
51

Shows the current cpu usage of host *192.168.100.12*.
The output is something like that:

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
52
```txt
53
54
55
56
57
58
59
60
61
62
63
64
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.

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
65
66
67
### Get counter data

`./check_snmp_data -h 192.168.100.12 -v -m netio`
68
69
70

If there is a check with counter data using *-v* option you see the counter value and the delta speed. It is calculated by

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
71
```txt
72
73
74
75
              [current_counter] - [last_counter]
delta_speed = ----------------------------------
                time_since_last_check_in_sec
```
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
76

77
The output looks like that:
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
78
79

```txt
80
81
82
83
84
85
86
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;
```

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
87
## Configuration
88
89
90
91

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:
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
92
93

```txt
94
95
96
97
# SYNTAX:
# label    --> DATA:[method]:label:[text]
# n x data --> DATA:[method]:data:[perf-label]:[oid]:[optional unit]
```
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
98

99
... followed by the configuration data of the checks.
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
100
101

```txt
102
103
104
105
106
107
108
#
# 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:%
```

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
109
To fetch configuration data the text in $0 is grepped by `^#\ DATA:`.
110
111
112
113

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.