trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject svn commit: r1059969 [6/6] - in /trafficserver/traffic/trunk: ./ ci/ proxy/config/ proxy/mgmt/ proxy/mgmt/api/ proxy/mgmt/api/include/ proxy/mgmt/api/remote/ proxy/mgmt/cli/ proxy/mgmt/cli2/ proxy/mgmt/cluster/ proxy/mgmt/html2/ proxy/mgmt/html2/charti...
Date Mon, 17 Jan 2011 16:11:34 GMT
Copied: trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h (from r1059438, trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h)
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h?p2=trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h&p1=trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h&r1=1059438&r2=1059969&rev=1059969&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpRender.h Mon Jan 17 16:11:27 2011
@@ -32,6 +32,7 @@
 #define _WEB_HTTP_RENDER_H_
 
 #include "TextBuffer.h"
+#include "WebHttpContext.h"
 
 #include "P_RecCore.h"
 
@@ -383,7 +384,15 @@
 #define HTML_WRAP_OFF                   "off"
 
 #define HTML_ALARM_FILE                 "/monitor/m_alarm.ink"
+#define HTML_MGMT_GENERAL_FILE          "/configure/c_mgmt_general.ink"
+#define HTML_MGMT_LOGIN_FILE            "/configure/c_mgmt_login.ink"
+#define HTML_INSPECTOR_DISPLAY_FILE     "/configure/c_inspector_display.ink"
+#define HTML_CONFIG_DISPLAY_FILE        "/configure/c_config_display.ink"
+#define HTML_TREE_HEADER_FILE           "/include/tree_header.ink"
+#define HTML_TREE_FOOTER_FILE           "/include/tree_footer.ink"
 #define HTML_DEFAULT_MONITOR_FILE       "/monitor/m_overview.ink"
+#define HTML_DEFAULT_CONFIGURE_FILE     "/configure/c_basic.ink"
+#define HTML_FEATURE_ON_OFF_FILE        "/configure/c_basic.ink"
 #define HTML_DEFAULT_HELP_FILE          "/help/ts.ink"
 
 #define HTML_CHART_FILE                 "/charting/chart.cgi"
@@ -392,16 +401,36 @@
 //#define HTML_SUBMIT_SNAPSHOT_FILE       "/submit_snapshot.cgi"
 #define HTML_SUBMIT_SNAPSHOT_FILESYSTEM "/submit_snapshot_filesystem.cgi"
 #define HTML_SUBMIT_INSPECTOR_FILE      "/submit_inspector.cgi"
+#define HTML_SUBMIT_INSPECTOR_DPY_FILE  "/configure/submit_inspector_display.cgi"
 #define HTML_SUBMIT_VIEW_LOGS_FILE      "/log.cgi"
+#define HTML_VIEW_DEBUG_LOGS_FILE       "/configure/c_view_debug_logs.ink"
 #define HTML_SUBMIT_UPDATE_FILE         "/submit_update.cgi"
 #define HTML_SUBMIT_UPDATE_CONFIG       "/submit_update_config.cgi"
+#define HTML_SUBMIT_CONFIG_DISPLAY      "/configure/submit_config_display.cgi"
 #define HTML_SUBMIT_NET_CONFIG          "/submit_net_config.cgi"
 #define HTML_SUBMIT_OTW_UPGRADE_FILE    "/submit_otw_upgrade.cgi"
 #define HTML_BACKDOOR_STATS             "/monitor/m_records.cgi"
+#define HTML_BACKDOOR_CONFIGS           "/configure/c_records.cgi"
 #define HTML_BACKDOOR_STATS_REC         "/monitor/m_records_rec.cgi"
+#define HTML_BACKDOOR_CONFIGS_REC       "/configure/c_records_rec.cgi"
+#define HTML_BACKDOOR_CONFIG_FILES      "/configure/f_configs.cgi"
+#define HTML_BACKDOOR_DEBUG_LOGS        "/configure/d_logs.cgi"
 #define HTML_SYNTHETIC_FILE             "/synthetic.txt"
 
 #define HTML_CONFIG_FILE_TAG            "filename"
+#define HTML_FILE_ALL_CONFIG            "/configure/f_configs.ink"
+#define HTML_FILE_CACHE_CONFIG          "/configure/f_cache_config.ink"
+#define HTML_FILE_HOSTING_CONFIG        "/configure/f_hosting_config.ink"
+#define HTML_FILE_ICP_CONFIG            "/configure/f_icp_config.ink"
+#define HTML_FILE_IP_ALLOW_CONFIG       "/configure/f_ip_allow_config.ink"
+#define HTML_FILE_MGMT_ALLOW_CONFIG     "/configure/f_mgmt_allow_config.ink"
+#define HTML_FILE_PARENT_CONFIG         "/configure/f_parent_config.ink"
+#define HTML_FILE_PARTITION_CONFIG      "/configure/f_partition_config.ink"
+#define HTML_FILE_REMAP_CONFIG          "/configure/f_remap_config.ink"
+#define HTML_FILE_SOCKS_CONFIG          "/configure/f_socks_config.ink"
+#define HTML_FILE_SPLIT_DNS_CONFIG      "/configure/f_split_dns_config.ink"
+#define HTML_FILE_UPDATE_CONFIG         "/configure/f_update_config.ink"
+#define HTML_FILE_VADDRS_CONFIG         "/configure/f_vaddrs_config.ink"
 
 #define HTML_HELP_LINK_CACHE            "/help/ts.ink?help=ccache.htm"
 #define HTML_HELP_LINK_HOSTING          "/help/ts.ink?help=c_host.htm"
@@ -426,6 +455,8 @@
 //-------------------------------------------------------------------------
 
 void WebHttpRenderInit();
+int WebHttpRender(WebHttpContext * whc, const char *file);
+int WebHttpRender(WebHttpContext * whc, char *file_buf, int file_size);
 
 //-------------------------------------------------------------------------
 // html rendering
@@ -459,10 +490,12 @@ int HtmlRndrUlClose(textBuffer * html);
 
 int HtmlRndrInput(textBuffer * html, const HtmlCss css, const HtmlType type, const char *name,
const char *value, const char *target, const char *onclick);
 
+int HtmlRndrInput(textBuffer * html, MgmtHashTable * dict_ht, HtmlCss css, HtmlType type,
char *name, HtmlId value_id);
 int HtmlRndrBr(textBuffer * html);
 int HtmlRndrLi(textBuffer * html);
 
 int HtmlRndrSpace(textBuffer * html, int num_spaces);
+int HtmlRndrText(textBuffer * html, MgmtHashTable * dict_ht, const HtmlId text_id);
 
 int HtmlRndrImg(textBuffer * html, const char *src, const char *border, const char *width,
const char *height, const char *hspace);
 int HtmlRndrDotClear(textBuffer * html, int width, int height);

Copied: trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc (from r1059438, trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc)
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc?p2=trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc&p1=trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc&r1=1059438&r2=1059969&rev=1059969&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.cc Mon Jan 17 16:11:27 2011
@@ -45,6 +45,8 @@
 // defines
 //-------------------------------------------------------------------------
 
+#define WHT_XML_FILE         "navigation_tree.xml"
+
 #define WHT_MAX_MODES        5
 #define WHT_MAX_MENUS        10
 #define WHT_MAX_ITEMS        32
@@ -457,6 +459,52 @@ build_and_index_tree(InkHashTable * mode
 }
 
 //-------------------------------------------------------------------------
+// WebHttpTreeInit
+//-------------------------------------------------------------------------
+
+int
+WebHttpTreeInit()
+{
+  char *xml_file_path;
+  char *xml_file_buf = NULL;
+  int xml_file_len;
+
+  // allocate objects
+  g_mode_ht = ink_hash_table_create(InkHashTableKeyType_String);
+  g_menu_ht = ink_hash_table_create(InkHashTableKeyType_String);
+  g_item_ht = ink_hash_table_create(InkHashTableKeyType_String);
+  g_link_ht = ink_hash_table_create(InkHashTableKeyType_String);
+
+  XML_Parser parser = XML_ParserCreate(NULL);
+  XML_SetUserData(parser, NULL);
+  XML_SetElementHandler(parser, start_element_handler, end_element_handler);
+
+  size_t len = adminContext.docRootLen + strlen(DIR_SEP) + strlen(WHT_XML_FILE) + 1;
+  xml_file_path = (char *) xmalloc(len);
+  snprintf(xml_file_path, len, "%s%s%s", adminContext.docRoot, DIR_SEP, WHT_XML_FILE);
+  if (WebFileImport_Xmalloc(xml_file_path, &xml_file_buf, &xml_file_len) != WEB_HTTP_ERR_OKAY)
{
+    /* 3Com doesn't want to see this message */
+    mgmt_elog(stderr, "[WebHttpTreeInit]: unable to import file %s\n", xml_file_path);
+    goto Lerror;
+  }
+  if (XML_Parse(parser, xml_file_buf, xml_file_len, true) == 0) {
+    mgmt_elog(stderr, "[WebHttpTreeInit]: XML parse error - %s at line %d for %s\n",
+              XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser),xml_file_path);
+    goto Lerror;
+  }
+  // build javascript tree and track 'item's in our g_link_ht
+  //build_and_index_tree(g_mode_ht, g_menu_ht, g_item_ht, g_link_ht, g_reverse_ht);
+  build_and_index_tree(g_mode_ht, g_menu_ht, g_item_ht, g_link_ht);
+  xfree(xml_file_path);
+  xfree(xml_file_buf);
+  XML_ParserFree(parser);
+  return WEB_HTTP_ERR_OKAY;
+Lerror:
+  xfree(xml_file_path);
+  return WEB_HTTP_ERR_FAIL;
+}
+
+//-------------------------------------------------------------------------
 // WebHttpRenderJsTree
 //-------------------------------------------------------------------------
 
@@ -474,6 +522,100 @@ WebHttpRenderJsTree(textBuffer * output,
   return WEB_HTTP_ERR_OKAY;
 }
 
+//-------------------------------------------------------------------------
+// WebHttpRenderTabs
+//-------------------------------------------------------------------------
+
+int
+WebHttpRenderTabs(textBuffer * output, int active_mode)
+{
+  // render the stuff in c_tab.ink / m_tab.ink
+  int err = WEB_HTTP_ERR_OKAY;
+  char buf[WHT_MAX_BUF_LEN + 1];
+  char *default_link = NULL;
+  mode_node *a_mode = &g_modes[active_mode];
+  mode_node *mode = &g_modes[0];
+  int mode_index = 0;
+
+  if (active_mode == 0) {
+    HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    HtmlRndrImg(output, "/images/menu_begin_on.gif", NULL, NULL, NULL, NULL);
+    HtmlRndrTdClose(output);
+  } else {
+    HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    HtmlRndrImg(output, "/images/menu_begin_off.gif", NULL, NULL, NULL, NULL);
+    HtmlRndrTdClose(output);
+  }
+
+  while (mode->node.name) {
+
+    //HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_BOTTOM, "116", NULL,
0);
+
+    if (mode == a_mode) {       // active mode
+
+      HtmlRndrTdOpen(output, HTML_CSS_BLACK_ITEM, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL,
NULL, 0,
+                     "/images/menu_bg_on.gif");
+      output->copyFrom(mode->node.name, strlen(mode->node.name));
+
+    } else {                    // non-active mode
+
+      menu_node *menu = &mode->menus[0];
+      item_node *item = &menu->items[0];
+      link_node *link = &item->links[0];
+
+      snprintf(buf, WHT_MAX_BUF_LEN, "%s%s", link->file_name, link->query);
+
+      if (default_link)
+        xfree(default_link);
+      default_link = WebHttpGetLink_Xmalloc(buf);
+      if (strcmp(default_link, g_empty_string) == 0) {
+        err = WEB_HTTP_ERR_FAIL;
+        goto Ldone;
+      }
+
+      HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0,
+                     "/images/menu_bg_off.gif");
+      HtmlRndrAOpen(output, HTML_CSS_NONE, default_link, NULL);
+      output->copyFrom(mode->node.name, strlen(mode->node.name));
+      HtmlRndrAClose(output);
+    }
+    HtmlRndrTdClose(output);
+
+    mode++;
+    // if current mode is not the last mode, put correct separator
+    if (mode->node.name) {
+      HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+      if (mode_index == active_mode) {
+        // if current mode is active, we need on-off separator
+        HtmlRndrImg(output, "/images/menu_separator_on_off.gif", NULL, NULL, NULL, NULL);
+      } else if (mode_index + 1 == active_mode) {
+        // if next mode is active, we need off-on separator
+        HtmlRndrImg(output, "/images/menu_separator_off_on.gif", NULL, NULL, NULL, NULL);
+      } else {
+        // otherwise we need off-off separator
+        HtmlRndrImg(output, "/images/menu_separator_off_off.gif", NULL, NULL, NULL, NULL);
+      }
+      HtmlRndrTdClose(output);
+    }
+    mode_index++;
+  }
+
+  if (mode_index - 1 == active_mode) {
+    HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    HtmlRndrImg(output, "/images/menu_end_on.gif", NULL, NULL, NULL, NULL);
+    HtmlRndrTdClose(output);
+  } else {
+    HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    HtmlRndrImg(output, "/images/menu_end_off.gif", NULL, NULL, NULL, NULL);
+    HtmlRndrTdClose(output);
+  }
+
+
+Ldone:
+  if (default_link)
+    xfree(default_link);
+  return err;
+}
 
 //-------------------------------------------------------------------------
 // WebHttpRenderHtmlTabs

Copied: trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h (from r1059438, trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h)
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h?p2=trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h&p1=trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h&r1=1059438&r2=1059969&rev=1059969&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt/web2/WebHttpTree.h Mon Jan 17 16:11:27 2011
@@ -32,8 +32,12 @@
 #ifndef _WEB_HTTP_TREE_H_
 #define _WEB_HTTP_TREE_H_
 
+#include "WebHttpContext.h"
+
+int WebHttpTreeInit();
 
 int WebHttpRenderJsTree(textBuffer * output, char *file_link);
+int WebHttpRenderTabs(textBuffer * output, int active_mode);
 int WebHttpRenderHtmlTabs(textBuffer * output, char *file_link, int active_tab);
 bool WebHttpTreeReturnRefresh(char *file_link);
 char *WebHttpTreeReturnHelpLink(char *file_link);

Modified: trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.cc?rev=1059969&r1=1059968&r2=1059969&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.cc Mon Jan 17 16:11:27 2011
@@ -33,6 +33,8 @@
 
 #include "WebOverview.h"
 #include "WebGlobals.h"
+#include "WebHttpRender.h"
+#include "WebHttpTree.h"
 #include "WebMgmtUtils.h"
 
 #include "Main.h"
@@ -737,6 +739,86 @@ overviewPage::addAlarm(alarm_t type, cha
   ink_mutex_release(&accessLock);
 }
 
+// void overviewPage::generateAlarmsTable(textBuffer* output)
+//
+//  places an HTML table containing
+//
+//    resolve   hostname  alarm_description into output
+//
+void
+overviewPage::generateAlarmsTable(WebHttpContext * whc)
+{
+
+  overviewRecord *current;
+  AlarmListable *curAlarm;
+  char numBuf[256];
+  char name[32];
+  //  char *alarm_query;
+  int alarm_count;
+
+  textBuffer *output = whc->response_bdy;
+
+  ink_mutex_acquire(&accessLock);
+
+  // Iterate through each host
+  alarm_count = 0;
+  for (int i = 0; i < numHosts; i++) {
+    current = (overviewRecord *) sortRecords[i];
+
+    // Iterate through the list of alarms
+    curAlarm = current->nodeAlarms.head;
+
+    while (curAlarm != NULL) {
+      HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+
+      // Hostname is an entry
+      HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_TOP, NULL,
NULL, 0);
+      output->copyFrom(current->hostname, strlen(current->hostname));
+      HtmlRndrTdClose(output);
+
+      // Alarm description is an entry
+      HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_TOP, NULL,
NULL, 0);
+      if (curAlarm->desc != NULL) {
+        output->copyFrom(curAlarm->desc, strlen(curAlarm->desc));
+      } else {
+        const char *alarmText = lmgmt->alarm_keeper->getAlarmText(curAlarm->type);
+        output->copyFrom(alarmText, strlen(alarmText));
+      }
+      HtmlRndrTdClose(output);
+
+      // the name of each checkbox is : "alarm:<alarm_count>"
+      // the value of each checkbox is: "<alarmId>:<ip addr>"
+      HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_CENTER, HTML_VALIGN_NONE, NULL,
NULL, 0);
+      if (curAlarm->ip == NULL)
+        snprintf(numBuf, sizeof(numBuf), "%d:local", curAlarm->type);
+      else
+        snprintf(numBuf, sizeof(numBuf), "%d:%s", curAlarm->type, curAlarm->ip);
+      snprintf(name, sizeof(name), "alarm:%d", alarm_count);
+      HtmlRndrInput(output, HTML_CSS_NONE, HTML_TYPE_CHECKBOX, name, numBuf, NULL, NULL);
+      HtmlRndrTdClose(output);
+
+      HtmlRndrTrClose(output);
+      curAlarm = curAlarm->link.next;
+
+      alarm_count++;
+
+    }
+  }
+
+  ink_mutex_release(&accessLock);
+
+  // check if we didn't find any alarms
+  if (alarm_count == 0) {
+    HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
3);
+    HtmlRndrSpace(output, 2);
+    HtmlRndrText(output, whc->lang_dict_ht, HTML_ID_NO_ACTIVE_ALARMS);
+    HtmlRndrTdClose(output);
+    HtmlRndrTrClose(output);
+  }
+
+}
+
 void
 overviewPage::generateAlarmsTableCLI(textBuffer * output)
 {
@@ -820,6 +902,225 @@ overviewPage::generateAlarmsTableCLI(tex
 }                               // end generateAlarmsTableCLI()
 
 #if TS_HAS_WEBUI
+// void overviewPage::generateAlarmsSummary(textBuffer* output)
+//
+//  alarm summary information (Alarm! [X pending])
+//
+void
+overviewPage::generateAlarmsSummary(WebHttpContext * whc)
+{
+
+  overviewRecord *current;
+  AlarmListable *curAlarm;
+  char buf[256];
+  int alarm_count;
+  char *alarm_link;
+
+  textBuffer *output = whc->response_bdy;
+
+  ink_mutex_acquire(&accessLock);
+
+  // Iterate through each host
+  alarm_count = 0;
+  for (int i = 0; i < numHosts; i++) {
+    current = (overviewRecord *) sortRecords[i];
+    // Iterate through the list of alarms
+    curAlarm = current->nodeAlarms.head;
+    while (curAlarm != NULL) {
+      alarm_count++;
+      curAlarm = curAlarm->link.next;
+    }
+  }
+
+  ink_mutex_release(&accessLock);
+
+  if (alarm_count > 0) {
+    HtmlRndrTableOpen(output, "100%", 0, 0, 0);
+
+    HtmlRndrTrOpen(output, HTML_CSS_ALARM_COLOR, HTML_ALIGN_NONE);
+    HtmlRndrTdOpen(output, HTML_CSS_GREY_LINKS, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL,
"30", 0);
+    alarm_link = WebHttpGetLink_Xmalloc(HTML_ALARM_FILE);
+    HtmlRndrAOpen(output, HTML_CSS_NONE, alarm_link, NULL);
+    xfree(alarm_link);
+    HtmlRndrSpace(output, 2);
+    HtmlRndrText(output, whc->lang_dict_ht, HTML_ID_ALARM);
+    snprintf(buf, sizeof(buf), "! [%d ", alarm_count);
+    output->copyFrom(buf, strlen(buf));
+    HtmlRndrText(output, whc->lang_dict_ht, HTML_ID_PENDING);
+    snprintf(buf, sizeof(buf), "]");
+    output->copyFrom(buf, strlen(buf));
+    HtmlRndrAClose(output);
+    HtmlRndrTdClose(output);
+    HtmlRndrTrClose(output);
+
+    HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE);
+    HtmlRndrTdOpen(output, HTML_CSS_TERTIARY_COLOR, HTML_ALIGN_NONE, HTML_VALIGN_NONE, "1",
"1", 0);
+    HtmlRndrDotClear(output, 1, 1);
+    HtmlRndrTdClose(output);
+
+    HtmlRndrTrClose(output);
+
+    HtmlRndrTableClose(output);
+
+  }
+}
+
+// generates the table for the overview page
+//
+//  the entries are   hostname, on/off, alarm
+//
+void
+overviewPage::generateTable(WebHttpContext * whc)
+{
+
+  // Varariables for finding out information about a specific node
+  overviewRecord *current;
+  char *hostName;
+  bool alarm;
+  bool up;
+  bool found;
+  PowerLampState proxyUp;
+  bool sslEnabled = false;
+  const char refFormat[] = "%s://%s:%d%s";
+  char refBuf[256];             // Buffer for link to other nodes
+  char *domainStart;            // pointer to domain name part of hostna,e
+  int hostLen;                  // length of the host only portion of the hostname
+  char outBuf[16 + 1];
+  MgmtInt objs, t_hit, t_miss;
+  MgmtFloat ops, hits, mbps;
+  //  char *alarm_link;
+
+  textBuffer *output = whc->response_bdy;
+  MgmtHashTable *dict_ht = whc->lang_dict_ht;
+
+  // Check to see if SSL is enabled.  Do one check, and record
+  //  the info since it can change from under us in the pContext
+  //  structure and we at least want to be able to give a
+  //  consistent view
+  if (whc->server_state & WEB_HTTP_SERVER_STATE_SSL_ENABLED) {
+    sslEnabled = true;
+  }
+
+  ink_mutex_acquire(&accessLock);
+  for (int i = 0; i < numHosts; i++) {
+    current = (overviewRecord *) sortRecords[i];
+    current->getStatus(&hostName, &up, &alarm, &proxyUp);
+
+    // no longer need 'if (alarm)' since we have the alarm bar now
+    //if (alarm)
+    //HtmlRndrTrOpen(output, HTML_CSS_ALARM_COLOR, HTML_ALIGN_CENTER);
+    //else
+    HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_CENTER);
+
+    // Make the hostname non-qualified if we have a host name and not
+    // an ip address
+    if (isdigit(*hostName))
+      domainStart = NULL;
+    else
+      domainStart = strchr(hostName, '.');
+
+    if (domainStart == NULL)
+      hostLen = strlen(hostName);
+    else
+      hostLen = domainStart - hostName;
+
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    // INKqa01119  - remove the up check since we are currently
+    // not sending heartbeat packets when the proxy is off
+    // if (up == true && current->localNode == false) {
+    if (current->localNode == false) {
+      char *link = WebHttpGetLink_Xmalloc(HTML_DEFAULT_MONITOR_FILE);
+      if (sslEnabled == false) {
+        // coverity[non_const_printf_format_string]
+        snprintf(refBuf, sizeof(refBuf), refFormat, "http", hostName, wGlobals.webPort, link);
+      } else {
+        // coverity[non_const_printf_format_string]
+        snprintf(refBuf, sizeof(refBuf), refFormat, "https", hostName, wGlobals.webPort,
link);
+      }
+      HtmlRndrAOpen(output, HTML_CSS_GRAPH, refBuf, NULL);
+      output->copyFrom(hostName, hostLen);
+      HtmlRndrAClose(output);
+      xfree(link);
+    } else {
+      output->copyFrom(hostName, hostLen);
+    }
+    HtmlRndrTdClose(output);
+
+    // Add On/Off light
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    switch (proxyUp) {
+    case LAMP_ON:
+      HtmlRndrText(output, dict_ht, HTML_ID_ON);
+      break;
+    case LAMP_OFF:
+      HtmlRndrText(output, dict_ht, HTML_ID_OFF);
+      break;
+    case LAMP_WARNING:
+      HtmlRndrText(output, dict_ht, HTML_ID_WARNING);
+      break;
+    }
+    HtmlRndrTdClose(output);
+
+    // objects served
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    current->varIntFromName("proxy.node.user_agents_total_documents_served", &objs);
+    snprintf(outBuf, sizeof(outBuf), "%.10lld", objs);
+    output->copyFrom(outBuf, strlen(outBuf));
+    HtmlRndrTdClose(output);
+
+    // ops/sec
+    if (up == true) {
+      ops = current->readFloat("proxy.node.user_agent_xacts_per_second", &found);
+    } else {
+      // Always report zero for down nodes
+      ops = 0;
+      found = true;
+    }
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    snprintf(outBuf, 16, "%.2f", ops);
+    output->copyFrom(outBuf, strlen(outBuf));
+    HtmlRndrTdClose(output);
+
+    // hit rate
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    current->varFloatFromName("proxy.node.cache_hit_ratio_avg_10s", &hits);
+    snprintf(outBuf, sizeof(outBuf), "%.2f%% ", hits * 100.0);
+    output->copyFrom(outBuf, strlen(outBuf));
+    HtmlRndrTdClose(output);
+
+    // throughput
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    current->varFloatFromName("proxy.node.client_throughput_out", &mbps);
+    snprintf(outBuf, sizeof(outBuf), "%.2f", mbps);
+    output->copyFrom(outBuf, strlen(outBuf));
+    HtmlRndrTdClose(output);
+
+    // hit latency
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    current->varIntFromName("proxy.node.http.transaction_msec_avg_10s.hit_fresh", &t_hit);
+    snprintf(outBuf, sizeof(outBuf), "%" PRId64 "", t_hit);
+    output->copyFrom(outBuf, strlen(outBuf));
+    HtmlRndrTdClose(output);
+
+    // miss latency
+    HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+    current->varIntFromName("proxy.node.http.transaction_msec_avg_10s.miss_cold", &t_miss);
+    snprintf(outBuf, sizeof(outBuf), "%" PRId64 "", t_miss);
+    output->copyFrom(outBuf, strlen(outBuf));
+    HtmlRndrTdClose(output);
+
+    // row close
+    HtmlRndrTrClose(output);
+
+    // show the 'details' section on the dashboard
+    if (whc->request_state & WEB_HTTP_STATE_MORE_DETAIL) {
+      this->addHostPanel(whc, current);
+    }
+
+  }
+
+  ink_mutex_release(&accessLock);
+}
 
 //
 // generates the table for the dashboard page for CLI
@@ -933,6 +1234,189 @@ overviewPage::generateTableCLI(textBuffe
   ink_mutex_release(&accessLock);
 }                               // end generateTableCLI()
 
+// overviewPage::addHostPanel
+//
+//  Inserts stats entries for the host referenced by parameter host
+//  Called by overviewPage::generateTable
+//
+void
+overviewPage::addHostPanel(WebHttpContext * whc, overviewRecord * host)
+{
+
+  const char errorStr[] = "loading...";
+  char tmp[256];
+  in_addr ip;
+  char *ip_str;
+
+  textBuffer *output = whc->response_bdy;
+  MgmtHashTable *dict_ht = whc->lang_dict_ht;
+
+  //-----------------------------------------------------------------------
+  // SET 1: CACHE TRANSACTION SUMMARY
+  //-----------------------------------------------------------------------
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_NONE, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL, 8);
+
+  MgmtFloat hits, hit_f, hit_r;
+  MgmtFloat errs, abts, f;
+
+  // get aborts
+  abts = 0;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.errors.pre_accept_hangups",
&f))
+    abts += f;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.errors.empty_hangups",
&f))
+    abts += f;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.errors.early_hangups",
&f))
+    abts += f;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.errors.aborts",
&f))
+    abts += f;
+
+  // get errors
+  errs = 0;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.errors.connect_failed",
&f))
+    errs += f;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.errors.other",
&f))
+    errs += f;
+
+  // get hits
+  hits = hit_f = hit_r = 0;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.hit_fresh", &hit_f))
+    hits += hit_f;
+  if (host->varFloatFromName("proxy.node.http.transaction_frac_avg_10s.hit_revalidated",
&hit_r))
+    hits += hit_r;
+#ifndef OLD_WAY
+  host->varFloatFromName("proxy.node.cache_hit_ratio_avg_10s", &hits);
+#endif /* !OLD_WAY */
+
+#define SEPARATOR output->copyFrom("&nbsp;-&nbsp;", 13)
+
+  HtmlRndrTableOpen(output, NULL, 0, 0, 0);
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_CACHE_HIT_RATE);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  snprintf(tmp, sizeof(tmp), "%.1f%% (%.1f%% ", hits * 100.0, hit_f * 100.0);
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrText(output, dict_ht, HTML_ID_FRESH);
+  snprintf(tmp, sizeof(tmp), ", %.1f%% ", hit_r * 100.0);
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrText(output, dict_ht, HTML_ID_REFRESH);
+  output->copyFrom(")", 1);
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_ERRORS);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  snprintf(tmp, sizeof(tmp), "%.1f%%", errs * 100.0);
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_ABORTS);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  snprintf(tmp, sizeof(tmp), "%.1f%%", abts * 100.0);
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  //-----------------------------------------------------------------------
+  // SET 2: ACTIVE CONNECTIONS
+  //-----------------------------------------------------------------------
+
+  MgmtInt clients, servers;
+
+  clients = servers = 0;
+
+  host->varIntFromName("proxy.node.current_client_connections", &clients);
+  host->varIntFromName("proxy.node.current_server_connections", &servers);
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_ACTIVE_CLIENTS);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  snprintf(tmp, sizeof(tmp), "%" PRId64 "", clients);
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_ACTIVE_SERVERS);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  snprintf(tmp, sizeof(tmp), "%" PRId64 "", servers);
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  //-----------------------------------------------------------------------
+  // SET 3: CLUSTER ADDRESS
+  //-----------------------------------------------------------------------
+
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_NODE_IP_ADDRESS);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  ip.s_addr = host->inetAddr;
+  ip_str = inet_ntoa(ip);
+  output->copyFrom(ip_str, strlen(ip_str));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  //-----------------------------------------------------------------------
+  // SET 4: TS Lite
+  //-----------------------------------------------------------------------
+
+  if (host->varStrFromName("proxy.node.cache.bytes_free\\b", tmp, 256) == false) {
+    ink_strncpy(tmp, errorStr, sizeof(tmp));
+  }
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_CACHE_FREE_SPACE);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  if (host->varStrFromName("proxy.node.hostdb.hit_ratio_avg_10s\\p", tmp, 256) == false)
{
+    ink_strncpy(tmp, errorStr, sizeof(tmp));
+  }
+  HtmlRndrTrOpen(output, HTML_CSS_NONE, HTML_ALIGN_LEFT);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  HtmlRndrText(output, dict_ht, HTML_ID_HOSTDB_HIT_RATE);
+  HtmlRndrTdClose(output);
+  HtmlRndrTdOpen(output, HTML_CSS_BODY_TEXT, HTML_ALIGN_NONE, HTML_VALIGN_NONE, NULL, NULL,
0);
+  SEPARATOR;
+  output->copyFrom(tmp, strlen(tmp));
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+  HtmlRndrTableClose(output);
+
+  HtmlRndrTdClose(output);
+  HtmlRndrTrClose(output);
+
+#undef SEPARATOR
+}
 #endif
 
 // int overviewPage::getClusterHosts(Expanding Array* hosts)

Modified: trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.h?rev=1059969&r1=1059968&r2=1059969&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt/web2/WebOverview.h Mon Jan 17 16:11:27 2011
@@ -24,13 +24,14 @@
 #ifndef _WEB_OVERVIEW_H_
 #define _WEB_OVERVIEW_H_
 
-#include "WebUtils.h"
 #include "ink_hash_table.h"
 #include "ink_mutex.h"
 #include "WebGlobals.h"
 #include "TextBuffer.h"
 #include "List.h"
 
+#include "WebHttpContext.h"
+#include "WebHttpMessage.h"
 #include "ExpandingArray.h"
 #include "ClusterCom.h"
 #include "Alarms.h"
@@ -125,9 +126,13 @@ public:
   /*
      void generateTable(textBuffer* output,
      const char* submission,
+     WebContext* pContext);
    */
+  void generateTable(WebHttpContext * whc);
   void generateTableCLI(textBuffer * output);
+  void generateAlarmsTable(WebHttpContext * whc);
   void generateAlarmsTableCLI(textBuffer * output);
+  void generateAlarmsSummary(WebHttpContext * whc);
   void addAlarm(alarm_t newAlarm, char *ip, char *desc);
   void checkForUpdates();
   char *resolvePeerHostname(const char *peerIP);
@@ -154,6 +159,7 @@ private:
   void addLoadBar(textBuffer * output, MgmtInt load);
   void sortHosts();
   bool moreInfoButton(const char *submission, textBuffer * output);
+  void addHostPanel(WebHttpContext * whc, overviewRecord * host);
 
   // Private variables
   InkHashTable *nodeRecords;    // container for overviewRecords

Modified: trafficserver/traffic/trunk/proxy/mgmt/web2/WebUtils.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt/web2/WebUtils.h?rev=1059969&r1=1059968&r2=1059969&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt/web2/WebUtils.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt/web2/WebUtils.h Mon Jan 17 16:11:27 2011
@@ -35,6 +35,8 @@
 #include "ink_platform.h"
 #include "MgmtDefs.h"
 
+struct WebContext;
+
 /* Ugly Hack - declare
  *  SSLcon as void* instead of SSL since this prevents  us from
  *  including ssl.h right here which creates a whole bunch of



Mime
View raw message