Ad Widget

Collapse

Beginner need some help with zabbix and powershell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tomas58
    Junior Member
    • May 2019
    • 1

    #1

    Beginner need some help with zabbix and powershell

    Hello, so I'm newbie IT support intern. Have some learning tasks to do. Task is quite simple, cause I'm learning powershell and little bit of zabbix, I have an task to create some kind of powershell script which sends trigger to zabbix. Firstly I'm just thinking of making simple script, which checks if USB is connected to PC, if not it should trigger zabbix, I'm totally newbie to zabbix so not sure how triggers works, is it even possible to do such thing like I said? Let's say here is my simple script:

    $usb=Get-WmiObject Win32_LogicalDisk -filter "DeviceID = 'E:' "
    if(!$usb)
    {
    }

    I can create like scheduled task to check it every 30minutes or so, but how to send trigger to zabbix when the script runs and the USB is removed? Maybe there are easier options, but I need to do it using Powershell. Any help is appreciated.
  • steeladept
    Member
    • Sep 2018
    • 69

    #2
    It absolutely is possible. I, however, don't know exactly how to do this myself. I have been putting it off due to other Zabbix items I am working through. However, I do know Powershell and I can tell you this: make sure your Powershell script works 100% with a return output that Zabbix can capture - a number, word, or whatever is appropriate (I find numbers usually work best, but again, with Zabbix specifically, I don't know if another way is better or not). When Zabbix calls the script, this output is what it will parse to trigger off of.

    So with your script above, you may wish to have it just "return 0" inside the 'if' block and have an else "return 1".

    Then in Zabbix, logically, if script=0 trigger alert.

    It is in the calling and returning that I do not know (which I know, is a big part of the ask).

    Comment

    Working...