Ad Widget

Collapse

Another problem with custom discovery external check

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smersh
    Member
    • Jul 2013
    • 49

    #1

    Another problem with custom discovery external check

    Hello,

    I created custom discovery of mssql bases by cmd script.

    zabbix_agentd.win.conf:
    Code:
    UnsafeUserParameters=1
    UserParameter = mssql.db.discovery,"C:\Program Files\Zabbix\zabbix_mssql_bases.cmd"
    zabbix_mssql_bases.cmd:
    Code:
    ...
    echo/{
    echo/	"data":[
    echo.
    setlocal ENABLEDELAYEDEXPANSION
    set "first=1"
    for /F "usebackq tokens=1" %%i in (`osql -E -i sql2000bases.sql -n -h-1`) do (
    	if NOT "%%i"=="" (
    		if NOT "%%i"== "(22" (
    			if NOT "!first!"=="1" (
    				echo/	}
    				echo/	,
    			)
    			set "first=0"
    			echo/	{
    			echo/		"{#DBNAME}":"%%i"
    			)
    		)
    	)
    )
    echo/	}
    echo.
    echo/	]
    echo/}
    GOTO :EOF
    sql2000bases.sql:
    Code:
    select name from master..sysdatabases where dbid > 4
    cmd-script executing output in console:
    Code:
    {
            "data":[
    
            {
                    "{#DBNAME}":"base_1"
            }
            ,
            {
                    "{#DBNAME}":"base_2"
            }
            ,
            {
                    "{#DBNAME}":"base_3"
            }
            ,
            {
                    "{#DBNAME}":"base_x"
            }
    
            ]
    }
    zabbix_agentd.log:
    Code:
    4956:20140325:172034.205 Run remote command ["C:\Program Files\Zabbix\zabbix_mssql_bases.cmd"] Result [87] [{
    
    	"data":[
    
    
    
    	{
    
    ]...
      4956:20140325:172034.205 Sending back [{
    
    	"data":[
    
    
    
    	{
    
    		"{#DBNAME}":"Cannot"
    
    	}
    
    	,
    
    	{
    
    		"{#DBNAME}":"No"
    
    	}
    
    
    
    	]
    
    }]
    In result of discovery Items for 2 bases appears: "Cannot" and "No".
    What am I doing wrong?

    P.S. Zabbix Server ver. 2.2.2; Agent ver. 2.2.1
    Last edited by Smersh; 26-03-2014, 13:26.
  • aib
    Senior Member
    • Jan 2014
    • 1615

    #2
    Regular question - Are you sure that the user Zabbix has enough permission to start the program 'osql' ?

    Did you try to do it manually with zabbix user privileges?

    And - last not the least - did you try to modify script to use the full path to the program osql? Something like that :
    ........
    for /F "usebackq tokens=1" %%i in (`"c:\program files\sqlWhatEver\osql.exe" -E -i sql2000bases.sql -n -h-1`) do (
    ........
    Sincerely yours,
    Aleksey

    Comment

    • Smersh
      Member
      • Jul 2013
      • 49

      #3
      Originally posted by aib
      And - last not the least - did you try to modify script to use the full path to the program osql?
      Yes, this was the problem. I have found it a short time ago. Zabbix agent launching by local system account and considers his working directory somewhere out of program folder (I think it is the system folder).

      Anyway, thanks for assistance.

      Comment

      Working...