Ad Widget

Collapse

LLD Script works on local host but returning null values to proxy/server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tmroberts
    Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Jan 2017
    • 73

    #1

    LLD Script works on local host but returning null values to proxy/server

    I am trying to set up some MSSQL monitoring that includes LLD for both instances and databases. The scripts that I have (https://github.com/MantasTumenas/Zab...oft-SQL-Server) works when run from the local host in powershell, but when I issue a zabbix_get from the proxy server I am getting null values. Here's an example of what I am getting:

    This is what I get when the script runs on the local machine:
    Code:
    PS C:\Program Files\Zabbix> .\Scripts\Discovery.mssql.instancename.ps1
    {
        "data":  [
                     {
                         "{#SQLINSTANCENAME}":  "MSSQLSERVER",
                         "{#SQLINSTANCE}":  "SQLServer",
                         "{#SQLINSTANCESERVICE}":  "MSSQLSERVER"
                     }
                 ]
    }
    PS C:\Program Files\Zabbix>



    But when I run zabbix_get from the proxy server I get the following:
    Code:
    zabbix_get -s mysqserverhost -k instances.mssql.discovery
    {
        "data":  [
                     {
                         "{#SQLINSTANCENAME}":  null,
                         "{#SQLINSTANCE}":  "MSSQL$",
                         "{#SQLINSTANCESERVICE}":  "MSSQL$"
                     }
                 ]
    }



    Can anyone shed some light on my this might be happening? I've checked the log file and the call is being called correctly as far as I can tell.

    And here is the script:
    Code:
    # Query to get instance name.
    
    $obj = [PSCustomObject] @{
        data = @((get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances | % {
            [PSCustomObject] @{
                '{#SQLINSTANCENAME}' = $_
                '{#SQLINSTANCE}' = if($_ -eq 'MSSQLSERVER') { "SQLServer" } else { "MSSQL`$$_" }
                '{#SQLINSTANCESERVICE}' = if($_ -eq 'MSSQLSERVER') { "MSSQLSERVER" } else { "MSSQL`$$_" }
            }
        }) 
    }
    Write-Output $($obj | ConvertTo-Json)
    Last edited by tmroberts; 02-12-2019, 20:31.
Working...