Ad Widget

Collapse

Unsupported Item Key when using UserParameter on Scripts as Action Operation

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RaulChiarella
    Member
    • Apr 2021
    • 59

    #1

    Unsupported Item Key when using UserParameter on Scripts as Action Operation

    Hello, everyone.
    So...
    1. I created a UserParameter that restarts a Windows Service, like this:

    UserParameter=restartService[*], powershell -NoProfile -ExecutionPolicy Bypass Restart-Service -Name "$1" -Force

    2. I created that script so I could restart a stopped service on Administration -> Scripts like this:
    Scope: Action Operation
    Script: restartService[{EVENT.TAGS.Service}]

    3. Finally, I applied that action on a Trigger Action so when a specific service is offline, I would execute that command and restart the service.

    But, the problem is that when the trigger occurs, it tries to execute the action and it returns "Unsupported item key" on the remote command.
    What am I doing wrong? Am I forgetting something?

    I already restarted the Zabbix Agent and I created a item called Restart Service Test to see if I could restart SysMain using "reiniciaServico[SysMain]" and it worked...
    But when using that UserParameter on a Action Operation, it is giving me that Unsupported Key error.

    Any tips?
  • Answer selected by RaulChiarella at 24-07-2024, 20:16.
    Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    Action script commands are not UserParameters (or other agent items). You need to enter the shell commands in the Commands field.

    Click image for larger version  Name:	image.png Views:	0 Size:	12.2 KB ID:	488167

    Consequently, you need to allow the system.run[] execution in the agent configuration, as the commands are run with system.run[] item.

    Markku
    Last edited by Markku; 24-07-2024, 10:25.

    Comment

    • Markku
      Senior Member
      Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
      • Sep 2018
      • 1781

      #2
      Action script commands are not UserParameters (or other agent items). You need to enter the shell commands in the Commands field.

      Click image for larger version  Name:	image.png Views:	0 Size:	12.2 KB ID:	488167

      Consequently, you need to allow the system.run[] execution in the agent configuration, as the commands are run with system.run[] item.

      Markku
      Last edited by Markku; 24-07-2024, 10:25.

      Comment

      • RaulChiarella
        Member
        • Apr 2021
        • 59

        #3
        Originally posted by Markku
        Action script commands are not UserParameters (or other agent items). You need to enter the shell commands in the Commands field.

        Click image for larger version Name:	image.png Views:	0 Size:	12.2 KB ID:	488167

        Consequently, you need to allow the system.run[] execution in the agent configuration, as the commands are run with system.run[] item.

        Markku
        Thank you, it worked. I did'nt know that I could'nt use UserParameters on scripts! Thanks for the tip.
        The final AllowKey for `system.run[]` tho was: AllowKey=system.run[*powershell*Restart-Service*,*]
        So Zabbix Agent restarted the service successfully.

        Comment

        Working...