Forum Discussion

Robert_Reznicek's avatar
Robert_Reznicek
Icon for Nimbostratus rankNimbostratus
Apr 14, 2010

printing variables values

Is it possible to use another method for printing, that log command?

 

I need to print items of array for debug purposes (approx. 1000 items) and i found out, that when using log command in foreach loop, some entries are omitted, because of syslog limitations. I also tried to use HTTP:respond and return the values in "content" section, but this is not possible.

 

I suppose it is not possible to use "puts" command and define somehow channel for printing.

 

4 Replies

  • Hi Robert,

    On 10.1, logging ~100-400 lines in a loop seems to work. Beyond that, you start seeing throttling. Your idea of using HTTP::respond seems to work in a simple test. What issue did you see with it?

    
    when RULE_INIT {
    
        load up an array
       for {set i 0} {$i < 1000} {incr i} {
          set ::arr($i) "value$i"
          log local0. "\$i-1000: $i"
       }
       log local0. "size: [array size ::arr]"
    }
    when HTTP_REQUEST {
       HTTP::respond 200 content [array get ::arr]
    }
    

    Aaron
  • Hi Aaron,

     

    thank you for your help. I used nearly the same piece of code in the HTTP::respond:

     

     HTTP::respond 200 content [array names ::arr]
     

     

    but the output is truncated (i only get 4268 chars).

     

    I tried to use loop behind the HTTP::respond and print the array entry by entry, but this doesn't work.

     

    I also tried to append the entries in one string and then print it, but there is limitation for length of the string.
  • That's odd. In 10.0.1, I've received as much as 1.7MB using this:

    
    when RULE_INIT {
       
       for {set i 0} {$i < 100000} {incr i} {
          set ::arr($i) "value$i"
          log local0. "\$i-1000: $i"
       }
       log local0. "size: [array size ::arr]"
    }
    when HTTP_REQUEST {
    
       HTTP::respond 200 content [array get ::arr]
    }
    

    $ curl -s 10.42.2.10 |wc -m

    1677779 (~1.6Mb)

    Aaron
  • I found it, I put "drop" command behind the HTTP::respond. When removed, i get the whole array.

     

    BTW, I'm still curious why the drop was executed before the HTTP::respond finished execution.

     

     

    Anyway, thank you very much for your help Aaron!

     

     

    Robert