Ad Widget

Collapse

How to add an UserParameter for zabbix_agent on windows OS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rubynle
    Junior Member
    • Sep 2014
    • 4

    #1

    How to add an UserParameter for zabbix_agent on windows OS

    Hi,

    I want add an userparameter to monitor MSSQL data.

    zabbix folder is c:\zabbix
    script folder is c:\zabbix\script

    I wrote two scripts and put them into c:\zabbix\script

    MSSQL.bat
    @echo off
    sqlcmd -U sa -P mypassword -Q "set nocount on;select count(*) from sys.sysprocesses where open_tran>0"

    test.bat
    @echo off
    for /f %%i in ('MSSQL.bat') do echo %%i

    Then I update c:\zabbix\zabbix_agentd.win.conf to add an userparamter

    UserParameter=MSSQL.T,c:\zabbix\script\test.bat

    I got an message when I run zabbix_agentd.exe -t MSSQL.T under c:\zabbix

    MSSQL.T [m|ZBX_NOTSUPPORTED] [Unsupported
    item key.]

    Is there some mistakes I made or something else I missed?

    thanks
  • rubynle
    Junior Member
    • Sep 2014
    • 4

    #2
    Forgot the version

    Version information

    Zabbix 2.4.0
    Zabbix Agent 2.4.0

    Windows Windows Server2008R2

    Comment

    • aib
      Senior Member
      • Jan 2014
      • 1615

      #3
      It's possible that you have a problem with access levels.
      By default, Zabbix agent starts under System account, and because of that, it cannot collect some information (ex. mapped drives, started processes for user)
      I believe, that your scripts tested under user account.

      Try to start Debug Logging for Zabbix Agent & MS SQL and check if I'm wrong.
      Sincerely yours,
      Aleksey

      Comment

      • rubynle
        Junior Member
        • Sep 2014
        • 4

        #4
        Originally posted by aib
        It's possible that you have a problem with access levels.
        By default, Zabbix agent starts under System account, and because of that, it cannot collect some information (ex. mapped drives, started processes for user)
        I believe, that your scripts tested under user account.

        Try to start Debug Logging for Zabbix Agent & MS SQL and check if I'm wrong.
        Thanks for your reply.
        I changed zabbix agent runs under one of administrators member and restart it.
        Unlucky, it didn't work.
        It was show me the same message as before.

        Comment

        • rubynle
          Junior Member
          • Sep 2014
          • 4

          #5
          Fixed

          We should run zabbix_get on zabbix server to check the parameter defined by user.
          It can not work to use zabbix_agentd on client at all.

          Thanks

          Comment

          • grantav
            Junior Member
            • Dec 2013
            • 7

            #6
            Hi Rubynle

            Almost a year since you posted this thread. I had success here is a VB script.

            You need to define your data source name in the odbc connector, then you can use it in the script.

            VBS example I used:

            Code:
            option explicit
            
            Dim Connection
            Dim Recordset
            Dim SQL
            Dim Server
            Dim field
            
             
            'declare the SQL statement that will query the database
            
            SQL = ""
            
            'create an instance of the ADO connection and recordset objects
            
            ' 
            
            Set Connection = CreateObject("ADODB.Connection")
            
            Set Recordset = CreateObject("ADODB.Recordset")
            
            
            'open the connection to the database
            
            Connection.Open "DSN=DSN-NAME;UID=username;PWD=DBPWD;Database=DBNAME"
            
             
            
            'Open the recordset object executing the SQL statement and return records 
            
            Recordset.Open SQL,Connection
            
             
            
            'first of all determine whether there are any records 
            
            If Recordset.EOF Then 
            
            wscript.echo "There are no records to retrieve; Check that you have the correct job number."
            
            Else 
            
            'if there are records then loop through the fields 
            
            Do While NOT Recordset.Eof   
            
            field = Recordset("SMSes")
            
            
            if field <> "" then
            
            wscript.echo field
            
            end if
            
            Recordset.MoveNext     
            
            Loop
            
            End If
            
             
            'close the connection and recordset objects to free up resources
            
            Recordset.Close
            
            Set Recordset=nothing
            
            Connection.Close
            
            Set Connection=nothing
            The in the zabbix_agent conf:
            UserParameter=zbxParamaName,cscript //NoLogo "C:\path\to\script.vbs"

            Hope this helps.

            Regards
            G

            Comment

            • Balu123
              Junior Member
              • Aug 2015
              • 7

              #7
              Alert Notification mail

              Hi All,

              I have set the script for Email alert notification.
              In action log status shows sent but i dint receive the mails,earlier i was received.
              I have attached the screen shot.

              Thanks
              Last edited by Balu123; 15-09-2015, 10:41.

              Comment

              Working...