* save start time
* memory utilisation
This commit is contained in:
		@@ -2,15 +2,30 @@ package com.wasteinformationserver.basicutils;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.text.NumberFormat;
 | 
			
		||||
import java.text.SimpleDateFormat;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.Properties;
 | 
			
		||||
 | 
			
		||||
public class Info {
 | 
			
		||||
    public static String version="0.0";
 | 
			
		||||
    public static String builddate;
 | 
			
		||||
    private static String version="not init";
 | 
			
		||||
    private static String builddate="not init";
 | 
			
		||||
    private static String starttime="not init";
 | 
			
		||||
 | 
			
		||||
    public static String getVersion() {
 | 
			
		||||
        return version;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String getBuilddate() {
 | 
			
		||||
        return builddate;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String getStarttime() {
 | 
			
		||||
        return starttime;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void init(){
 | 
			
		||||
        starttime = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date());
 | 
			
		||||
        Properties prop = new Properties();
 | 
			
		||||
        try {
 | 
			
		||||
            URL url = Info.class.getResource("/version.properties");
 | 
			
		||||
@@ -22,4 +37,22 @@ public class Info {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void getMemoryUsage(){
 | 
			
		||||
        Runtime runtime = Runtime.getRuntime();
 | 
			
		||||
 | 
			
		||||
        NumberFormat format = NumberFormat.getInstance();
 | 
			
		||||
 | 
			
		||||
        StringBuilder sb = new StringBuilder();
 | 
			
		||||
        long maxMemory = runtime.maxMemory();
 | 
			
		||||
        long allocatedMemory = runtime.totalMemory();
 | 
			
		||||
        long freeMemory = runtime.freeMemory();
 | 
			
		||||
 | 
			
		||||
        sb.append("free memory: " + format.format(freeMemory / 1024) + "\n");
 | 
			
		||||
        sb.append("allocated memory: " + format.format(allocatedMemory / 1024) + "\n");
 | 
			
		||||
        sb.append("max memory: " + format.format(maxMemory / 1024) + "\n");
 | 
			
		||||
        sb.append("total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024) + "\n");
 | 
			
		||||
 | 
			
		||||
        System.out.println(sb.toString());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,8 +26,8 @@ public class main {
 | 
			
		||||
        }));
 | 
			
		||||
 | 
			
		||||
        Info.init();
 | 
			
		||||
        Log.info("Server version: "+Info.version);
 | 
			
		||||
        Log.debug("Build date: "+Info.builddate);
 | 
			
		||||
        Log.info("Server version: "+Info.getVersion());
 | 
			
		||||
        Log.debug("Build date: "+Info.getBuilddate());
 | 
			
		||||
 | 
			
		||||
        //initial connect to db
 | 
			
		||||
        Log.message("initial login to db");
 | 
			
		||||
 
 | 
			
		||||
@@ -175,8 +175,8 @@ public class DataRequest extends PostRequest {
 | 
			
		||||
            case "getversionandbuildtime":
 | 
			
		||||
                sb.append("{");
 | 
			
		||||
 | 
			
		||||
                sb.append("\"version\" : \""+ Info.version+"\"");
 | 
			
		||||
                sb.append(",\"buildtime\" : \""+ Info.builddate+"\"");
 | 
			
		||||
                sb.append("\"version\" : \""+ Info.getVersion()+"\"");
 | 
			
		||||
                sb.append(",\"buildtime\" : \""+ Info.getBuilddate()+"\"");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                sb.append(",\"query\":\"ok\"");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user