Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SAVA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Agroclim
SAVA
Commits
27017497
Commit
27017497
authored
10 months ago
by
TROMEL LOUIS
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Ajouter la version de la distribution"
parent
1248909f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Resolve "Ajouter la version de la distribution"
Pipeline
#199331
passed
10 months ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sava-core/src/main/java/fr/agroclim/sava/core/MetricsBasicAuthServlet.java
+15
-1
15 additions, 1 deletion
...n/java/fr/agroclim/sava/core/MetricsBasicAuthServlet.java
with
15 additions
and
1 deletion
sava-core/src/main/java/fr/agroclim/sava/core/MetricsBasicAuthServlet.java
+
15
−
1
View file @
27017497
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
());
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment