Page 1 of 1

check_mssql (Solved)

Posted: Mon Jul 15, 2019 6:05 am
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

Re: check_mssql

Posted: Mon Jul 15, 2019 3:14 pm
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
          }

Re: check_mssql

Posted: Tue Jul 16, 2019 3:34 am
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.

Re: check_mssql

Posted: Wed Jul 17, 2019 2:51 pm
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
              }

Re: check_mssql

Posted: Thu Jul 18, 2019 8:27 am
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

Re: check_mssql (Solved)

Posted: Thu Jul 18, 2019 4:41 pm
by mbellerue
Here is one of our go-to resources for NRPE.

https://assets.nagios.com/downloads/nag ... e/NRPE.pdf