# Icinga Check Command with multiples of the same flag allowed how to handle

**URL:** <https://community.icinga.com/t/icinga-check-command-with-multiples-of-the-same-flag-allowed-how-to-handle/6740>\
**Category:** Icinga 2\
**Tags:** director, icinga2\
**Created:** [February 19, 2021, 2:30pm UTC](https://community.icinga.com/t/icinga-check-command-with-multiples-of-the-same-flag-allowed-how-to-handle/6740 "2021-02-19T14:30:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.g](https://community.icinga.com/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@peter.g](https://community.icinga.com/u/peter.g)\
**Post date:** [February 19, 2021, 2:30pm UTC](https://community.icinga.com/t/icinga-check-command-with-multiples-of-the-same-flag-allowed-how-to-handle/6740/1 "2021-02-19T14:30:27Z")

</div>

Hi Icinga Community,

The ITL command **dns** has a ‘-a’ parameter that allows for multiples of this flag.

[https://icinga.com/docs/icinga-2/latest/doc/10-icinga-template-library/#dns](https://icinga.com/docs/icinga-2/latest/doc/10-icinga-template-library/#dns)  
dns\_expected\_answers **Optional.** The answer(s) to look for. A hostname must end with a dot. Multiple answers must be defined as array.

Also, this is documented in the command definitions: -  
`dns_expected_answers Optional ip address or host you expect the DNS server to return. Host must end with a dot (.). This option can be repeated multiple times (Returns OK if any value match). If multiple addresses are returned at once, you have to match the whole string of addresses separated with commas (sorted alphabetically).`

I defined a service and added an array as a string for the -a variable ‘dns\_expected\_answers’ like this.

[10.70.55.23, [ns2.services.somedomain.net](http://ns2.services.somedomain.net)]

But the check fails:  
DNS CRITICAL - expected ‘[10.70.55.23, [ns2.services.somedomain.net](http://ns2.services.somedomain.net)]’ but got ‘10.70.55.23’

We use Directory for managing the commands/services/hosts etc.

I can execute the check manually on the server

```
/usr/lib64/nagios/plugins/check_dns -H ns2.services.somedomain.net -slocalhost -qA -a 
ns2.services.trakm8.net -a 10.70.55.23 -w1 -c5
DNS OK: 0.010 seconds response time. ns2.services.somedomain.net returns 
10.70.55.23|time=0.009936s;1.000000;5.000000;0.000000

```

How do you define multiple ‘-a’ values for this check in icinga2 director?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Pooh](https://community.icinga.com/letter_avatar_proxy/v4/letter/p/f05b48/32.png) [@Pooh](https://community.icinga.com/u/Pooh)\
**Post date:** [February 19, 2021, 2:49pm UTC](https://community.icinga.com/t/icinga-check-command-with-multiples-of-the-same-flag-allowed-how-to-handle/6740/2 "2021-02-19T14:49:36Z")

</div>

If you are looking up a hostname, then the result/s will be IP address/es.

If you are looking up an address, then the result/s will be hostname/s.

It doesn’t make sense to combine an IP address and a hostname in the expected  
list of results; there is nothing you could look up which would return both of  
these.

Antony.

---

<div class="post-metadata">

**Author:** ![peter.g](https://community.icinga.com/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@peter.g](https://community.icinga.com/u/peter.g)\
**Post date:** [February 19, 2021, 4:10pm UTC](https://community.icinga.com/t/icinga-check-command-with-multiples-of-the-same-flag-allowed-how-to-handle/6740/3 "2021-02-19T16:10:35Z")

</div>

Well I figured it out. The key is to locate the variable in Director under ‘Define Data Fields’ and set it to type array. In the service created for the command you have the option to add each item you want multiples of for this field.

1. [Monitoring Plugins - check\_dns](https://www.monitoring-plugins.org/doc/man/check_dns.html)

2. ITL defines -a with a parameter

3. Define dns\_expected\_answers in Icinga Director under ‘Define Data Fields’ and set it to type array

4. Create a service for the command

Hope this helps someone.

@Anthony Stone - Thanks but what if I wanted to specify multiple hostnames as the command states its possible to use the ‘-a’ flag multiple times.
