Ad Widget

Collapse

System.run - Escape comma ( , ) and Square brackets ( [ ] )

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • registration_is_lame
    Senior Member
    • Nov 2007
    • 148

    #1

    System.run - Escape comma ( , ) and Square brackets ( [ ] )

    Hello any idea how to escape ',' for system.run item? It seems the command I need to run has a comma in it but zabbix interprets as second parameter. Error says invalid second parameter

    system.run[powershell -c "(omreport storage controller | FINDSTR "Name").split(":").Replace(" ","") | FINDSTR /V "Name""]

    Here is the command without escaping so you can read clearly: system.run[powershell -c "(omreport storage controller | FINDSTR "Name").split(":").Replace(" ","")"]

    the comma is in Replace section
    It seems zabbix thinks that ',' comma in the command is a mode

    system.run[command,<mode>] that's the documentation https://www.zabbix.com/documentation...s/zabbix_agent


    Also the square brackets don't work. If I try to add a item with square brackets then I can't add the item as frontend doesn't allow me to add the item.

    Here is the command without escaping so you can read it clearly.

    system.run[omreport storage controller | FINDSTR "Name").split(":")[1].replace(" ","")]

    The fontend thinks square brackets are considered some kind of start and end block as a result it won't let me add the item.

    Error:
    Invalid key "system.run[omreport storage controller | FINDSTR "Name").split(":")[1].replace(" ","")] " for item "Raid Controller" on "Template OS Windows": incorrect syntax near ".replace(" ","")] ".

    I tried single quote before the start and end of the command but that did not work either
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    For a complicated command that's going to require specific quoting and escaping of special characters, you're better off creating a custom item key via a UserParameter

    If you search the forums, someone else may already have created one for omreport (not sure if someone has, but there are lots of people using Dell systems, especially in the US). Also, search for people that have examples of using PowerShell from a UserParameter, as sometimes it may require additional command-line flags.

    Comment

    Working...