Skip to content
Snippets Groups Projects
Commit 27017497 authored by TROMEL LOUIS's avatar TROMEL LOUIS
Browse files

Resolve "Ajouter la version de la distribution"

parent 1248909f
No related branches found
No related tags found
1 merge request!6Resolve "Ajouter la version de la distribution"
Pipeline #199331 passed
package fr.agroclim.sava.core;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.Base64;
import javax.servlet.ServletException;
......@@ -8,13 +12,14 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.prometheus.client.exporter.MetricsServlet;
import java.nio.charset.StandardCharsets;
import lombok.extern.log4j.Log4j2;
/**
* SAVA metrics servlet, using basic_auth with context parameters.
*
* @author ltromel
*/
@Log4j2
public class MetricsBasicAuthServlet extends MetricsServlet {
/**
......@@ -60,6 +65,15 @@ public class MetricsBasicAuthServlet extends MetricsServlet {
"The total amount of memory in the Java virtual machine, measured in bytes");
SavaUtils.addGauge("jvm_free_memory",
"The amount of free memory in the Java Virtual Machine, measured in bytes");
try {
SavaUtils.addCounter("host_distribution", "Host machine distribution (linux only)", "", "version");
SavaUtils.incrementCounter("host_distribution", new BufferedReader(new InputStreamReader(new ProcessBuilder("lsb_release", "-ds").start().getInputStream())).readLine());
} catch (final Exception e) {
LOGGER.trace("Could not init host_distribution.");
}
SavaUtils.addCounter("run_since", "Server run date", "", "instant");
SavaUtils.incrementCounter("run_since", LocalDateTime.now().toString());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment