Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ Checks the hwgroup environmental devices. Supported devices are:

```
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
-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

SNMPv3
--v3-username="public" SNMPv3 username
Expand Down Expand Up @@ -109,4 +109,4 @@ How the plugin maps the returned output setup:
- `3`: On if value higher than Trigger
- `4`: On if value lower than Trigger
- `5`: On if Alarm on
- `everything else`: unknown
- `everything else`: unknown
71 changes: 71 additions & 0 deletions contrib/icinga2-commands.conf
Original file line number Diff line number Diff line change
@@ -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$"
}
5 changes: 4 additions & 1 deletion internal/hwgroup/hwgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ 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{
poseidonType: "3.3.3.1.8",
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",
}

Expand All @@ -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"},
}

Expand Down
24 changes: 12 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down