Ad Widget

Collapse

Problem with Powershell script and zabbix_get/zabix_sender information

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Beki4
    Junior Member
    • Jun 2024
    • 10

    #1

    Problem with Powershell script and zabbix_get/zabix_sender information

    Hello , I have prepared a PS1 script that sends information to zabbix (zabbix_trapper) but I faced the following issue.

    When I ran the script on the local Windows host I got this ("test" is the machine hostname):
    Click image for larger version

Name:	image.png
Views:	244
Size:	53.6 KB
ID:	486549
    But when I ran Zabbix_get command from the Zabbix server I got this:
    Click image for larger version

Name:	image.png
Views:	195
Size:	11.4 KB
ID:	486550

    zabbix_sender [2824]: Warning: incorrect answer from "10.100.100.20:10050": [{"version":"7.0.0","error":"unknown request "sender data""}]

    Do you know why Zabbix server does not display the machine hostname and how I can fix the problem?

  • Answer selected by Beki4 at 27-06-2024, 17:26.
    Brambo
    Senior Member
    • Jul 2023
    • 245

    There are multiple ways to use powershell to send data:
    1: send your data as a file
    Code:
    .\zabbix_sender.exe -v -z <server-ip> -p 10051 -i test.txt
    In test.txt (can be multiple line if you want to send data to multiple host / items
    Code:
    "your host name" item-key data
    2: directly, $date is for correct timestamp of the current time of that system,
    $argu is argument list: Zserver is zabbix ip, Zport is port number, key is the itemkey.
    the startproces global:Zsenderpath is the full path to my zabbix sender.exe
    Code:
        $date = Get-date -Date $data -UFormat %s
        $argu = "-z $Zserver -p $Zport -s $Zhost -k $key -o $date"
        start-process -NoNewWindow -FilePath $global:Zsenderpath -ArgumentList $argu -Wait

    Comment

    • Brambo
      Senior Member
      • Jul 2023
      • 245

      #2
      There are multiple ways to use powershell to send data:
      1: send your data as a file
      Code:
      .\zabbix_sender.exe -v -z <server-ip> -p 10051 -i test.txt
      In test.txt (can be multiple line if you want to send data to multiple host / items
      Code:
      "your host name" item-key data
      2: directly, $date is for correct timestamp of the current time of that system,
      $argu is argument list: Zserver is zabbix ip, Zport is port number, key is the itemkey.
      the startproces global:Zsenderpath is the full path to my zabbix sender.exe
      Code:
          $date = Get-date -Date $data -UFormat %s
          $argu = "-z $Zserver -p $Zport -s $Zhost -k $key -o $date"
          start-process -NoNewWindow -FilePath $global:Zsenderpath -ArgumentList $argu -Wait

      Comment

      Working...