Ad Widget

Collapse

item key does not support with [ ] brackets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gopkris2000
    Junior Member
    • Feb 2020
    • 15

    #1

    item key does not support with [ ] brackets

    I have tried to add a new item key to capture the read-only directory using the below command.


    Key​

    system.run[ [ -w /mount-dir ] && echo "rw" || echo "ro" ]

    but it is failing with the below errors to test.
    • Incorrect value for field "key_": incorrect syntax near "&& echo "rw" || echo "ro" ]".

    ​what is the best way to add [ ] in the item key?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    #2
    system.run[test -w /mount-dir && echo "rw" || echo "ro" ]

    Or follow docs https://www.zabbix.com/documentation...nquoted-string
    use ""-s to quote parameters for a key.
    If the key parameter is an unquoted string, any Unicode character is allowed except comma and right square bracket (]). Unquoted parameter cannot start with left square bracket ([).

    Code:
    system.run[" [ -w /mount-dir ] && echo \"rw\" || echo \"ro\" "]
    Last edited by cyber; 31-08-2022, 08:19.

    Comment

    • gopkris2000
      Junior Member
      • Feb 2020
      • 15

      #3
      It is working fine. Thanks, cyber, however, it is returning "ro" only from the items key test but the directory which I tested is writable.

      Any Idea how can we get "read-only" file system errors to the mounted partitions?

      Appreciated.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4806

        #4
        Writable to whom? Maybe they are not writeable for user zabbix?
        test -w is checking if write permission is given... It depends on, who is asking...
        Just testing the same here with very obvious /tmp and /root directories... /tmp as usual is world writeable and gives me rw as answer... /root is owned by root an no other permissions given, gives me ro. /boot gives also ro, as I cannot write there.
        Switching to root, same commands give me rw as answer as root can write everywhere...

        Comment

        • gopkris2000
          Junior Member
          • Feb 2020
          • 15

          #5
          Originally posted by cyber
          Writable to whom? Maybe they are not writeable for user zabbix?
          test -w is checking if write permission is given... It depends on, who is asking...
          Just testing the same here with very obvious /tmp and /root directories... /tmp as usual is world writeable and gives me rw as answer... /root is owned by root an no other permissions given, gives me ro. /boot gives also ro, as I cannot write there.
          Switching to root, same commands give me rw as answer as root can write everywhere...
          Thanks cyber It worked what I expected after enabled AllowRoot in zabbix configuration.

          Comment

          Working...