New YPstats possibility.

Users can enter the details of their system configuration and we are able do work-out profiles for special uses and hardware-configurations.
Default DB running on yacy-forum.de, but URL can be changed. 
User can see all data, which will be submitted.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2249 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
rramthun 19 years ago
parent 53cbcc6d6e
commit db2405533a

@ -0,0 +1,249 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>YaCy '#[clientname]#': YPStats</title>
#%env/templates/metas.template%#
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
#%env/templates/header.template%#
<br />
<h2>YPStats - Statistics to generate default settings</h2>
<p>
<form action="#" method="GET">
<label for="0">Select submit url: </label><input type="text" name="url" value="#[url]#" />
<input type="submit" name="urlchg" value="change" />
</form>
</p>
<hr />
<form action="#[url]#" method="post" enctype="multipart/form-data">
<p>
<table>
<tr>
<td><label for="1">Operating system: </label></td>
<td><input type="text" name="OS" value="" id="1" /></td>
</tr>
<tr>
<td><label for="2">RAM in machine: </label></td>
<td><input type="text" name="RAM" value="" id="2" /> MB</td>
</tr>
<tr>
<td><label for="3">CPU speed: </label></td>
<td><input type="text" name="CPUSpeed" value="" id="3" /> MHz</td>
</tr>
<tr>
<td><label for="5">HDD speed: </label></td>
<td><input type="text" name="HDDSpeed" value="" id="5" /> RPM</td>
</tr>
<tr>
<td><label for="6">HDD cache: </label></td>
<td><input type="text" name="HDDCache" value="" id="6" /> KB</td>
</tr>
<tr>
<td><label for="7">HDD interface: </label></td>
<td>
<select name="HDDInterface" id="7">
<option name="P-ATA" selected>P-ATA / IDE</option>
<option name="S-ATA">Serial ATA</option>
<option name="S-ATA2">Serial ATA 2</option>
<option name="SCSI">SCSI</option>
<option name="else">Other</option>
</select>
</td>
</tr>
<tr>
<td><label for="seperate">YaCy runs on "own" HDD</label></td>
<td><input type="checkbox" name="seperateHDD" id="seperate" /></td>
<tr>
<td><label for="8">Peer main usage: </label></td>
<td>
<select name="Usage" id="8">
<option name="Proxy" selected>Proxy</option>
<option name="DHT">DHT-Peer</option>
<option name="Crawler">Crawl-Peer</option>
<option name="else">No special usage</option>
</select>
</td>
</tr>
<tr>
<td><label for="9">Peer runs 24/7 </label></td>
<td><input type="checkbox" name="24-7" id="9" /></td>
</tr>
<tr>
<td><label for="10">System slowdown: </label></td>
<td>
<select name="Slowdown" id="10">
<option name="0" selected>No slowdown noticable</option>
<option name="1">Slight slowdown</option>
<option name="2">Moderate slowdown</option>
<option name="3">Heavy slowdown</option>
<option name="4">Working not possible</option>
</select>
</td>
</tr>
<tr>
<td><label for="11">Comments: </label></td>
<td><textarea name="comment" rows="10" cols="73" id="11"></textarea></td>
</tr>
<tr>
<td colspan="3">
<center><input type="submit" name="submit" value="Submit to YPStats" /></center>
</td>
</tr>
</table>
</p>
<hr />
<h3>Data which will be sent to #[url]#:</h3>
<p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td class="small">Thread</td>
<td class="small">idlesleep</td>
<td class="small">busysleep</td>
<td class="small">memprereq</td>
</tr>
#{table}#<tr class="TableCellDark">
<td class="small">#[threadname]#</td>
<td class="small">#[idlesleep]#<input type="hidden" name="#[threadname]#_idlesleep" value="#[idlesleep]#" /></td>
<td class="small">#[busysleep]#<input type="hidden" name="#[threadname]#_busysleep" value="#[busysleep]#" /></td>
<td class="small">#[memprereq]#<input type="hidden" name="#[threadname]#_memprereq" value="#[memprereq]#" /></td>
</tr>
#{/table}#
</table>
</p>
<p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableCellDark">
<td class="small">wordCacheMaxCount</td>
<td class="small">#[wordCacheMaxCount]#<input type="hidden" name="wordCacheMaxCount" value="#[wordCacheMaxCount]#" /></td>
</tr>
</table>
</p>
<p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td class="small">Thread</td>
<td class="small">maxActive</td>
<td class="small">maxIdle</td>
<td class="small">minIdle</td>
</tr>
#{pool}#<tr class="TableCellDark">
<td class="small">#[name]#</td>
<td class="small">#[maxActive]#<input type="hidden" name="#[name]#_maxActive" value="#[maxActive]#" /></td>
<td class="small">#[maxIdle]#<input type="hidden" name="#[name]#_maxIdle" value="#[maxIdle]#"/></td>
<td class="small">#[minIdle]#<input type="hidden" name="#[name]#_minIdle" value="#[minIdle]#" /></td>
</tr>
#{/pool}#
</table>
</p>
<p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableCellDark">
<td><span title="-Xmx parameter for Java" class="small">Maximum RAM</span></td>
<td class="small">#[Xmx]#<input type="hidden" name="Xmx" value="#[Xmx]#" /></td>
</tr>
<tr class="TableCellDark">
<td><span title="-Xms parameter for Java" class="small">Initial RAM</span></td>
<td class="small">#[Xms]#<input type="hidden" name="Xms" value="#[Xms]#" /></td>
</tr>
</table>
</p>
<p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td class="small">Database</td>
<td class="small">DB-Size</td>
<td class="small">RAM Cache</td>
</tr>
<tr class="TableCellDark">
<td class="small">RWI</td>
<td class="small">#[slreqRWI]#<input type="hidden" name="DBSizeRWI" value="#[slreqRWI]#" /></td>
<td class="small">#[ramCacheRWI]#<input type="hidden" name="ramCacheRWI" value="#[ramCacheRWI]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">HTTP</td>
<td class="small">#[slreqHTTP]#<input type="hidden" name="DBSizeHTTP" value="#[slreqHTTP]#" /></td>
<td class="small">#[ramCacheHTTP]#<input type="hidden" name="ramCacheHTTP" value="#[ramCacheHTTP]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">LURL</td>
<td class="small">#[slreqLURL]#<input type="hidden" name="DBSizeLURL" value="#[slreqLURL]#" /></td>
<td class="small">#[ramCacheLURL]#<input type="hidden" name="ramCacheLURL" value="#[ramCacheLURL]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">NURL</td>
<td class="small">#[slreqNURL]#<input type="hidden" name="DBSizeNURL" value="#[slreqNURL]#" /></td>
<td class="small">#[ramCacheNURL]#<input type="hidden" name="ramCacheNURL" value="#[ramCacheNURL]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">EURL</td>
<td class="small">#[slreqEURL]#<input type="hidden" name="DBSizeEURL" value="#[slreqEURL]#" /></td>
<td class="small">#[ramCacheEURL]#<input type="hidden" name="ramCacheEURL" value="#[ramCacheEURL]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">DHT</td>
<td class="small">#[slreqDHT]#<input type="hidden" name="DBSizeDHT" value="#[slreqDHT]#" /></td>
<td class="small">#[ramCacheDHT]#<input type="hidden" name="ramCacheDHT" value="#[ramCacheDHT]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Message</td>
<td class="small">#[slreqMessage]#<input type="hidden" name="DBSizeMessage" value="#[slreqMessage]#" /></td>
<td class="small">#[ramCacheMessage]#<input type="hidden" name="ramCacheMessage" value="#[ramCacheMessage]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Wiki</td>
<td class="small">#[slreqWiki]#<input type="hidden" name="DBSizeWiki" value="#[slreqWiki]#" /></td>
<td class="small">#[ramCacheWiki]#<input type="hidden" name="ramCacheWiki" value="#[ramCacheWiki]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Blog</td>
<td class="small">#[slreqBlog]#<input type="hidden" name="DBSizeBlog" value="#[slreqBlog]#" /></td>
<td class="small">#[ramCacheBlog]#<input type="hidden" name="ramCacheBlog" value="#[ramCacheBlog]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">News</td>
<td class="small">#[slreqNews]#<input type="hidden" name="DBSizeNews" value="#[slreqNews]#" /></td>
<td class="small">#[ramCacheNews]#<input type="hidden" name="ramCacheNews" value="#[ramCacheNews]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Robots</td>
<td class="small">#[slreqRobots]#<input type="hidden" name="DBSizeRobots" value="#[slreqRobots]#" /></td>
<td class="small">#[ramCacheRobots]#<input type="hidden" name="ramCacheRobots" value="#[ramCacheRobots]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Profiles</td>
<td class="small">#[slreqProfiles]#<input type="hidden" name="DBSizeProfiles" value="#[slreqProfiles]#" /></td>
<td class="small">#[ramCacheProfiles]#<input type="hidden" name="ramCacheProfiles" value="#[ramCacheProfiles]#" /></td>
</tr>
</table>
</p>
<p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableCellDark">
<td class="small">YaCy-Version</td>
<td class="small">#[versionpp]#<input type="hidden" name="version" value="#[versionpp]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small"># Links</td>
<td class="small">#[links]#<input type="hidden" name="links" value="#[links]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small"># RWIs</td>
<td class="small">#[words]#<input type="hidden" name="words" value="#[words]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Peer-Hash</td>
<td class="small">#[hash]#<input type="hidden" name="hash" value="#[hash]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Java-Version</td>
<td class="small">#[jversion]#<input type="hidden" name="jversion" value="#[jversion]#" /></td>
</tr>
<tr class="TableCellDark">
<td class="small">Processors</td>
<td class="small">#[processors]#<input type="hidden" name="CPUCount" value="#[processors]#" /></td>
</tr>
</table>
</p>
</form>
#%env/templates/footer.template%#
</body>

@ -0,0 +1,251 @@
//YPStats_p.java
//-----------------------
//Author: Franz Brauße
//part of YaCy (C) by Michael Peter Christen; mc@anomic.de
//first published on http://www.anomic.de
//Frankfurt, Germany, 2004, 2005
//last major change: 27.06.2006
//
//This program is free software; you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation; either version 2 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//Using this software in any meaning (reading, learning, copying, compiling,
//running) means that you agree that the Author(s) is (are) not responsible
//for cost, loss of data or any harm that may be caused directly or indirectly
//by usage of this softare or this documentation. The usage of this software
//is on your own risk. The installation and usage (starting/running) of this
//software may allow other people or application to access your computer and
//any attached devices and is highly dependent on the configuration of the
//software which must be done by the user of the software; the author(s) is
//(are) also not responsible for proper configuration and usage of the
//software, even if provoked by documentation provided together with
//the software.
//
//Any changes to this file according to the GPL as documented in the file
//gpl.txt aside this file in the shipment you received can be done to the
//lines that follows this copyright notice here, but changes must not be
//done inside the copyright notive above. A re-distribution must contain
//the intact and unchanged copyright notice.
//Contributions and changes to the program code must be marked as such.
//You must compile this file with
//javac -classpath .:../classes YPStats_p.java
//if the shell's current path is HTROOT
import java.util.Iterator;
import java.util.Map;
import java.io.File;
import org.apache.commons.pool.impl.GenericObjectPool;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.serverThread;
import de.anomic.server.serverFileUtils;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;
public class YPStats_p {
private static final int KB = 1024;
private static final int MB = 1024 * KB;
private static Map defaultSettings = null;
private static long[] slt,chk;
private static String[] ost;
private static long req, usd, bst, god;
private static long usedTotal, currTotal, dfltTotal, goodTotal, bestTotal;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch sb) {
// return variable that accumulates replacements
plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
serverObjects prop = new serverObjects();
File defaultSettingsFile = new File(switchboard.getRootPath(), "yacy.init");
Map defaultSettings = ((post == null) || (!(post.containsKey("submitdefault")))) ? null : serverFileUtils.loadHashMap(defaultSettingsFile);
String url=null;
if(post!=null && post.containsKey("url")) {
url=(String)post.get("url");
} else {
url="http://ypstats.yacy-forum.de/index.php";
}
prop.put("url", url);
Iterator threads = switchboard.threadNames();
String threadName;
serverThread thread;
// calculate totals
long blocktime_total = 0, sleeptime_total = 0, exectime_total = 0;
while (threads.hasNext()) {
threadName = (String) threads.next();
thread = switchboard.getThread(threadName);
blocktime_total += thread.getBlockTime();
sleeptime_total += thread.getSleepTime();
exectime_total += thread.getExecTime();
}
if (blocktime_total == 0) blocktime_total = 1;
if (sleeptime_total == 0) sleeptime_total = 1;
if (exectime_total == 0) exectime_total = 1;
// set templates for latest news from the threads
long blocktime, sleeptime, exectime;
long idlesleep, busysleep, memuse, memprereq;
int queuesize;
threads = switchboard.threadNames();
int c = 0;
long idleCycles, busyCycles, memshortageCycles;
while (threads.hasNext()) {
threadName = (String) threads.next();
thread = switchboard.getThread(threadName);
// set values to templates
prop.put("table_" + c + "_threadname", threadName);
prop.put("table_" + c + "_shortdescr", (thread.getMonitorURL() == null) ? thread.getShortDescription() : "<a href=\"" + thread.getMonitorURL() + "\" class=?\"small\">" + thread.getShortDescription() + "</a>");
prop.put("table_" + c + "_longdescr", thread.getLongDescription());
queuesize = thread.getJobCount();
prop.put("table_" + c + "_queuesize", (queuesize == Integer.MAX_VALUE) ? "unlimited" : Integer.toString(queuesize));
blocktime = thread.getBlockTime();
sleeptime = thread.getSleepTime();
exectime = thread.getExecTime();
memuse = thread.getMemoryUse();
idleCycles = thread.getIdleCycles();
busyCycles = thread.getBusyCycles();
memshortageCycles = thread.getOutOfMemoryCycles();
prop.put("table_" + c + "_blocktime", blocktime / 1000);
prop.put("table_" + c + "_blockpercent", Long.toString(100 * blocktime / blocktime_total));
prop.put("table_" + c + "_sleeptime", sleeptime / 1000);
prop.put("table_" + c + "_sleeppercent", Long.toString(100 * sleeptime / sleeptime_total));
prop.put("table_" + c + "_exectime", exectime / 1000);
prop.put("table_" + c + "_execpercent", Long.toString(100 * exectime / exectime_total));
prop.put("table_" + c + "_totalcycles", Long.toString(idleCycles + busyCycles + memshortageCycles));
prop.put("table_" + c + "_idlecycles", Long.toString(idleCycles));
prop.put("table_" + c + "_busycycles", Long.toString(busyCycles));
prop.put("table_" + c + "_memscycles", Long.toString(memshortageCycles));
prop.put("table_" + c + "_sle ", ((idleCycles + busyCycles) == 0) ? "-" : Long.toString(sleeptime / (idleCycles + busyCycles)));
prop.put("table_" + c + "_execpercycle", (busyCycles == 0) ? "-" : Long.toString(exectime / busyCycles));
prop.put("table_" + c + "_memusepercycle", (busyCycles == 0) ? "-" : Long.toString(memuse / busyCycles / 1024));
// load with old values
idlesleep = Long.parseLong(switchboard.getConfig(threadName + "_idlesleep" , "1000"));
busysleep = Long.parseLong(switchboard.getConfig(threadName + "_busysleep", "100"));
memprereq = Long.parseLong(switchboard.getConfig(threadName + "_memprereq", "0"));
prop.put("table_" + c + "_idlesleep", idlesleep);
prop.put("table_" + c + "_busysleep", busysleep);
prop.put("table_" + c + "_memprereq", memprereq / 1024);
c++;
}
prop.put("table", c);
// table cache settings
prop.put("wordCacheMaxCount", switchboard.getConfig("wordCacheMaxCount", "10000"));
// table thread pool settings
GenericObjectPool.Config crawlerPoolConfig = switchboard.cacheLoader.getPoolConfig();
prop.put("pool_0_name","Crawler Pool");
prop.put("pool_0_maxActive",crawlerPoolConfig.maxActive);
prop.put("pool_0_maxIdle",crawlerPoolConfig.maxIdle);
prop.put("pool_0_minIdle",crawlerPoolConfig.minIdle);
serverThread httpd = switchboard.getThread("10_httpd");
GenericObjectPool.Config httpdPoolConfig = ((serverCore)httpd).getPoolConfig();
prop.put("pool_1_name","httpd Session Pool");
prop.put("pool_1_maxActive",httpdPoolConfig.maxActive);
prop.put("pool_1_maxIdle",httpdPoolConfig.maxIdle);
prop.put("pool_1_minIdle",httpdPoolConfig.minIdle);
GenericObjectPool.Config stackerPoolConfig = switchboard.sbStackCrawlThread.getPoolConfig();
prop.put("pool_2_name","CrawlStacker Session Pool");
prop.put("pool_2_maxActive",stackerPoolConfig.maxActive);
prop.put("pool_2_maxIdle",stackerPoolConfig.maxIdle);
prop.put("pool_2_minIdle",stackerPoolConfig.minIdle);
prop.put("pool",3);
// parse initialization memory settings
String Xmx = sb.getConfig("javastart_Xmx", "Xmx64m").substring(3);
prop.put("Xmx", Xmx.substring(0, Xmx.length() - 1));
String Xms = sb.getConfig("javastart_Xms", "Xms10m").substring(3);
prop.put("Xms", Xms.substring(0, Xms.length() - 1));
plasmaSwitchboard sb1 = (plasmaSwitchboard) sb;
req = sb1.wordIndex.size();
putprop(prop, sb, "RWI");
req = sb1.cacheManager.dbSize();
putprop(prop, sb, "HTTP");
//req = sb1.urlPool.loadedURL.urlHashCache.size();
putprop(prop, sb, "LURL");
//req = sb1.urlPool.noticeURL.urlHashCache.size();
putprop(prop, sb, "NURL");
//req = sb1.urlPool.errorURL.urlHashCache.size();
putprop(prop, sb, "EURL");
req = yacyCore.seedDB.sizeConnected() + yacyCore.seedDB.sizeDisconnected() + yacyCore.seedDB.sizePotential();
putprop(prop, sb, "DHT");
req = sb1.messageDB.size();
putprop(prop, sb, "Message");
req = sb1.wikiDB.sizeOfTwo();
putprop(prop, sb, "Wiki");
req = sb1.blogDB.size();
putprop(prop, sb, "Blog");
req = yacyCore.newsPool.dbSize();
putprop(prop, sb, "News");
req = plasmaSwitchboard.robots.size();
putprop(prop, sb, "Robots");
req = sb1.profiles.size();
putprop(prop, sb, "Profiles");
prop.put("versionpp", yacy.combinedVersionString2PrettyString(sb.getConfig("version","0.1")));
prop.put("links", yacyCore.seedDB.mySeed.get(yacySeed.LCOUNT, "unknown"));
prop.put("words", yacyCore.seedDB.mySeed.get(yacySeed.ICOUNT, "unknown"));
/*prop.put("address", yacyCore.seedDB.mySeed.getAddress());
prop.put("ip", serverCore.publicLocalIP());*/
prop.put("hash", yacyCore.seedDB.mySeed.hash);
String jversion = System.getProperties().getProperty("java.vendor");
jversion += " " + System.getProperties().getProperty("java.version");
prop.put("jversion", jversion);
prop.put("processors",Runtime.getRuntime().availableProcessors());
// return rewrite values for templates
return prop;
}
private static void putprop(serverObjects prop, serverSwitch sb, String db) {
prop.put("slreq" + db, req);
prop.put("ramCache" + db, Long.parseLong(sb.getConfig("ramCache" + db, "0")) / KB);
}
private static String d(String a, String b) {
return (a == null) ? b : a;
}
}
Loading…
Cancel
Save