Forum Discussion

marvn_58503's avatar
marvn_58503
Icon for Nimbostratus rankNimbostratus
Oct 23, 2013
Solved

What is the correct way to script multiple newline characters in iApp (to create a monitor)

I have a HTTP monitor which requires a \r\n\r\n at the end. For the life of me, I cannot fix the syntax on this.

I end up with the following debugs in /var/tmp/scriptd.out (sanitised obviously).

With the following line:

set monitor_send "\"GET /hosting/discovery HTTP/1.1\r\nHost: $::deploy__monitor_dns_name\r\nConnection: Close\r\n \r\n\""

I get the following result:

create / ltm monitor http test_lync_wac_internal_http_monitor defaults-from http interval 30 timeout 91 send "GET /hosting/discovery HTTP/1.1\r\nHost: myserver.mydomain.local\r\nConnection: Close\r\n \r\n" recv "wopi-discovery"

With the following line:

set monitor_send "\"GET /hosting/discovery HTTP/1.1\r\nHost: $::deploy__monitor_dns_name\r\nConnection: Close\r\n\r\n\""

I get the following result:

create / ltm monitor http test_lync_wac_internal_http_monitor defaults-from http interval 30 timeout 91 send "GET /hosting/discovery HTTP/1.1\r\nHost: myserver.mydomain.local\r\nConnection: Close\r\n" recv "wopi-discovery"

The final part of the send string must read "Connection: Close\r\n\r\n" to work correctly.

In both cases this is using the f5.app_utils:create_monitor procedure.

set monitor_name [tmsh::run_proc f5.app_utils:create_monitor \
                    $app_name $monitor_type $monitor_interval "$monitor_send" \
                    "$monitor_recv" $::HTTP_11_VERSION_STRING $monitor_dns_name]

I did try making one directly with LTM commands but I experienced difficulty with escaping and it sent the \r\n as linefeed characters instead of literal text.

This means a manual edit of the monitor each time a setting is changed in the iApp, which isn't going to be regular, but will cause an outage when someone forgets to check (and they will). What's the right way to escape two newlines?

Any help is appreciated, thanks.

  • The 11.4 f5.http template uses the following:

    'GET $::monitor__uri HTTP/1.1\\r\\nHost: $hostname\\r\\nConnection: Close\\r\\n\\r\\n'
    The extra backslash is consumed within the iApp, and the result is correct. It does not use app_utils.

9 Replies

    • Fred_Slater_856's avatar
      Fred_Slater_856
      Historic F5 Account
      OK, I see it. And the output you are viewing is from scriptd.out or from a sniffer like Wireshark?
    • marvn_58503's avatar
      marvn_58503
      Icon for Nimbostratus rankNimbostratus
      Okay, I've cleaned up my poorly-replied mess in this thread, and have added proper debugging information into the question itself, with output from /var/tmp/scriptd.out and the various test lines of code in the iApp. Thanks for looking at it.
  • Fred_Slater_856's avatar
    Fred_Slater_856
    Historic F5 Account

    OK, that helps. There is nothing inherent in iApps that does anything specific with monitors, but the iApp template code may be adding an extra newline. Scriptd.out logs are created by the iApp itself, and can sometimes be misleading when the log contains escaped characters. You may want to check the monitor you create in the UI, or directly check the traffic with Wireshark to see if you really have a problem. If you tell me which iapp you are using and which version of TMOS (11.3 perhaps?) you are running, I can look at the code and try to explain what you are seeing.

     

    • marvn_58503's avatar
      marvn_58503
      Icon for Nimbostratus rankNimbostratus
      Yeah the monitor itself definitely reflects the output you're seeing in scriptd.out, I've verified that. We're on TMOS11.4. I might have to have a dig around in some F5 iApps and see if there's an answer in there, as they may have already had to fix this.
  • Fred_Slater_856's avatar
    Fred_Slater_856
    Historic F5 Account

    The 11.4 f5.http template uses the following:

    'GET $::monitor__uri HTTP/1.1\\r\\nHost: $hostname\\r\\nConnection: Close\\r\\n\\r\\n'
    The extra backslash is consumed within the iApp, and the result is correct. It does not use app_utils.

    • marvn_58503's avatar
      marvn_58503
      Icon for Nimbostratus rankNimbostratus
      Just coming back to this - I can confirm that it seems app_utils will not correctly handle multiple \r\n characters and you have to create it manually using ltm_create. I'm finding so many limitations in app_utils I'm wondering why bother using it at all. Marking as answer.
    • Fred_Slater_856's avatar
      Fred_Slater_856
      Historic F5 Account
      We agree, and we deprecated app_utils in 11.4. It's still there for backward compatibility, but the F5 iApps all use the new iapp:: tcl package instead. It is documented here https://clouddocs.f5.com/api/iapps/iApp-Utility-Package.html, and you can find examples by looking at f5.http in 11.4.