Getting check_mssql_Health to work

Hello, I am trying to fully understand how to get this working and have gotten superb help here previously.

So to begin with, In external command you have a definition of the check_mssql_health. Is it someway possible to copy this command to /usr/lib/nagios/plugins to be able to run it on a remote server using Director?

Secondly I have tried to download the nagios check_mssql_health and it works perfectly fine in the CLI, I would probably get it to work within the Icinga CLI (normal checks) However I am trying to get it to work with director.

There are atleast one difference in syntaxes between this check and the one available in external commands.

The external command has -server as the hostname where the downloaded check has --hostname

This is the check i have downloaded (seems to be the same in the nagios repo)

I cannot use the prebuilt fields for the external command (which is understandable since it doesn´t seem to be the same command)

However I cannot use arguments within the command itself either ( for example --hostname=xxx)


I have even tried writing --hostname=xxx in the top field (Argument name)

Why are you trying to use a “selfmade” command definition and do not use the provided command from the ITL?
I use it here since a long time with director and it works like a charm. and it has both fields in his definition.

object CheckCommand "mssql_health" {
        import "ipv4-or-ipv6"

        command = [ PluginContribDir + "/check_mssql_health" ]

        arguments = {
                "--hostname" = {
                        value = "$mssql_health_hostname$"
                        description = "the database server's hostname"
                "--username" = {
                        value = "$mssql_health_username$"
                        description = "the mssql db user"
                "--password" = {
                        value = "$mssql_health_password$"
                        description = "the mssql db user's password"
                "--port" = {
                        value = "$mssql_health_port$"
                        description = "the database's port"
                "--server" = {
                        value = "$mssql_health_server$"
                        description = "the name of a predefined connection"
                "--currentdb" = {
                        value = "$mssql_health_currentdb$"
                        description = "the name of a database which is used as the current database for the connection"
                "--offlineok" = {
                        set_if = "$mssql_health_offlineok$"
                        description = "if offline databases are perfectly ok for you"
                "--nooffline" = {
                        set_if = "$mssql_health_nooffline$"
                        description = "Skip the offline databases"
                "--dbthresholds" = {
                        value = "$mssql_health_dbthresholds$"
                        description = "Read thresholds from a database table"
                "--notemp" = {
                        set_if = "$mssql_health_notemp$"
                        description = "Ignore temporary databases/tablespaces"
                "--commit" = {
                        set_if = "$mssql_health_commit$"
                        description = "turns on autocommit for the dbd::sybase module"
                "--method" = {
                        value = "$mssql_health_method$"
                        description = "how the plugin should connect to the database (dbi for using DBD::Sybase (default), sqlrelay for the SQLRelay proxy)"
                "--mode" = {
                        value = "$mssql_health_mode$"
                        description = "the mode of the plugin"
                "--regexp" = {
                        set_if = "$mssql_health_regexp$"
                        description = "name will be interpreted as a regular expression"
                "--warning" = {
                        value = "$mssql_health_warning$"
                        description = "the warning range"
                "--critical" = {
                        value = "$mssql_health_critical$"
                        description = "the critical range"
                "--warningx" = {
                        value = "$mssql_health_warningx$"
                        description = "The extended warning thresholds"
                "--criticalx" = {
                        value = "$mssql_health_criticalx$"
                        description = "The extended critical thresholds"
                "--units" = {
                        value = "$mssql_health_units$"
                        description = "This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free"
                "--name" = {
                        value = "$mssql_health_name$"
                        description = "the name of the database etc depending on the mode"
                "--name2" = {
                        value = "$mssql_health_name2$"
                        description = "if name is a sql statement, name2 can be used to appear in the output and the performance data"
                "--name3" = {
                        value = "$mssql_health_name3$"
                        description = "The tertiary name of a component"
                "--extra-opts" = {
                        value = "$mssql_health_extraopts$"
                        description = "read command line arguments from an external file"
                "--blacklist" = {
                        value = "$mssql_health_blacklist$"
                        description = "Blacklist some (missing/failed) components"
                "--mitigation" = {
                        value = "$mssql_health_mitigation$"
                        description = "The parameter allows you to change a critical error to a warning."
                "--lookback" = {
                        value = "$mssql_health_lookback$"
                        description = "The amount of time you want to look back when calculating average rates"
                "--environment" = {
                        value = "$mssql_health_environment$"
                        description = "Add a variable to the plugin's environment."
                "--negate" = {
                        value = "$mssql_health_negate$"
                        description = "Emulate the negate plugin. --negate warning=critical --negate unknown=critical."
                "--morphmessage" = {
                        value = "$mssql_health_morphmessage$"
                        description = "Modify the final output message."
                "--morphperfdata" = {
                        value = "$mssql_health_morphperfdata$"
                        description = "The parameter allows you to change performance data labels."
                "--selectedperfdata" = {
                        value = "$mssql_health_selectedperfdata$"
                        description = "The parameter allows you to limit the list of performance data."
                "--report" = {
                        value = "$mssql_health_report$"
                        description = "Report can be used to output only the bad news (short,long,html)"
                "--multiline" = {
                        value = "$mssql_health_multiline$"
                        description = "Multiline output."
                "--with-mymodules-dyn-dir" = {
                        value = "$mssql_health_withmymodulesdyndir$"
                        description = "Add-on modules for the my-modes will be searched in this directory."
                "--statefilesdir" = {
                        value = "$mssql_health_statefilesdir$"
                        description = "An alternate directory where the plugin can save files."
                "--isvalidtime" = {
                        value = "$mssql_health_isvalidtime$"
                        description = "Signals the plugin to return OK if now is not a valid check time."
                "--timeout" = {
                        value = "$mssql_health_timeout$"
                        description = "Seconds before plugin times out (default: 15)"

        vars.mssql_health_regexp = false
        vars.mssql_health_offlineok = false
        vars.mssql_health_commit = false
        vars.mssql_health_notemp = false
        vars.mssql_health_nooffline = false
        vars.mssql_health_report = "short"

Edit: The arguments from mssql_health “–hostname” and “–server” has different functions, from the docs

–hostname <hostname>
The database server
–server <server>
An alternative to hostname+port. <server> will be looked up in the file freetds.conf.

Hello Carsten, exactly because i don´t know how to use the itil commands on remote servers

Every time i try to create a service using the external command i get the command is not available in /usr/lib/nagios/plugins.

I guess my question is, how can i copy this command to usr/lib/nagios/plugins since it doesn´t work from scratch

Read the docs of the plugin, install the plugin + requirements on the satellite/agent then it should work. The ITL only provides the command definition.

Every plugin needs to be installed locally. There are several ways to achieve this very common are tools like ansible, chef, puppet, saltstack etc.

1 Like

Oh, that explains alot. I was stuck in the thought this was going to run from the master.

Thanks, that makes things alot more clear, I have other plugins doing the same thing but i somehow thought you were able to run stuff from the master aswell. Mainly because of this article which works in CLI

Where can i find this icinga compatible plugin, I have checked the exchange but didn´t find it. Or will it work with the nagios one?

To be more precisely, the plugin needs to be installed where it is executed. In case of check_mssql_health it could be run from master or satellites as well.

So I am trying to use the build in check command and it doesn´t work well. Despite the fact the hostname is specified it doesnt show under the inspect field done by the last check command

Last check result displays

‘/usr/lib/nagios/plugins/check_mssql_health’ ‘–mode’ ‘full-scans’ ‘–password’ ‘xxx’ ‘–report’ ‘short’ ‘–username’ ‘icinga’


Do I have to use the Server flag here instead of hostname since it seems to leave that field out of the game completely

Did you really set something into the var? You only show the fields and not the service definition

This was it! The hostname wasn´t available in custom properties even though it was added. I had to remove the entry and add it again, this time I was able to get it working


Thanks alot for the help Carsten and Roland, even though I have read the documentation it´s really hard to get a grip of everything without trial and error and some help in this forum if you have never tried Icinga before

1 Like

Would you be so kind and edit the docs and send your suggestion upstream now that you’ve found a solution? :slight_smile:

Hello Michael, It wasn´t any criticism about the documentation! Just want to point that out!

But i feel i have gotten a better understanding how stuff works now, thanks to you all and i don´t think i would have gotten this fully in the documentation because it kind of requires you to have a basic understanding right from the start. Sometimes you just need to have someone pointing you in the right direction to get a grip of everything (which you have done in a great way). Don´t know if that is fully possible in docs without writing in extreme detail.

Let me know if you need anything though and I will send it

1 Like