check_mssql (Solved)

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
simob82
Posts: 3
Joined: Wed Jul 03, 2019 3:16 am

check_mssql (Solved)

Post by simob82 »

Hi guys, thank for your great job!
Since two weeks I'm facing troubles to make up&running this [1] plugin, now I have no idea how to do that.
I try to explain you:
When run from nagios server, it works fine:

Image


Also when started from mssql via powershell works as desired:

Image


But from scheduled job it doesn't return any output:

Image

This is my services definition:

Code: Select all

define service{
        use                     generic-service
        host_name               vmbg-mssql01
        service_description     SQL - Jobs
        check_command           check_nrpe!check_mssql -c check_mssql -a Jobs INST01
        contact_groups                                  ictlog
        }



define service{
        use                     generic-service
        host_name               vmbg-mssql01
        service_description     SQL - DB status
        check_command           check_nrpe!check_mssql -c check_mssql -a DBStatus  INST01
        contact_groups                                  ictlog
       }

define service{
        use                     generic-service
        host_name               vmbg-mssql01
        service_description     SQL - Connection Time
        check_command           check_nrpe!check_mssql -c check_mssql -a ConnectionTime INST01
        contact_groups                                  ictlog
       }


define service{
       use                     generic-service
       host_name               vmbg-mssql01
       service_description     SQL - DB Size
       check_command           check_nrpe!check_mssql -c check_mssql -a  TempDBSize  INST01
       contact_groups                                  ictlog
      }

The service was tested even without the "-c check_mssql -a [...] "
And here my nsclient.ini, modified as described here [2]

Code: Select all

[/settings/external scripts/scripts]
check_mssql = cmd /c echo scripts\\check_mssql.ps1 "$ARG1$" ; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass  -command -


; Script to check external scripts and/or internal aliases.
CheckExternalScripts.dll

[Script Wrappings]
vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
bat=scripts\%SCRIPT% %ARGS%
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command -
ps1 = cmd /c echo scripts%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command -
ps1=cmd /c echo scripts\\\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

[Wrapped Scripts]
check_mssql=check_mssql.ps1 $ARG1$

[/settings/external scripts]
allow arguments = true
;use_file = 1


--------
;[/settings/external scripts/scripts]
;check_mssql=check_mssql.ps1


;[Script Wrappings]
;ps1 = cmd /c echo %SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass C:\scripts\check_mssql.ps1 "$ARG1$"-command -
;check_mssql = cmd /c echo C:\scripts\check_mssql.ps1 "$ARG1$" ; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass ;C:\scripts\check_mssql.ps1 "$ARG1$" -command -

; POWERSHELL WRAPPING -
;ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command -


;[Wrapped Scripts]
;check_mssql=C:\scripts\check_mssql.ps1 $ARG1$
; POWERSHELL WRAPPING -
;ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command -


;[/settings/external scripts]
;allow arguments = true
;use_file = 1
It is all commented in/out due to all my try. I can't understand what is wrong, could you please suggest me where I have to fix? I have no idea...
Thank in advance guys! if I forget any useful info let me know!
best regard

simob from Italy


[1] https://github.com/yosbit/nagios-plugins/
[2] https://exchange.nagios.org/directory/P ... ct/details
Last edited by simob82 on Thu Jul 18, 2019 8:30 am, edited 1 time in total.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: check_mssql

Post by cdienger »

What does the check_nrpe service definition look like(in commands.cfg most likely)? It looks like service defintions are passing the check_mssql command twice which can break it depending on how the command definition is configured. Try modifying the service definitions to look like:

Code: Select all

    define service{
            use                     generic-service
            host_name               vmbg-mssql01
            service_description     SQL - Jobs
            check_command           check_nrpe!check_mssql -a Jobs INST01
            contact_groups                                  ictlog
            }



    define service{
            use                     generic-service
            host_name               vmbg-mssql01
            service_description     SQL - DB status
            check_command           check_nrpe!check_mssql -a DBStatus  INST01
            contact_groups                                  ictlog
           }

    define service{
            use                     generic-service
            host_name               vmbg-mssql01
            service_description     SQL - Connection Time
            check_command           check_nrpe!check_mssql -a ConnectionTime INST01
            contact_groups                                  ictlog
           }


    define service{
           use                     generic-service
           host_name               vmbg-mssql01
           service_description     SQL - DB Size
           check_command           check_nrpe!check_mssql -a  TempDBSize  INST01
           contact_groups                                  ictlog
          }
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
simob82
Posts: 3
Joined: Wed Jul 03, 2019 3:16 am

Re: check_mssql

Post by simob82 »

Ciao cdienger,
thank for your answer. Your advice has been useful and I could do one step ahead further.
These are the check_nrpe and the command.cfg

Code: Select all

# this command runs a program $ARG1$ with arguments $ARG2$

define command {
        command_name    check_nrpe
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

# this command runs a program $ARG1$ with no arguments
define command {
        command_name    check_nrpe_1arg
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}


define command {
        command_name    check_nrpe_2arg
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ -a "$ARG2$" "$ARG3$"
}
################################
command.cfg

Code: Select all

# 'check_mssql' command definition
define command{
        command_name    check_mssql
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}

# 'check_mssql_db' command definition
define command{
        command_name    check_mssql_db
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}
# 'check_mssql_db' command definition
define command{
        command_name    check_mssql_jobs
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}
# 'check_mssql_db' command definition
define command{
        command_name    check_mssql_log
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
}
######################
As reported in command line it expect the -c that doesn't match with my "check_command" on service.
Now it become:

Code: Select all

# 'check_mssql' command definition
define command{
        command_name    check_mssql
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -a $ARG1$
}

# 'check_mssql_db' command definition
define command{
        command_name    check_mssql_db
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -a $ARG1$
}



# 'check_mssql_db' command definition
define command{
        command_name    check_mssql_jobs
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -a $ARG1$
}


# 'check_mssql_db' command definition
define command{
        command_name    check_mssql_log
        command_line    /usr/lib/nagios/plugins/check_mssql -H $HOSTADDRESS$ -a $ARG1$
}

  • - Modified
    - Reloaded
    - Scheduled
But is not enough, I have the same error, no output returned.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: check_mssql

Post by cdienger »

The INST01 part of the command doesn't appear to be needed and given the way the check_nrpe service is configured, try this:

Code: Select all

        define service{
                use                     generic-service
                host_name               vmbg-mssql01
                service_description     SQL - Jobs
                check_command           check_nrpe!check_mssql!Jobs
                contact_groups                                  ictlog
                }



        define service{
                use                     generic-service
                host_name               vmbg-mssql01
                service_description     SQL - DB status
                check_command           check_nrpe!check_mssql!DBStatus
                contact_groups                                  ictlog
               }

        define service{
                use                     generic-service
                host_name               vmbg-mssql01
                service_description     SQL - Connection Time
                check_command           check_nrpe!check_mssql!ConnectionTime
                contact_groups                                  ictlog
               }


        define service{
               use                     generic-service
               host_name               vmbg-mssql01
               service_description     SQL - DB Size
               check_command           check_nrpe!check_mssql!TempDBSize
               contact_groups                                  ictlog
              }
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
simob82
Posts: 3
Joined: Wed Jul 03, 2019 3:16 am

Re: check_mssql

Post by simob82 »

Hi cdienger,
as you can see
Image

all works fine and it's all thanks to you.
Really really thanks!
Have a nice days, weeks...years and life : ]

#----------EDIT------------#

One think I can't understand, in these weeks I followed a lot of posts, threads, etc etc but on one suggest me to do what you did, so I'd want know what way of thinking did you do? there are any resources that show how to do in your way? What I ought to have done?
thank again!

Simo
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: check_mssql (Solved)

Post by mbellerue »

Here is one of our go-to resources for NRPE.

https://assets.nagios.com/downloads/nag ... e/NRPE.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked