Check_command troubleshooting

I’m trying to use a plugin with Icinga2.:

The docs are focused on Nagios configs, so I’m working through the conversion. I’ve run the script successfully from the command line:

/usr/lib/nagios/plugins/nagios-cloudwatch-metrics/check_cloudwatch.sh --region=us-west-2 --namespace=“RDS” --metric=“WriteIOPS” --statistics=“Average” --mins=5 --dimensions=“Name=DBInstanceIdentifier,Value=rds-test-db” --warning=10 --critical=“50” --default=0

with successful output:

WARNING - Name=DBInstanceIdentifier,Value=rds-test-db WriteIOPS (5 min Average): 18.589465425 Count/Second - VALUE is wrong. It SHOULD BE inside the range {0 … 10} | perf=18.589465425Count/Second;10;50;0.000000

I’ve come up with this check_command to match that test:

object CheckCommand “check_rds_iops” {
command = [ PluginDir + “/nagios-cloudwatch-metrics/check_cloudwatch.sh” ]

arguments = {

“–region” = “us-west-2”
“–namespace” = “RDS”
“–metric” = “WreiteIOPS”
“–statistics” = “Average”
“–mins” = “5”
“–dimensions” = “Name=DBInstanceIdentifier,Value=rds-us-devops”
“–warning” = “10”
“–critical” = “50”
“–default” = “0”
}
}

The API shows the command output as follows:

command = [ “/usr/lib/nagios/plugins/nagios-cloudwatch-metrics/check_cloudwatch.sh”, “–critical”, “50”, “–default”, “0”, “–dimensions”, “Name=DBInstanceIdentifier,Value=rds-test-db”, “–metric”, “WreiteIOPS”, “–mins”, “5”, “–namespace”, “RDS”, “–region”, “us-west-2”, “–statistics”, “Average”, “–warning”, “10” ]

The result of the check when run by icinga2 is:

output = "Error, unknown parameter “–critical” given!

So, I’m guessing the parameters are getting malformed, since --critical is a valid and required parameter, based on how the shell script wants them fed in, but I don’t have any ideas on how to modify or troubleshoot further. The fact that I can’t actually see the command line (like, where there are equals signs, spaces, etc.) makes it tough, maybe there is a way to see that? I have debug on, but don’t see it in the logs either.

Check the docs for the command definition, you need to understand how to pass parameters as runtime macros.

https://icinga.com/docs/icinga2/snapshot/doc/05-service-monitoring/#checkcommand-definition

For those interested, if you have a command line that requires this format:

command argument=value

where there is required to be an = and no space between the = and the value, I basically used “skip_key” and then added the actual key to the value inside the arguments dictionary like this:

–argument = {
skip_key = true
value = “–argument=$value$”
}

And this worked.

2 Likes