Ad Widget

Collapse

One zabbix agent on windows doesn't send data from scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • titans2020
    Junior Member
    • Apr 2020
    • 3

    #1

    One zabbix agent on windows doesn't send data from scripts

    Hi everyone.
    I have zabbix agent which was installed on windows 2016 server.
    I created powershell script which for test return a constant value.
    And added it to zabbix conf file with such line:

    Code:
    UserParameter=testkey[*],PowerShell.exe -nologo "C:\Scripts\Test.ps1"
    After I added the template in zabbix server and added this template to specified server.
    This key shows me on the monitor with is the grey color and it doesn't receive any value.
    I changed for test value like this:

    Code:
    UserParameter=testkey[*],echo 51
    And after a few seconds, I saw this value in zabbix.
    Could you please suggest how to fix it?
    Probably it is a security issue?
    I tried to switch zabbix agent to admin account, but during the switch, it shows me the error: Access denied.
    Log error level equals 3 and I don't see any error.

    I did the same in Windows 10 and this script is working.
    So something I missed during configuration on the server.
  • james.shaw
    Junior Member
    • Mar 2020
    • 15

    #2
    Is the Agent connecting to the Window server? Does it show as green on the Zabbix web UI?

    So long as the agent is connecting, the script should really be fine, does it run through any trigger/macro on the Zabbix side that you may have forgot to setup, and is this a custom built script or is it one supplied by zabbix/zabbix share?

    In case the agent isnt communicating with the server (I am going to bed now so won't reply until tomorrow and if it is this, then you won't be waiting as long for a reply), run these commands in powershell:

    netsh advfirewall firewall add rule name="Zabbix Allow incoming V4 echo request" protocol="icmpv4:8,any" dir=in action=allow
    netsh advfirewall firewall add rule name="Zabbix Open Port 10050" protocol=TCP dir=in action=allow localport=10050

    Also, what are you trying to achieve with this script?

    Comment

    • titans2020
      Junior Member
      • Apr 2020
      • 3

      #3
      Hi.
      Thanks for your reply.
      Let me answer all questions.

      Is the Agent connecting to the Window server? Does it show as green on the Zabbix web UI?
      Yes. An agent has been connected to Zabbix server. I added Template Windows OS and see every parameter except my customizations.

      In case the agent isnt communicating with the server
      I opened port 10080 in zabbix, and can connect via telnet from windows get to Zabbix server.
      But not port 10050 from agent to zabbix server is closed. Should I open it?

      what are you trying to achieve with this script?
      So I have disk quota for sharefolder, and I need to send a notification when space is full.


      Run test (replace variable with string that is in zabbix item key in '[]'):
      - run command: zabbix_agentd -t testkey[variable] -c absolute_path_to_agent_config_file
      Yes, I put to script static value: Write-Host 78.1

      After test zabbix agents I see the output:
      quotafreespace[quotafreespace] [t|78.1]

      Probably it is enough for zabbix.
      But still in the tab "Monitoring -> Latest date" the key selected with grey color, and no input date commig.
      But again if I put in agent config value: UserParameter=quotafreespace[*],echo 25
      I immediately see this value in the latest data.
      Still doesn't understand what's happened.

      Comment

      • titans2020
        Junior Member
        • Apr 2020
        • 3

        #4
        Yes, I do.
        With execution powershell script zabbix doesn't receive value.
        The record looks like:
        Code:
        UserParameter=quotafreespace[*],C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -file C:\Scripts\Test.ps1
        Separate execution of this key in the agent is a success:
        quotafreespace[quotafreespace] [t|78.1]
        If I change in config file to such record:
        Code:
        UserParameter=quotafreespace[*],echo 25
        Then it immediately shows in zabbix the result equal 25.

        Comment

        Working...