Ad Widget

Collapse

grabbing a value from a text file for userpapmters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muteb
    Junior Member
    • Apr 2013
    • 4

    #1

    grabbing a value from a text file for userpapmters

    Hi,

    I have this file containing numbers of lines and my interest is only for one line which is "
    capture.kernel_packets | RxPcapeth11 | 680". As you see, it has three culmons and I only need the third one so i used the command " root@ubuntu:~# tail -n53 '/var/log/suricata/stats.log'| grep 'capture.kernel_packets' | awk '/[0-9]/ {print $5}'" which prints out the value "680". however, when I try to import it to " /etc/zabbix/zabbix_agentd.conf" which the this command "UserParameter=suricata.packets[*],tail -n53 '/var/log/suricata/stats.log'| grep 'capture.kernel_packets' | awk '/[0-9]/ {print $5}'" it works fine but when i test it, it is presenting the the whole line as:
    root@ubuntu:~# zabbix_agentd -t suricata.packets
    suricata.packets[] [t|capture.kernel_packets | RxPcapeth11 | 680]

    can anyone help me to only extract that number?

    thanks
  • neogan
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2011
    • 118

    #2
    Seems you do not allow UnsafeUserParameters
    Unless UnsafeUserParameters agent daemon configuration option is enabled, it is not allowed to pass flexible parameters containing these symbols: \ ' ” ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @
    Please check you zabbix_agentd.conf for this option. Hope it help.

    Comment

    • muteb
      Junior Member
      • Apr 2013
      • 4

      #3
      thanks for the rplay

      I'm sure the command shell passess bt didn't execute entierly. it shows this message at the website "Type of received value [capture.kernel_packets | RxPcapeth11 | 680] is not suitable for value type [Numeric (fl','','on');".

      Comment

      • neogan
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Sep 2011
        • 118

        #4
        1) You need cut this [*] from your key in UserParameter. And all will be good Or you want to use various parameters?

        or see in documentation
        To use positional references unaltered, specify double dollar sign - for example, awk '{print $$2}'.
        You just lose normal {print } statement
        2) Add in your print another one $ char.

        Comment

        • muteb
          Junior Member
          • Apr 2013
          • 4

          #5
          thanks you so much.

          I removed the[*] and it worked like a charm. really appariciate it

          Comment

          Working...