Ad Widget

Collapse

Runnig PowerShell script using externalscripts / system.run on Linux.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zaicnupagadi
    Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2010
    • 73

    #1

    Runnig PowerShell script using externalscripts / system.run on Linux.

    Hi Everyone,

    I am working on running some PowerShell scripts BUT - on linux, pswh works well in general from the command prompt, here is the simply command that check the date:

    pawel@zabbix:/$ pwsh -Command "Get-Date"
    Thursday, September 24, 2020 2:24:22 PM
    However when trying to run it as an item I am getting an error:

    pawel@zabbix$ zabbix_get -s 127.0.0.1 -k system.run["pwsh -Command "Get-Date""]
    cannot create user data directory: /nonexistent/snap/powershell/137: Permission denied
    Checked that - indeed "/nonexistent" is the location of the zabbix user:

    pawel@zabbix$ getent passwd zabbix
    zabbix:x:112:114::/nonexistent:/usr/sbin/nologin
    I gave 777 starting from /nonexistent till the /137 folder - nothing.

    I've found something like this where someone runs powershell scripts https://www.b-blog.info/en/monitorin...th-zabbix.html however he shoots to zabbix with them with zabbix trapper - maybe that was the reason this person done it this way?

    I've tried to run pwsh with all these switches [-NoLogo] [-NonInteractive] [-NoProfile] and... unfortunately [-NothingHelpedAndIamFrustratedAF].

    Is there something specific that need to be done for powershell / linux system to allow zabbix Powershell script executions on a linux machine?

    J
  • zaicnupagadi
    Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2010
    • 73

    #2
    Hi! So what I did I installed powershell on ubuntu in accordance with Microsoft instructions and all works well now. I have a powershell script in externalscripts which is triggered by bash script in an external item - works as well as on Microsoft Machines ^^

    ​​​​​​

    Comment

    Working...