Ad Widget

Collapse

How to put a crriage retrun in a zabbix_sender character value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • themons
    Senior Member
    • Feb 2005
    • 110

    #1

    How to put a crriage retrun in a zabbix_sender character value

    Hello,

    We use zabbix_sender and I would like to have a carriage return in the value sended to zabbix server.

    for the moment what I have test and working its this :

    Code:
    #!/bin/sh
    
    test_val=`ls -ltr /opt/`
    zabbix_sender -zzabbix -sTEST -ktest -o"$test_val"
    In this case I have in the history the same output as I do in the shell

    I have also test this one but it doesn't work:

    Code:
     zzabbix_sender -zzabbix -sTEST -ktest -o"$test_val" -o"Hello \n test <br /> test char(13) \r test 123 \r\n 7987645 <br> 7897651 ^M 798"
    Everything is on one line in history. Can you help me

    Thanks
    Zabbix 1.8.3
    SLES 11 x64

    French Zabbix user
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    i'm not completely sure i understood the request, but maybe you want
    Code:
     echo -e "some\ntext\nin\nmultiple\nlines"
    Zabbix 3.0 Network Monitoring book

    Comment

    • themons
      Senior Member
      • Feb 2005
      • 110

      #3
      Oups there is just a mistake in my copy past ;-)

      correct command
      Code:
      #zabbix_sender -zzabbix -sTEST -ktest -o"My value will be send with multiples lines \n New line"
      Thats right but if its possible I would like to do something like this but without echo -e.
      Zabbix 1.8.3
      SLES 11 x64

      French Zabbix user

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        you could try replacing \n with $'\n' (if using bash), although i'll admit i have no idea whether it will expand as expected
        Zabbix 3.0 Network Monitoring book

        Comment

        • themons
          Senior Member
          • Feb 2005
          • 110

          #5
          It works fine with this one

          Code:
          #zabbix_sender -zzabbix -sTEST -ktest -o"Hello"$'\n'"new line"
          But If I want to do this I recive only the first line

          Code:
          #!/bin/sh
          
          test_val="Hello"$'\n'"new line"
          
          zabbix_sender -zzabbix -sTEST -ktest -o$test_val
          Zabbix 1.8.3
          SLES 11 x64

          French Zabbix user

          Comment

          • richlv
            Senior Member
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Oct 2005
            • 3112

            #6
            you seem to be omitting quoting for some reason.
            why not -o"$test_val" ?
            Zabbix 3.0 Network Monitoring book

            Comment

            • themons
              Senior Member
              • Feb 2005
              • 110

              #7
              YES IT WORKS

              Thanks a lot
              Zabbix 1.8.3
              SLES 11 x64

              French Zabbix user

              Comment

              Working...