#include "gb-include.h" #include "Stats.h" #include "Pages.h" // . returns false if blocked, true otherwise // . sets errno on error // . make a web page displaying the config of this host // . call g_httpServer.sendDynamicPage() to send it bool sendPagePerf ( TcpSocket *s , HttpRequest *r ) { // if ip is not from matt wells, don't print this stuff, too sensitive //long matt1 = atoip ( MATTIP1 , gbstrlen(MATTIP1) ); //long matt2 = atoip ( MATTIP2 , gbstrlen(MATTIP2) ); // allow connection if i'm running this on lenny, too //if ( s->m_ip != matt1 && s->m_ip != matt2 ) // return g_httpServer.sendErrorReply(s,500,mstrerror(g_errno)); long refreshLen = 0; if(r->getString ( "refresh" , &refreshLen) ) { g_stats.dumpGIF (); return g_httpServer.sendDynamicPage ( s , "x", 1 ); } // don't allow pages bigger than 128k in cache char buf [ 64*1024 ]; SafeBuf p(buf, 64*1024); // print standard header g_pages.printAdminTop ( &p , s , r ); // password, too //long pwdLen = 0; //char *pwd = r->getString ( "pwd" , &pwdLen ); long autoRefresh = r->getLong("rr", 0); if(autoRefresh > 0) { p.safePrintf(""); } // dump stats to /tmp/diskGraph.gif g_stats.dumpGIF (); if(autoRefresh > 0) p.safePrintf(""); //get the 'path' part of the request. char rbuf[1024]; if(r->getRequestLen() > 1023) memcpy( rbuf, r->getRequest(), 1023); else memcpy( rbuf, r->getRequest(), r->getRequestLen()); char* rbufEnd = rbuf; //skip GET while (!isspace(*rbufEnd)) rbufEnd++; //skip space(s) while (isspace(*rbufEnd)) rbufEnd++; //skip request path while (!isspace(*rbufEnd)) rbufEnd++; *rbufEnd = '\0'; char* refresh = strstr(rbuf, "&rr="); // print resource table // columns are the dbs p.safePrintf( //"
Disk Statistics

" "

" "

", g_hostdb.m_hostId ); if(autoRefresh > 0) { if(refresh) *(refresh+4) = '0'; p.safePrintf( "
Auto Refresh Off" "
", rbuf + 4/*skip over GET*/); p.safePrintf( ""); } else { char* rr = ""; if(refresh) *(refresh+4) = '1'; else rr = "&rr=1"; p.safePrintf( "
Auto Refresh" "
", rbuf + 4/*skip over GET*/, rr); } // print the key p.safePrintf ( "
" "" "%s
" "" // black "" "" "" // grey "" "" "" // red "" "" "" // light brown "" "" "" // dark brown "" "" "" // blue "" "" "" // pinkish purple "" "" "" // yellow "" "" "" // pinkish purple "" "" "" // light yellow "" "" "" // dark purple "" "" "" // turquoise "" "" "" // white "" "" "" // orange "" "" "" // bright green "" "" "" // dark green "" "" "" // bright green "" "" "" // dark green "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
    High priority disk read. " "Thicker lines for bigger reads.    Low priority disk read. " "Thicker lines for bigger reads.
    Disk write. " "Thicker lines for bigger writes.    Processing end user query. No raw= parm.
    Processing raw query. Has raw= parm.    Summary extraction for one document.
    Send data over network. (low priority)" "Thicker lines for bigger sends.    Read all termlists (msg2). (low priority)" "Thicker lines for bigger reads.
    Send data over network. (high priority)" "Thicker lines for bigger sends.    Read all termlists (msg2). (high priority)" "Thicker lines for bigger reads.
    Get all summaries for results.    Merge multiple disk reads. Real-time searching. " "Thicker lines for bigger merges.
    Uncompress cached document.    Parse a document. Blocks CPU.
    Compute search results. " "All terms required. rat=1.    Compute search results. " "Not all terms required. rat=0.
    Compute reference pages. " "    Compute related pages. " "
    Compute Gigabits. " "    Quick Poll. " "
    \"Summary\" extraction (low priority) " "      " "
" "
", g_stats.m_keyCols.getBufStart() && g_conf.m_dynamicPerfGraph ? g_stats.m_keyCols.getBufStart() : "" ); if(autoRefresh > 0) p.safePrintf(""); // print the final tail //p += g_httpServer.printTail ( p , pend - p ); long bufLen = p.length(); // . send this page // . encapsulates in html header and tail // . make a Mime return g_httpServer.sendDynamicPage ( s, p.getBufStart(), bufLen ); }