aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/StatisticsManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/StatisticsManager.java')
-rw-r--r--src/org/traccar/database/StatisticsManager.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/org/traccar/database/StatisticsManager.java b/src/org/traccar/database/StatisticsManager.java
index 8abadddc5..09cfee856 100644
--- a/src/org/traccar/database/StatisticsManager.java
+++ b/src/org/traccar/database/StatisticsManager.java
@@ -15,6 +15,9 @@
*/
package org.traccar.database;
+import com.ning.http.client.Request;
+import com.ning.http.client.RequestBuilder;
+import org.joda.time.format.ISODateTimeFormat;
import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.Statistics;
@@ -27,7 +30,7 @@ import java.util.Set;
public class StatisticsManager {
- private static final int SPLIT_MODE = Calendar.DAY_OF_MONTH;
+ private static final int SPLIT_MODE = Calendar.MINUTE;
private int lastUpdate = Calendar.getInstance().get(SPLIT_MODE);
@@ -63,6 +66,27 @@ public class StatisticsManager {
Log.warning(e);
}
+ String url = Context.getConfig().getString("server.statistics");
+ if (url != null) {
+ String time = ISODateTimeFormat.dateTime().print(statistics.getCaptureTime().getTime());
+ Request request = new RequestBuilder("POST")
+ .setUrl(url)
+ .addHeader("Content-Type", "application/x-www-form-urlencoded")
+ .addFormParam("version", Log.getAppVersion())
+ .addFormParam("captureTime", time)
+ .addFormParam("activeUsers", String.valueOf(statistics.getActiveUsers()))
+ .addFormParam("activeDevices", String.valueOf(statistics.getActiveDevices()))
+ .addFormParam("requests", String.valueOf(statistics.getRequests()))
+ .addFormParam("messagesReceived", String.valueOf(statistics.getMessagesReceived()))
+ .addFormParam("messagesStored", String.valueOf(statistics.getMessagesStored()))
+ .addFormParam("mailSent", String.valueOf(statistics.getMailSent()))
+ .addFormParam("smsSent", String.valueOf(statistics.getSmsSent()))
+ .addFormParam("geocoderRequests", String.valueOf(statistics.getGeocoderRequests()))
+ .addFormParam("geolocationRequests", String.valueOf(statistics.getGeolocationRequests()))
+ .build();
+ Context.getAsyncHttpClient().prepareRequest(request).execute();
+ }
+
users.clear();
devices.clear();
requests = 0;