#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( //"" " | High priority disk read. " "Thicker lines for bigger reads. | " // grey "" " | Low priority disk read. " "Thicker lines for bigger reads. | " "
" " | Disk write. " "Thicker lines for bigger writes. | " // light brown "" " | Processing end user query. No raw= parm. | " "
" " | Processing raw query. Has raw= parm. | " // blue "" " | Summary extraction for one document. | " "
" " | Send data over network. (low priority)" "Thicker lines for bigger sends. | " // yellow "" " | Read all termlists (msg2). (low priority)" "Thicker lines for bigger reads. | " "
" " | Send data over network. (high priority)" "Thicker lines for bigger sends. | " // light yellow "" " | Read all termlists (msg2). (high priority)" "Thicker lines for bigger reads. | " "
" " | Get all summaries for results. | " // turquoise "" " | Merge multiple disk reads. Real-time searching. " "Thicker lines for bigger merges. | " "
" " | Uncompress cached document. | " // orange "" " | Parse a document. Blocks CPU. | " "
" " | Compute search results. " "All terms required. rat=1. | " // dark green "" " | Compute search results. " "Not all terms required. rat=0. | " "
" " | Compute reference pages. " " | " // dark green "" " | Compute related pages. " " | " "
" " | Compute Gigabits. " " | " "" " | Quick Poll. " " | " "
" " | \"Summary\" extraction (low priority) " " | " "" " | " " | " "