Forum Discussion

Simon_Wright_85's avatar
Simon_Wright_85
Icon for Nimbostratus rankNimbostratus
Jun 25, 2007

Displaying stats using HTTP::respond

Hi all

I am in the process of looking to display some performance statistics i want to gather in a statistics profile. I am able to gather statistics and can view them when looking at it through the GUI. When i try to use an iRule to display it as suggested in the following thread i just get an error.

http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=5916

Currently my test rule is as follows.


when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/myteststats" } {
    set stats_html "Total Users: $tot_users"
    set html_content "iRule Statistics$stats_html"
    HTTP::respond 200 content $html_content
  }
}

All i seem to get back is an error. If i change $tot_users to generic text it works fine but i cannot seem to get data from the statistics profile. Im probably missing something quite simple but i have not been able to find anything on devcentral that talks about it other than the post linked above.

many thanks in advance.

Simon
  • I realised my error and found the rule should look like this instead.
    when HTTP_REQUEST {
      if { [HTTP::uri] starts_with "/myteststats" } {
        set stats_html "Total Users: [STATS::get MyStatsProfile tot_users]"
        set html_content "iRule Statistics$stats_html"
        HTTP::respond 200 content $html_content
      }
    }

    I also found after a few minutes of headscratching that the name of the stats profile is case sensitive.

    Cheers

    simon