Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

extended search statistics

orbiterf3f99b19c696
diff --git a/htroot/SearchStatistics_p.html b/htroot/SearchStatistics_p.html
index 600f18a17..c771ff8f8 100644
--- a/htroot/SearchStatistics_p.html
+++ b/htroot/SearchStatistics_p.html
@@ -9,8 +9,10 @@
<div class="SubMenu">
<h3>Seach Statistics Menu</h3>
<ul class="SubMenu">
- <li><a href="/SearchStatistics_p.html?page=1" class="MenuItemLink lock">Local&nbsp;Searches</a></li>
- <li><a href="/SearchStatistics_p.html?page=3" class="MenuItemLink lock">Remote&nbsp;Searches</a></li>
+ <li><a href="/SearchStatistics_p.html?page=1" class="MenuItemLink lock">Local&nbsp;Search&nbsp;Log</a></li>
+ <li><a href="/SearchStatistics_p.html?page=2" class="MenuItemLink lock">Local&nbsp;Search&nbsp;Host&nbsp;Tracker</a></li>
+ <li><a href="/SearchStatistics_p.html?page=3" class="MenuItemLink lock">Remote&nbsp;Search&nbsp;Log</a></li>
+ <li><a href="/SearchStatistics_p.html?page=4" class="MenuItemLink lock">Remote&nbsp;Search&nbsp;Host&nbsp;Tracker</a></li>
</ul>
</div>
#(page)#
@@ -27,6 +29,7 @@
<tr class="TableHeader">
<td>Requesting Host</td>
<td>Date</td>
+ <td>Offset</td>
<td>Expected Results</td>
<td>Returned Results</td>
<td>Expected Time</td>
@@ -37,6 +40,7 @@
<tr class="TableCell#(dark)#Light::Dark#(/dark)#">
<td>#[host]#</td>
<td>#[date]#</td>
+ <td>#[offset]#</td>
<td>#[querycount]#</td>
<td>#[resultcount]#</td>
<td>#[querytime]#</td>
@@ -46,6 +50,23 @@
#{/list}#
</table>
::
+ <h2>Search Statistics: Local Searche Tracker</h2>
+ <p>This is a list of searches that had been requested from this' peer search interface</p>
+ <p>Showing #[num]# entries from a total of #[total]# Requests.</p>
+ <table border="0" cellpadding="2" cellspacing="1">
+ <tr class="TableHeader">
+ <td>Requesting Host</td>
+ <td>Count</td>
+ <td>Access Dates</td>
+ </tr>
+ #{list}#
+ <tr class="TableCell#(dark)#Light::Dark#(/dark)#">
+ <td>#[host]#</td>
+ <td>#[count]#</td>
+ <td>#[dates]#</td>
+ </tr>
+ #{/list}#
+ </table>
::
<h2>Search Statistics: Remote Searches</h2>
<p>This is a list of searches that had been requested from remote peer search interface</p>
@@ -53,6 +74,7 @@
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader">
<td>Requesting Host</td>
+ <td>Peer Name</td>
<td>Date</td>
<td>Expected Results</td>
<td>Returned Results</td>
@@ -63,6 +85,7 @@
#{list}#
<tr class="TableCell#(dark)#Light::Dark#(/dark)#">
<td>#[host]#</td>
+ <td>#[peername]#</td>
<td>#[date]#</td>
<td>#[querycount]#</td>
<td>#[resultcount]#</td>
@@ -72,6 +95,24 @@
</tr>
#{/list}#
</table>
+ ::
+ <h2>Search Statistics: Remote Searche Tracker</h2>
+ <p>This is a list of searches that had been requested from remote peer search interface</p>
+ <p>Showing #[num]# entries from a total of #[total]# Requests.</p>
+ <table border="0" cellpadding="2" cellspacing="1">
+ <tr class="TableHeader">
+ <td>Requesting Host</td>
+ <td>Count</td>
+ <td>Access Dates</td>
+ </tr>
+ #{list}#
+ <tr class="TableCell#(dark)#Light::Dark#(/dark)#">
+ <td>#[host]#</td>
+ <td>#[count]#</td>
+ <td>#[dates]#</td>
+ </tr>
+ #{/list}#
+ </table>
#(/page)#
#%env/templates/footer.template%#
</body>
diff --git a/htroot/SearchStatistics_p.java b/htroot/SearchStatistics_p.java
index 9b990cdee..491e9ca15 100644
--- a/htroot/SearchStatistics_p.java
+++ b/htroot/SearchStatistics_p.java
@@ -29,12 +29,14 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
+import de.anomic.yacy.yacyCore;
public class SearchStatistics_p {
@@ -50,42 +52,72 @@ public class SearchStatistics_p {
int maxCount = 100;
int entCount = 0;
boolean dark = true;
- Iterator i = (page <= 2) ? switchboard.localSearches.entrySet().iterator() : switchboard.remoteSearches.entrySet().iterator() ;
Map.Entry entry;
- Long trackerHandle;
- HashMap searchProfile;
- StringBuffer a = null;
- while ((entCount < maxCount) && (i.hasNext())) {
- entry = (Map.Entry) i.next();
- trackerHandle = (Long) entry.getKey();
- searchProfile = (HashMap) entry.getValue();
+ if ((page == 1) || (page == 3)) {
+ Iterator i = (page == 1) ? switchboard.localSearches.entrySet().iterator() : switchboard.remoteSearches.entrySet().iterator();
+ Long trackerHandle;
+ HashMap searchProfile;
+ StringBuffer a = null;
+ while ((entCount < maxCount) && (i.hasNext())) {
+ entry = (Map.Entry) i.next();
+ trackerHandle = (Long) entry.getKey();
+ searchProfile = (HashMap) entry.getValue();
- if (page <= 2) {
- Iterator wi = ((Set) searchProfile.get("querywords")).iterator();
- a = new StringBuffer();
- while (wi.hasNext()) a.append((String) wi.next()).append(' ');
- }
+ if (page == 1) {
+ Iterator wi = ((Set) searchProfile.get("querywords")).iterator();
+ a = new StringBuffer();
+ while (wi.hasNext()) a.append((String) wi.next()).append(' ');
+ }
- // put values in template
- prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) ); dark =! dark;
- prop.put("page_list_" + entCount + "_host", (String) searchProfile.get("host"));
- prop.put("page_list_" + entCount + "_date", (new Date(trackerHandle.longValue())).toString());
- if (page <= 2) {
- prop.put("page_list_" + entCount + "_querywords", new String(a));
- } else {
- prop.put("page_list_" + entCount + "_queryhashes", plasmaSearchQuery.anonymizedQueryHashes((Set) searchProfile.get("queryhashes")));
- }
- prop.put("page_list_" + entCount + "_querycount", ((Integer) searchProfile.get("querycount")).toString());
- prop.put("page_list_" + entCount + "_querytime", ((Long) searchProfile.get("querytime")).toString());
- prop.put("page_list_" + entCount + "_resultcount", ((Integer) searchProfile.get("resultcount")).toString());
- prop.put("page_list_" + entCount + "_resulttime", ((Long) searchProfile.get("resulttime")).toString());
+ // put values in template
+ prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) ); dark =! dark;
+ prop.put("page_list_" + entCount + "_host", (String) searchProfile.get("host"));
+ prop.put("page_list_" + entCount + "_date", yacyCore.universalDateShortString(new Date(trackerHandle.longValue())));
+ if (page == 1) {
+ // local search
+ prop.put("page_list_" + entCount + "_offset", ((Integer) searchProfile.get("offset")).toString());
+ prop.put("page_list_" + entCount + "_querywords", new String(a));
+ } else {
+ // remote search
+ prop.put("page_list_" + entCount + "_peername", (String) searchProfile.get("peername"));
+ prop.put("page_list_" + entCount + "_queryhashes", plasmaSearchQuery.anonymizedQueryHashes((Set) searchProfile.get("queryhashes")));
+ }
+ prop.put("page_list_" + entCount + "_querycount", ((Integer) searchProfile.get("querycount")).toString());
+ prop.put("page_list_" + entCount + "_querytime", ((Long) searchProfile.get("querytime")).toString());
+ prop.put("page_list_" + entCount + "_resultcount", ((Integer) searchProfile.get("resultcount")).toString());
+ prop.put("page_list_" + entCount + "_resulttime", ((Long) searchProfile.get("resulttime")).toString());
- // next
- entCount++;
+ // next
+ entCount++;
+ }
+ prop.put("page_list", entCount);
+ prop.put("page_num", entCount);
+ prop.put("page_total", (page == 1) ? switchboard.localSearches.size() : switchboard.remoteSearches.size());
+ }
+ if ((page == 2) || (page == 4)) {
+ Iterator i = (page == 2) ? switchboard.localSearchTracker.entrySet().iterator() : switchboard.remoteSearchTracker.entrySet().iterator();
+ String host, handlestring;
+ TreeSet handles;
+ while ((entCount < maxCount) && (i.hasNext())) {
+ entry = (Map.Entry) i.next();
+ host = (String) entry.getKey();
+ handles = (TreeSet) entry.getValue();
+ handlestring = "";
+ Iterator ii = handles.iterator();
+ while (ii.hasNext()) {
+ handlestring += yacyCore.universalDateShortString(new Date(((Long) ii.next()).longValue())) + " ";
+ }
+ prop.put("page_list_" + entCount + "_dark", ((dark) ? 1 : 0) ); dark =! dark;
+ prop.put("page_list_" + entCount + "_host", host);
+ prop.put("page_list_" + entCount + "_count", new Integer(handles.size()).toString());
+ prop.put("page_list_" + entCount + "_dates", handlestring);
+ // next
+ entCount++;
+ }
+ prop.put("page_list", entCount);
+ prop.put("page_num", entCount);
+ prop.put("page_total", (page == 2) ? switchboard.localSearches.size() : switchboard.remoteSearches.size());
}
- prop.put("page_list", entCount);
- prop.put("page_num", entCount);
- prop.put("page_total", (page <= 2) ? switchboard.localSearches.size() : switchboard.remoteSearches.size());
// return rewrite properties
return prop;
}
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index af2a7db7f..10aea030d 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -56,6 +56,7 @@ import java.util.TreeSet;
import de.anomic.http.httpHeader;
import de.anomic.kelondro.kelondroBitfield;
import de.anomic.index.indexContainer;
+import de.anomic.net.natLib;
import de.anomic.plasma.plasmaURL;
import de.anomic.index.indexURLEntry;
import de.anomic.plasma.plasmaCondenser;
@@ -247,6 +248,8 @@ public final class search {
searchProfile.put("resultcount", new Integer(joincount));
String client = (String) header.get("CLIENTIP");
searchProfile.put("host", client);
+ yacySeed remotepeer = yacyCore.seedDB.lookupByIP(natLib.getInetAddress(client), true, false, false);
+ searchProfile.put("peername", (remotepeer == null) ? "unknown" : remotepeer.getName());
sb.remoteSearches.put(trackerHandle, searchProfile);
TreeSet handles = (TreeSet) sb.remoteSearchTracker.get(client);
if (handles == null) handles = new TreeSet();
diff --git a/source/de/anomic/net/natLib.java b/source/de/anomic/net/natLib.java
index 9147edfe9..ed00ec366 100644
--- a/source/de/anomic/net/natLib.java
+++ b/source/de/anomic/net/natLib.java
@@ -45,6 +45,7 @@
package de.anomic.net;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import de.anomic.http.httpc;
@@ -143,6 +144,23 @@ public class natLib {
if (ip.indexOf(":") >= 0) return false; // ipv6...
return (isNotLocal(ip)) && (isIP(ip));
}
+
+ public static final InetAddress getInetAddress(String ip) {
+ if (ip == null) return null;
+ if (ip.length() < 8) return null;
+ String[] ips = ip.split("\\.");
+ if (ips.length != 4) return null;
+ byte[] ipb = new byte[4];
+ ipb[0] = (byte) Integer.parseInt(ips[0]);
+ ipb[1] = (byte) Integer.parseInt(ips[1]);
+ ipb[2] = (byte) Integer.parseInt(ips[2]);
+ ipb[3] = (byte) Integer.parseInt(ips[3]);
+ try {
+ return InetAddress.getByAddress(ipb);
+ } catch (UnknownHostException e) {
+ return null;
+ }
+ }
private static int retrieveOptions() {
return 3;
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index d01d9bf0a..4c57e30a5 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -2239,6 +2239,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
Long trackerHandle = new Long(System.currentTimeMillis());
HashMap searchProfile = theSearch.resultProfile();
searchProfile.put("host", client);
+ searchProfile.put("offset", new Integer(0));
+ searchProfile.put("results", results);
this.localSearches.put(trackerHandle, searchProfile);
TreeSet handles = (TreeSet) this.localSearchTracker.get(client);
if (handles == null) handles = new TreeSet();
diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.java
index 585f971ee..0dd74f1b8 100644
--- a/source/de/anomic/yacy/yacySeed.java
+++ b/source/de/anomic/yacy/yacySeed.java
@@ -64,7 +64,6 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -362,21 +361,7 @@ public class yacySeed {
public final InetAddress getInetAddress() {
// returns the ip address
- String ip = (String) this.dna.get(yacySeed.IP);
- if (ip == null) return null;
- if (ip.length() < 8) return null;
- String[] ips = ip.split("\\.");
- if (ips.length != 4) return null;
- byte[] ipb = new byte[4];
- ipb[0] = (byte) Integer.parseInt(ips[0]);
- ipb[1] = (byte) Integer.parseInt(ips[1]);
- ipb[2] = (byte) Integer.parseInt(ips[2]);
- ipb[3] = (byte) Integer.parseInt(ips[3]);
- try {
- return InetAddress.getByAddress(ipb);
- } catch (UnknownHostException e) {
- return null;
- }
+ return natLib.getInetAddress((String) this.dna.get(yacySeed.IP));
}
public final int getPort() {