# Is it possible to add commands in check\_mssql\_health plugin?

**URL:** <https://community.icinga.com/t/is-it-possible-to-add-commands-in-check-mssql-health-plugin/11470>\
**Category:** Icinga Web\
**Created:** [February 16, 2023, 3:37pm UTC](https://community.icinga.com/t/is-it-possible-to-add-commands-in-check-mssql-health-plugin/11470 "2023-02-16T15:37:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfigueroa21](https://community.icinga.com/letter_avatar_proxy/v4/letter/j/90ced4/32.png) [@jfigueroa21](https://community.icinga.com/u/jfigueroa21)\
**Post date:** [February 16, 2023, 3:37pm UTC](https://community.icinga.com/t/is-it-possible-to-add-commands-in-check-mssql-health-plugin/11470/1 "2023-02-16T15:37:29Z")

</div>

![image](https://community.icinga.com/uploads/default/original/2X/6/6326a5cbea493b4c72129c0cb25c13982c9aa6ec.png)

Hello :),

I am trying to configure the plugin check\_mssql and what I am looking for is that at the time of setting the parameter “mssql\_health\_hostname” there is a command that runs a command and this automatically detects the “hostname” of the server and thus not having to configure the service for each server.

If someone knows the way to do it I appreciate your comments and support.

I am using icinga2 web.

Translated with [DeepL Translate: The world's most accurate translator](http://www.DeepL.com/Translator) (free version)

---

<div class="post-metadata">

**Author:** ![log1c](https://community.icinga.com/user_avatar/community.icinga.com/log1c/32/2071_2.png) [@log1c](https://community.icinga.com/u/log1c)\
**Post date:** [February 16, 2023, 4:12pm UTC](https://community.icinga.com/t/is-it-possible-to-add-commands-in-check-mssql-health-plugin/11470/2 "2023-02-16T16:12:21Z")

</div>

You can use other variables, for example you can set `$host.name$` in the `mssql_health_hostname` variable.  
This will the resolve to the hostname of the host the service is applied to.  
Example:  
 ![image](https://community.icinga.com/uploads/default/original/2X/8/89d1de15c0fb3abfea2f29a2fec5585a28ca186c.png)  
would resolve to  
 ![image](https://community.icinga.com/uploads/default/original/2X/8/86772fa20bdfa34d378b8235e18970d6799fa4b8.png)  
when the check is executed

---

<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 16, 2023, 4:22pm UTC](https://community.icinga.com/t/is-it-possible-to-add-commands-in-check-mssql-health-plugin/11470/3 "2023-02-16T16:22:53Z")

</div>

I would do this by assigning some custom variable to each machine which runs  
MSSQL.

For example:

object Host “SQLserver1” {  
address = “your.sql.ser.ver”  
vars.sql = true  
}

and then applying the service check to every machine which has that variable  
set:

apply Service “SQLcheck” {  
check\_command = “mssql”  
assign where host.vars.sql  
}

(The above is typed from memory and not actually tested, but should be close  
enough to point you in a useful direction.)

Antony.
