From 0dce03feed8755d5f4d9e8e918639b80860f8575 Mon Sep 17 00:00:00 2001 From: Alexander Stoll Date: Fri, 14 Aug 2026 08:40:21 +0200 Subject: [PATCH 1/4] Add icinga2 CheckCommand --- contrib/icinga2-commands.conf | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 contrib/icinga2-commands.conf diff --git a/contrib/icinga2-commands.conf b/contrib/icinga2-commands.conf new file mode 100644 index 0000000..e31291f --- /dev/null +++ b/contrib/icinga2-commands.conf @@ -0,0 +1,71 @@ +object CheckCommand "hwgroup" { + command = [ PluginContribDir + "/check_hwgroup" ] + + arguments = { + "-H" = { + value = "$hwgroup_hostname$" + description = "Hostname or IP of the device ($CHECK_HWGROUP_HOST)" + } + "-p" = { + value = "$hwgroup_port$" + description = "Port of the device ($CHECK_HWGROUP_PORT)" + } + "-w" = { + value = "$hwgroup_warning$" + description = "Warning threshold for return value" + } + "-c" = { + value = "$hwgroup_critical$" + description = "Critical threshold for return value" + } + "-s" = { + value = "$hwgroup_sensor$" + description = "Check the given sensor ID" + } + "-o" = { + value = "$hwgroup_output$" + description = "Check the given relay output ID" + } + "-d" = { + value = "$hwgroup_contact$" + description = "Check the given dry contact ID" + } + "-P" = { + value = "$hwgroup_snmp_version$" + description = "SNMP Version to use" + } + "-C" = { + value = "$hwgroup_community$" + description = "SNMP community string ($CHECK_HWGROUP_COMMUNITY)" + } + "--v3-username" = { + value = "$hwgroup_snmp_username$" + description = "SNMPv3 username" + } + "--v3-auth-proto" = { + value = "$hwgroup_snmp_auth_proto$" + description = "SNMPv3 authentication protocol (MD5|SHA|SHA224|SHA256|SHA384|SHA512)" + } + "--v3-auth-password" = { + value = "$hwgroup_snmp_auth_password$" + description = "SNMPv3 authentication password ($CHECK_HWGROUP_V3_AUTH_PASS)" + } + "--v3-priv-proto" = { + value = "$hwgroup_snmp_priv_proto$" + description = "SNMPv3 privacy protocol (DES|AES|AES192|AES256)" + } + "--v3-priv-password" = { + value = "$hwgroup_snmp_priv_password$" + description = "SNMPv3 privacy password ($CHECK_HWGROUP_V3_PRIV_PASS)" + } + "-t" = { + value = "$hwgroup_timeout$" + description = "Timeout for the connection" + } + "-r" = { + value = "$hwgroup_retries$" + description = "Retries for the connection" + } + } + vars.hwgroup_hostname = "$address$" +} \ No newline at end of file From a3d3f1abd54a52a7f028297a79273342684a0694 Mon Sep 17 00:00:00 2001 From: Alexander Stoll Date: Fri, 14 Aug 2026 08:41:30 +0200 Subject: [PATCH 2/4] Add short parameter alias --- README.md | 139 ++++++++++++++++++++++-------------------------------- main.go | 24 +++++----- 2 files changed, 68 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 476ff6c..6a4afe9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +**Note:** This is an older version and will no longer be maintained. + # check_hwgroup Checks the hwgroup environmental devices. Supported devices are: @@ -6,107 +8,78 @@ Checks the hwgroup environmental devices. Supported devices are: * [Damocles](https://www.hw-group.com/devices/monitoring) * [HWg-STE](https://www.hw-group.com/device/hwg-ste) -## Usage +# Installation -``` -Flags: - --help Show context-sensitive help. - --host=STRING Hostname or IP of the device ($CHECK_HWGROUP_HOST) - --community="public" SNMP community string ($CHECK_HWGROUP_COMMUNITY) - --port=UINT-16 Port of the device ($CHECK_HWGROUP_PORT) - --snmp-version="3" SNMP Version to use - --warning=STRING Warning threshold for return value - --critical=STRING Critical threshold for return value - --timeout=15s Timeout for the connection - --retries=2 Retries for the connection - --sensor=SENSOR Check the given sensor ID - --output=OUTPUT Check the given relay output ID - --contact=CONTACT check the given dry contact ID - --version Print version information and quit +The plugin requires at least Python 3. -SNMPv3 - --v3-username="public" SNMPv3 username - --v3-auth-proto="SHA" SNMPv3 authentication protocol (MD5|SHA|SHA224|SHA256|SHA384|SHA512) - --v3-auth-password=STRING SNMPv3 authentication password ($CHECK_HWGROUP_V3_AUTH_PASS) - --v3-priv-proto="AES" SNMPv3 privacy protocol (DES|AES|AES192|AES256) - --v3-priv-password=STRING SNMPv3 privacy password ($CHECK_HWGROUP_V3_PRIV_PASS) -``` +## Required Python Libraries -The warning and critical flags support thresholds in the common Nagios format (e.g. `~:10`). +* pysnmplib +* nagiosplugin -## Examples +# Usage -### Sensors +The options `-S`, `-I` and `-O` are mutually exclusive. ```bash -check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3266.internal --warning 10 --critical 20 --sensor 29448 +Usage: check_hwgroup --host=STRING --community="public" --port=161 --snmp-version="3" --warning=STRING --critical=STRING --sensor=SENSOR --output=OUTPUT --contact=CONTACT [flags] -[CRITICAL] - Poseidon2 3266 SNMP Supervisor v3.8.4 - Sensor value: 25.3|'HTemp Rack 19'=25.3;10;20 - -``` - -```bash -check_hwgroup --community public --snmp-version 1 --port 161 --host ste2.internal --warning 10 --critical 20 --sensor 52290 - -[WARNING] - STE2 r2, fw:1.5.9_2478 - Sensor value: 19.3|'Temp Rack'=19.3;10;20 -``` - -Check for a negative value: - -```bash -check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3265.internal --warning="-5:" --critical="-10:" --sensor 33640 +Monitoring check plugin for the HW group environmental devices -[CRITICAL] - Poseidon 3265 SNMP Supervisor v3.0.4 - Sensor value: -14.5|MORAL3=-14.5;-5:;-10: -``` - -### Dry Contacts - -```bash -check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3266.internal --warning 1 --critical 1 --contact 1 - -[OK] - Poseidon2 3266 SNMP Supervisor v3.8.4 - Contact name: Binary 1, SensorState: 0, AlarmSetup: active if on|'Binary 1'=0;1;1 -``` - -```bash -check_hwgroup --community public --snmp-version 1 --port 161 --host damocles-mini.internal --warning 1 --critical 1 --contact 1 +Flags: + -h, --help Show context-sensitive help. + -H, --host=STRING Hostname or IP of the device ($CHECK_HWGROUP_HOST) + -C, --community="public" SNMP community string ($CHECK_HWGROUP_COMMUNITY) + -p, --port=161 Port of the device ($CHECK_HWGROUP_PORT) + -P, --snmp-version="3" SNMP Version to use + -w, --warning=STRING Warning threshold for return value + -c, --critical=STRING Critical threshold for return value + -t, --timeout=15s Timeout for the connection + -r, --retries=2 Retries for the connection + -s, --sensor=SENSOR Check the given sensor ID + -o, --output=OUTPUT Check the given relay output ID + -d, --contact=CONTACT Check the given dry contact ID + -V, --version Print version information and quit -[OK] - Damocles MINI SNMP Supervisor v1.0.11 - Contact name: Input 1, SensorState: 0, AlarmSetup: inactive|'Input 1'=0;1;1 +SNMPv3 + --v3-username="public" SNMPv3 username + --v3-auth-proto="SHA" SNMPv3 authentication protocol (MD5|SHA|SHA224|SHA256|SHA384|SHA512) + --v3-auth-password=STRING SNMPv3 authentication password ($CHECK_HWGROUP_V3_AUTH_PASS) + --v3-priv-proto="AES" SNMPv3 privacy protocol (DES|AES|AES192|AES256) + --v3-priv-password=STRING SNMPv3 privacy password ($CHECK_HWGROUP_V3_PRIV_PASS) ``` -How the plugin maps the returned contact states: - -- `0`: 0 -- `1`: 1 -- `everything else`: unknown +# Examples -How the plugin maps the returned contact setup: +Fetch a sensor value and check whether it's OK, WARNING or CRITICAL: -- `0`: active if on -- `1`: active if off -- `2`: inactive -- `everything else`: unknown + $ ./check_hwgroup.py -H 192.168.144.120 -S 17946 -w 30 -c 35 + POSEIDON 2250 SNMP SUPERVISOR V1.0.13 OK - Sensor 240 is 25.8 | 'Sensor 240'=25.8;30.0;35.0 + $ echo $? + 0 -### Relay Outputs + $ ./check_hwgroup.py -H 192.168.144.120 -S 17946 -w 25.7 -c 35 + POSEIDON 2250 SNMP SUPERVISOR V1.0.13 WARNING - Sensor 240 is 25.8 (outside range 0:25.7) | 'Sensor 240'=25.8;25.7;35.0 + $ echo $? + 1 -```bash -check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3266.internal --warning 1 --critical 1 --output 1 + $ ./check_hwgroup.py -H 192.168.144.120 -S 17946 -w 25.7 -c 25.7 + POSEIDON 2250 SNMP SUPERVISOR V1.0.13 CRITICAL - Sensor 240 is 25.8 (outside range 0:25.7) | 'Sensor 240'=25.8;25.7;25.7 + $ echo $? + 2 -[OK] - Poseidon2 3266 SNMP Supervisor v3.8.4 - Output name: VirtBinOut 1, Type: On / Off (Relay output), Mode: Manual output control|'VirtBinOut 1'=0;1;1 -``` +## Frequently occurred user errors -How the plugin maps the returned output states: +Wrong host/port/community: -- `0`: On / Off (Relay output) -- `1`: On (+10V) / Off (-10V) (RTS output) -- `2`: On (+10V) / Off (0V) (DTR output) -- `everything else`: unknown + $ ./check_hwgroup.py -H 192.168.144.121 -S 17946 -w 30 -c 35 -P 162 -C apple + ERROR: SNMP error: No SNMP response received before timeout + $ echo $? + 3 -How the plugin maps the returned output setup: +Wrong sensor: -- `0`: Manual output control -- `1`: On if any alarm -- `2`: On if value equal to Trigger -- `3`: On if value higher than Trigger -- `4`: On if value lower than Trigger -- `5`: On if Alarm on -- `everything else`: unknown + $ ./check_hwgroup.py -H 192.168.144.120 -S 17947 -w 30 -c 35 + ERROR: Sensor ID (17947) not found + $ echo $? + 3 diff --git a/main.go b/main.go index c9e745c..ec5cbe1 100644 --- a/main.go +++ b/main.go @@ -28,21 +28,21 @@ type V3Flags struct { } type CLI struct { - Host string `kong:"required,env='CHECK_HWGROUP_HOST',help='Hostname or IP of the device'"` - Community string `kong:"required,default='public',env='CHECK_HWGROUP_COMMUNITY',help='SNMP community string'"` - Port uint16 `kong:"required,default=161,env='CHECK_HWGROUP_PORT',help='Port of the device'"` - SNMPVersion string `kong:"required,default='3',enum='1,2c,3',help='SNMP Version to use'"` - Warning string `kong:"required,help='Warning threshold for return value'"` - Critical string `kong:"required,help='Critical threshold for return value'"` - Timeout time.Duration `kong:"default='15s',help='Timeout for the connection'"` - Retries int `kong:"default=2,help='Retries for the connection'"` + Host string `kong:"required,short='H',env='CHECK_HWGROUP_HOST',help='Hostname or IP of the device'"` + Community string `kong:"required,short='C',default='public',env='CHECK_HWGROUP_COMMUNITY',help='SNMP community string'"` + Port uint16 `kong:"required,short='p',default=161,env='CHECK_HWGROUP_PORT',help='Port of the device'"` + SNMPVersion string `kong:"required,short='P',default='3',enum='1,2c,3',help='SNMP Version to use'"` + Warning string `kong:"required,short='w',help='Warning threshold for return value'"` + Critical string `kong:"required,short='c',help='Critical threshold for return value'"` + Timeout time.Duration `kong:"short='t',default='15s',help='Timeout for the connection'"` + Retries int `kong:"short='r',default=2,help='Retries for the connection'"` V3 V3Flags `kong:"embed='',prefix='v3-',group='SNMPv3'"` - Sensor *uint `kong:"required,xor=checkType,help='Check the given sensor ID'"` - Output *uint `kong:"required,xor=checkType,help='Check the given relay output ID'"` - Contact *uint `kong:"required,xor=checkType,help='check the given dry contact ID'"` + Sensor *uint `kong:"required,short='s',xor=checkType,help='Check the given sensor ID'"` + Output *uint `kong:"required,short='o',xor=checkType,help='Check the given relay output ID'"` + Contact *uint `kong:"required,short='d',xor=checkType,help='Check the given dry contact ID'"` - Version kong.VersionFlag `kong:"help='Print version information and quit'"` + Version kong.VersionFlag `kong:"short='V',help='Print version information and quit'"` } func main() { From edebbd51c0476508d2c76006ad4cea1075bd4e64 Mon Sep 17 00:00:00 2001 From: Alexander Stoll Date: Fri, 14 Aug 2026 08:42:25 +0200 Subject: [PATCH 3/4] Expand device detection HWg-STE --- internal/hwgroup/hwgroup.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/hwgroup/hwgroup.go b/internal/hwgroup/hwgroup.go index 6f864d4..1eec223 100644 --- a/internal/hwgroup/hwgroup.go +++ b/internal/hwgroup/hwgroup.go @@ -17,11 +17,12 @@ const ( damoclesType = "Damocles" steType = "STE1" ste2Type = "STE2" + hwgSteType = "HWg-STE" wldType = "WLD" unknownState = "unknown" ) -var supportedDeviceTypes = []string{poseidonType, damoclesType, steType, ste2Type, wldType} +var supportedDeviceTypes = []string{poseidonType, damoclesType, steType, ste2Type, hwgSteType, wldType} // OID prefixes for sensors per device type. var sensorIDPrefix = map[string]string{ @@ -29,6 +30,7 @@ var sensorIDPrefix = map[string]string{ damoclesType: "3.4.3.1.8", ste2Type: "4.9.3.1.8", steType: "4.1.3.1.8", + hwgSteType: "4.1.3.1.8", wldType: "4.5.4.1.5", } @@ -38,6 +40,7 @@ var sensorPathSuffix = map[string][3]string{ damoclesType: {"3.4.3.1.2", "3.4.3.1.4", "3.4.3.1.6"}, ste2Type: {"4.9.3.1.2", "4.9.3.1.3", "4.9.3.1.5"}, steType: {"4.1.3.1.2", "4.1.3.1.3", "4.1.3.1.5"}, + hwgSteType: {"4.1.3.1.2", "4.1.3.1.3", "4.1.3.1.5"}, wldType: {"4.5.4.1.2", "4.5.4.1.3", "4.5.4.1.6"}, } From 218587b0decef71d7c72ca1d5467653fed323cf1 Mon Sep 17 00:00:00 2001 From: Alexander Stoll Date: Fri, 14 Aug 2026 09:20:07 +0200 Subject: [PATCH 4/4] Restore README.md & add short aliases --- README.md | 115 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 6a4afe9..90e22c3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -**Note:** This is an older version and will no longer be maintained. - # check_hwgroup Checks the hwgroup environmental devices. Supported devices are: @@ -8,24 +6,9 @@ Checks the hwgroup environmental devices. Supported devices are: * [Damocles](https://www.hw-group.com/devices/monitoring) * [HWg-STE](https://www.hw-group.com/device/hwg-ste) -# Installation - -The plugin requires at least Python 3. - -## Required Python Libraries - -* pysnmplib -* nagiosplugin - -# Usage - -The options `-S`, `-I` and `-O` are mutually exclusive. - -```bash -Usage: check_hwgroup --host=STRING --community="public" --port=161 --snmp-version="3" --warning=STRING --critical=STRING --sensor=SENSOR --output=OUTPUT --contact=CONTACT [flags] - -Monitoring check plugin for the HW group environmental devices +## Usage +``` Flags: -h, --help Show context-sensitive help. -H, --host=STRING Hostname or IP of the device ($CHECK_HWGROUP_HOST) @@ -49,37 +32,81 @@ SNMPv3 --v3-priv-password=STRING SNMPv3 privacy password ($CHECK_HWGROUP_V3_PRIV_PASS) ``` -# Examples +The warning and critical flags support thresholds in the common Nagios format (e.g. `~:10`). -Fetch a sensor value and check whether it's OK, WARNING or CRITICAL: +## Examples - $ ./check_hwgroup.py -H 192.168.144.120 -S 17946 -w 30 -c 35 - POSEIDON 2250 SNMP SUPERVISOR V1.0.13 OK - Sensor 240 is 25.8 | 'Sensor 240'=25.8;30.0;35.0 - $ echo $? - 0 +### Sensors - $ ./check_hwgroup.py -H 192.168.144.120 -S 17946 -w 25.7 -c 35 - POSEIDON 2250 SNMP SUPERVISOR V1.0.13 WARNING - Sensor 240 is 25.8 (outside range 0:25.7) | 'Sensor 240'=25.8;25.7;35.0 - $ echo $? - 1 +```bash +check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3266.internal --warning 10 --critical 20 --sensor 29448 + +[CRITICAL] - Poseidon2 3266 SNMP Supervisor v3.8.4 - Sensor value: 25.3|'HTemp Rack 19'=25.3;10;20 + +``` + +```bash +check_hwgroup --community public --snmp-version 1 --port 161 --host ste2.internal --warning 10 --critical 20 --sensor 52290 + +[WARNING] - STE2 r2, fw:1.5.9_2478 - Sensor value: 19.3|'Temp Rack'=19.3;10;20 +``` - $ ./check_hwgroup.py -H 192.168.144.120 -S 17946 -w 25.7 -c 25.7 - POSEIDON 2250 SNMP SUPERVISOR V1.0.13 CRITICAL - Sensor 240 is 25.8 (outside range 0:25.7) | 'Sensor 240'=25.8;25.7;25.7 - $ echo $? - 2 +Check for a negative value: + +```bash +check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3265.internal --warning="-5:" --critical="-10:" --sensor 33640 -## Frequently occurred user errors +[CRITICAL] - Poseidon 3265 SNMP Supervisor v3.0.4 - Sensor value: -14.5|MORAL3=-14.5;-5:;-10: +``` + +### Dry Contacts + +```bash +check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3266.internal --warning 1 --critical 1 --contact 1 + +[OK] - Poseidon2 3266 SNMP Supervisor v3.8.4 - Contact name: Binary 1, SensorState: 0, AlarmSetup: active if on|'Binary 1'=0;1;1 +``` + +```bash +check_hwgroup --community public --snmp-version 1 --port 161 --host damocles-mini.internal --warning 1 --critical 1 --contact 1 + +[OK] - Damocles MINI SNMP Supervisor v1.0.11 - Contact name: Input 1, SensorState: 0, AlarmSetup: inactive|'Input 1'=0;1;1 +``` + +How the plugin maps the returned contact states: + +- `0`: 0 +- `1`: 1 +- `everything else`: unknown + +How the plugin maps the returned contact setup: + +- `0`: active if on +- `1`: active if off +- `2`: inactive +- `everything else`: unknown + +### Relay Outputs + +```bash +check_hwgroup --community public --snmp-version 2c --port 1161 --host poseidon2-3266.internal --warning 1 --critical 1 --output 1 + +[OK] - Poseidon2 3266 SNMP Supervisor v3.8.4 - Output name: VirtBinOut 1, Type: On / Off (Relay output), Mode: Manual output control|'VirtBinOut 1'=0;1;1 +``` -Wrong host/port/community: +How the plugin maps the returned output states: - $ ./check_hwgroup.py -H 192.168.144.121 -S 17946 -w 30 -c 35 -P 162 -C apple - ERROR: SNMP error: No SNMP response received before timeout - $ echo $? - 3 +- `0`: On / Off (Relay output) +- `1`: On (+10V) / Off (-10V) (RTS output) +- `2`: On (+10V) / Off (0V) (DTR output) +- `everything else`: unknown -Wrong sensor: +How the plugin maps the returned output setup: - $ ./check_hwgroup.py -H 192.168.144.120 -S 17947 -w 30 -c 35 - ERROR: Sensor ID (17947) not found - $ echo $? - 3 +- `0`: Manual output control +- `1`: On if any alarm +- `2`: On if value equal to Trigger +- `3`: On if value higher than Trigger +- `4`: On if value lower than Trigger +- `5`: On if Alarm on +- `everything else`: unknown \ No newline at end of file