diff --git a/htroot/Status.html b/htroot/Status.html
index 48e810d05..d5f0300de 100644
--- a/htroot/Status.html
+++ b/htroot/Status.html
@@ -109,6 +109,11 @@ you must switch off the proxy to go off-line.
Memory Usage |
free: #[freeMemory]# | total: #[totalMemory]# | max: #[maxMemory]#
|
+
+Traffic |
+In: #[trafficIn]# | Out: #[trafficOut]#
+ |
+
diff --git a/htroot/Status.java b/htroot/Status.java
index 0e2c6b974..5b3add157 100644
--- a/htroot/Status.java
+++ b/htroot/Status.java
@@ -43,9 +43,11 @@
// javac -classpath .:../Classes Status.java
// if the shell's current path is HTROOT
-import java.util.Properties;
+import java.text.DecimalFormat;
import de.anomic.http.httpHeader;
+import de.anomic.http.httpdByteCountInputStream;
+import de.anomic.http.httpdByteCountOutputStream;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -168,9 +170,13 @@ public class Status {
// memory usage
Runtime rt = Runtime.getRuntime();
- prop.put("freeMemory", Long.toString(rt.freeMemory()));
- prop.put("totalMemory", Long.toString(rt.totalMemory()));
- prop.put("maxMemory", Long.toString(rt.maxMemory()));
+ prop.put("freeMemory", bytesToString(rt.freeMemory()));
+ prop.put("totalMemory", bytesToString(rt.totalMemory()));
+ prop.put("maxMemory", bytesToString(rt.maxMemory()));
+
+ // proxy traffic
+ prop.put("trafficIn",bytesToString(httpdByteCountInputStream.getGlobalCount()));
+ prop.put("trafficOut",bytesToString(httpdByteCountOutputStream.getGlobalCount()));
// return rewrite properties
return prop;
@@ -200,5 +206,31 @@ public class Status {
return "unknown";
}
}
+
+ public static String bytesToString(long byteCount) {
+ try {
+ StringBuffer byteString = new StringBuffer();
+
+ DecimalFormat df = new DecimalFormat( "0.00" );
+ if (byteCount > 1073741824) {
+ byteString.append(df.format((double)byteCount / (double)1073741824 ))
+ .append(" GB");
+ } else if (byteCount > 1048576) {
+ byteString.append(df.format((double)byteCount / (double)1048576))
+ .append(" MB");
+ } else if (byteCount > 1024) {
+ byteString.append(df.format((double)byteCount /(double)1024))
+ .append(" KB");
+ } else {
+ byteString.append(Long.toString(byteCount))
+ .append(" Bytes");
+ }
+
+ return byteString.toString();
+ } catch (Exception e) {
+ return "unknown";
+ }
+
+ }
}