Skip to content

Commit 063d295

Browse files
committed
nmp: make table output suppressable, streamline output
1 parent c872e7c commit 063d295

File tree

4 files changed

+109
-34
lines changed

4 files changed

+109
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Monitoring Plugins:
5353
* icinga-topflap-services: increase default warning level from 5 to 7
5454
* php-status: bz2 and curl are no default modules
5555
* rhel-version: switch from lib.version to lib.distro
56+
* snmp: make table output suppressable, streamline output
5657

5758

5859

check-plugins/snmp/README.rst

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Help
3737
.. code-block:: text
3838
3939
usage: snmp [-h] [-V] [--community COMMUNITY] [--device DEVICE] [--hide-ok]
40-
-H HOSTNAME [--mib MIB] [--mib-dir MIB_DIR]
40+
[--hide-table] -H HOSTNAME [--mib MIB] [--mib-dir MIB_DIR]
4141
[--snmp-version {1,2c,3}] [--test TEST] [-t TIMEOUT]
4242
[--v3-auth-prot {MD5,SHA,SHA-224,SHA-256,SHA-384,SHA-512}]
4343
[--v3-auth-prot-password V3_AUTH_PROT_PASSWORD]
@@ -63,8 +63,13 @@ Help
6363
located under `./device-oids`, for example `switch-
6464
fs-s3900.csv` or `printer-brother-mfcj5720dw.csv`.
6565
`any-any-any.csv` is a good starting point showing
66-
some features.Default: any-any-any.csv.
66+
some features. The file name is irrelevant. We
67+
recommend the three-part structure, where the first
68+
"any" refers to the device class, the second "any"
69+
refers to the vendor, and the third refers to the
70+
model. Default: any-any-any.csv.
6771
--hide-ok Don't print OIDs with OK state. Default: False.
72+
--hide-table Suppress the output of the table. Default: False.
6873
-H, --hostname HOSTNAME
6974
SNMP Appliance address.
7075
--mib MIB Load given list of MIBs, for example `+FS-MIB` or `FS-
@@ -134,6 +139,31 @@ Other example using a more specific OID list and an additional MIB directory:
134139
--hide-ok \
135140
--hostname 10.80.32.109
136141
142+
Checking a Radware Alteon load balancer appliance - CSV file and result:
143+
144+
.. code-block:: text
145+
146+
OID,Name,Re-Calc,Unit Label,WARN,CRIT,Show in 1st Line,Report Change as
147+
SNMPv2-SMI::enterprises.1872.2.5.1.2.8.1.0,TotalMem,int(value),,,,,
148+
SNMPv2-SMI::enterprises.1872.2.5.1.2.8.3.0,FreeMem,int(value),,,,,
149+
,warnPercent,70,%,,,,
150+
,critPercent,90,%,,,,
151+
,UsedMem,"values['TotalMem'] - values['FreeMem']",,,,,
152+
,Memory Usage,"round( 100.0 * values['UsedMem'] / values['TotalMem'],2)",%,value > values['warnPercent'],value > values['critPercent'],True,
153+
154+
.. code-block:: text
155+
156+
lb-alteon-any.csv: Memory Usage: 40.06%
157+
158+
Key ! Value ! State
159+
-------------+----------+-------
160+
TotalMem ! 65835992 ! [OK]
161+
FreeMem ! 39465220 ! [OK]
162+
warnPercent ! 70% ! [OK]
163+
critPercent ! 90% ! [OK]
164+
UsedMem ! 26370772 ! [OK]
165+
Memory Usage ! 40.06% ! [OK]
166+
137167
138168
Installation
139169
------------

check-plugins/snmp/icingaweb2-module-director/snmp.json

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"--hide-ok": {
1212
"set_if": "$snmp_hide_ok$"
1313
},
14+
"--hide-table": {
15+
"set_if": "$snmp_hide_table$"
16+
},
1417
"--hostname": {
1518
"value": "$snmp_hostname$"
1619
},
@@ -77,12 +80,12 @@
7780
},
7881
{
7982
"datafield_id": 4,
80-
"is_required": "y",
83+
"is_required": "n",
8184
"var_filter": null
8285
},
8386
{
8487
"datafield_id": 5,
85-
"is_required": "n",
88+
"is_required": "y",
8689
"var_filter": null
8790
},
8891
{
@@ -149,6 +152,11 @@
149152
"datafield_id": 18,
150153
"is_required": "n",
151154
"var_filter": null
155+
},
156+
{
157+
"datafield_id": 19,
158+
"is_required": "n",
159+
"var_filter": null
152160
}
153161
],
154162
"imports": [],
@@ -206,6 +214,7 @@
206214
"snmp_community": "public",
207215
"snmp_device": "any-any-any.csv",
208216
"snmp_hide_ok": false,
217+
"snmp_hide_table": false,
209218
"snmp_mib_dir": "$$HOME/.snmp/mibs:/usr/share/snmp/mibs",
210219
"snmp_snmp_version": "2c",
211220
"snmp_timeout": 7
@@ -356,7 +365,7 @@
356365
"2": {
357366
"varname": "snmp_device",
358367
"caption": "SNMP: Device",
359-
"description": "The name of a device file containing the SNMP-OIDs, located under `./device-oids`, for example `switch-fs-s3900.csv` or `printer-brother-mfcj5720dw.csv`. `any-any-any.csv` is a good starting point showing some features.Default: %(default)s.",
368+
"description": "The name of a device file containing the SNMP-OIDs, located under `./device-oids`, for example `switch-fs-s3900.csv` or `printer-brother-mfcj5720dw.csv`. `any-any-any.csv` is a good starting point showing some features. The file name is irrelevant. We recommend the three-part structure, where the first \"any\" refers to the device class, the second \"any\" refers to the vendor, and the third refers to the model.",
360369
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
361370
"format": null,
362371
"settings": {
@@ -374,6 +383,15 @@
374383
"uuid": "6547a9dc-cd34-417f-9a95-2284883b8569"
375384
},
376385
"4": {
386+
"varname": "snmp_hide_table",
387+
"caption": "SNMP: Hide Table?",
388+
"description": "Suppress the output of the table.",
389+
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
390+
"format": null,
391+
"settings": {},
392+
"uuid": "7cd6f2fc-dcc1-4cc2-bf18-7117f38f8e59"
393+
},
394+
"5": {
377395
"varname": "snmp_hostname",
378396
"caption": "SNMP: Hostname",
379397
"description": "SNMP Appliance address.",
@@ -384,7 +402,7 @@
384402
},
385403
"uuid": "6b9bd0e5-d731-4f49-8038-6a902b5e9218"
386404
},
387-
"5": {
405+
"6": {
388406
"varname": "snmp_mib",
389407
"caption": "SNMP: MIB",
390408
"description": "Load given list of MIBs, for example `+FS-MIB` or `FS-MIB:BROTHER-MIB`. Behaves like the `-m` option of `snmpget`.",
@@ -395,7 +413,7 @@
395413
},
396414
"uuid": "44634455-a0e5-4463-81ca-7710b6c6398a"
397415
},
398-
"6": {
416+
"7": {
399417
"varname": "snmp_mib_dir",
400418
"caption": "SNMP: MIB Dir",
401419
"description": "Look in given list of directories for MIBs. Behaves like the `-M` option of `snmpget`.",
@@ -406,7 +424,7 @@
406424
},
407425
"uuid": "ee829f8b-ac45-45ae-9718-97b08e50c582"
408426
},
409-
"7": {
427+
"8": {
410428
"varname": "snmp_snmp_version",
411429
"caption": "SNMP: SNMP Version",
412430
"description": "Specifies SNMP version to use.",
@@ -419,7 +437,7 @@
419437
},
420438
"uuid": "e6aba866-969f-4f4a-9116-9b92e9f7b481"
421439
},
422-
"8": {
440+
"9": {
423441
"varname": "snmp_timeout",
424442
"caption": "SNMP: Timeout",
425443
"description": "Network timeout in seconds.",
@@ -430,7 +448,7 @@
430448
},
431449
"uuid": "2a99ff07-0562-4759-8fd0-3639297b54e3"
432450
},
433-
"9": {
451+
"10": {
434452
"varname": "snmp_v3_auth_prot",
435453
"caption": "SNMP: v3 Auth Prot",
436454
"description": "SNMP Version 3 specific. Set authentication protocol.",
@@ -443,7 +461,7 @@
443461
},
444462
"uuid": "cb551079-71f3-4012-8182-cf4c82b20f99"
445463
},
446-
"10": {
464+
"11": {
447465
"varname": "snmp_v3_auth_prot_password",
448466
"caption": "SNMP: v3 Auth Prot Password",
449467
"description": "SNMP Version 3 specific. Set authentication protocol pass phrase.",
@@ -454,7 +472,7 @@
454472
},
455473
"uuid": "70fd4bb9-935c-4b05-97e5-f5f6d834f46b"
456474
},
457-
"11": {
475+
"12": {
458476
"varname": "snmp_v3_boots_time",
459477
"caption": "SNMP: v3 Boots Time",
460478
"description": "SNMP Version 3 specific. Set destination engine boots/time.",
@@ -465,7 +483,7 @@
465483
},
466484
"uuid": "54d46a14-db2f-4812-9b6a-7bc06cf515d5"
467485
},
468-
"12": {
486+
"13": {
469487
"varname": "snmp_v3_context",
470488
"caption": "SNMP: v3 Context",
471489
"description": "SNMP Version 3 specific. Set context name (e.g. bridge1).",
@@ -476,7 +494,7 @@
476494
},
477495
"uuid": "63d8670c-f0b1-41bf-8889-fbfb1ef9ddca"
478496
},
479-
"13": {
497+
"14": {
480498
"varname": "snmp_v3_context_engine_id",
481499
"caption": "SNMP: v3 Context Engine ID",
482500
"description": "SNMP Version 3 specific. Set context engine ID (e.g. 800000020109840301).",
@@ -487,7 +505,7 @@
487505
},
488506
"uuid": "69e04d85-87d5-4954-880c-4a8de5e8c9b2"
489507
},
490-
"14": {
508+
"15": {
491509
"varname": "snmp_v3_level",
492510
"caption": "SNMP: v3 Level",
493511
"description": "SNMP Version 3 specific. Set security level.",
@@ -500,7 +518,7 @@
500518
},
501519
"uuid": "9108eb88-11fa-4f83-ac26-3be81fb6e7e6"
502520
},
503-
"15": {
521+
"16": {
504522
"varname": "snmp_v3_priv_prot",
505523
"caption": "SNMP: v3 Priv Prot",
506524
"description": "SNMP Version 3 specific. Set privacy protocol.",
@@ -513,7 +531,7 @@
513531
},
514532
"uuid": "ebcce2dc-3df1-47a1-ac6c-627b315789e2"
515533
},
516-
"16": {
534+
"17": {
517535
"varname": "snmp_v3_priv_prot_password",
518536
"caption": "SNMP: v3 Priv Prot Password",
519537
"description": "SNMP Version 3 specific. Set privacy protocol pass phrase.",
@@ -524,7 +542,7 @@
524542
},
525543
"uuid": "f39688e1-6d0c-4628-b940-58ea113afa18"
526544
},
527-
"17": {
545+
"18": {
528546
"varname": "snmp_v3_security_engine_id",
529547
"caption": "SNMP: v3 Security Engine ID",
530548
"description": "SNMP Version 3 specific. Set security engine ID (e.g. 800000020109840301).",
@@ -535,7 +553,7 @@
535553
},
536554
"uuid": "28f9fdaf-da72-4850-b3ca-edf559bf380b"
537555
},
538-
"18": {
556+
"19": {
539557
"varname": "snmp_v3_username",
540558
"caption": "SNMP: v3 Username",
541559
"description": "SNMP Version 3 specific. Set security name (e.g. bert).",

0 commit comments

Comments
 (0)