prometheus_exporter 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prometheus_exporter/server/web_server.rb +18 -3
- data/lib/prometheus_exporter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ab5d3f6ca1ef701116fda3e93cd10f27f2b6dec09d9c51e85a5cfb630680cb8
|
4
|
+
data.tar.gz: a743e9b6aa2b30d5cf815126bc75093a6ea99128b2837b7ab0008c732fb89a03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d8f8b98148df693fdc543a3f2a48893f3a101ecc30a9fddeae68a42c1aeb7a31c1848879e5226aae6e81662be4e1d83b1ed34d3e4a69f16ade8b5465e66957
|
7
|
+
data.tar.gz: 18960e4fefd02b61cbfd8188c8fd47fcb9e20c606e4adedf838e68e09a0446d5187583978a06edf6e2cc1668f4da9e80a01a6b399202f95bd007cfd3dc7b20e7
|
@@ -26,9 +26,13 @@ module PrometheusExporter::Server
|
|
26
26
|
res.status = 200
|
27
27
|
if req.header["accept-encoding"].to_s.include?("gzip")
|
28
28
|
sio = StringIO.new
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
collected_metrics = metrics
|
30
|
+
begin
|
31
|
+
writer = Zlib::GzipWriter.new(sio)
|
32
|
+
writer.write(collected_metrics)
|
33
|
+
ensure
|
34
|
+
writer.close
|
35
|
+
end
|
32
36
|
res.body = sio.string
|
33
37
|
res.header["content-encoding"] = "gzip"
|
34
38
|
else
|
@@ -91,12 +95,23 @@ module PrometheusExporter::Server
|
|
91
95
|
metric_text && metric_text.length > 0 ? 1 : 0
|
92
96
|
)
|
93
97
|
|
98
|
+
add_gauge(
|
99
|
+
"collector_rss",
|
100
|
+
"total memory used by collector process",
|
101
|
+
get_rss
|
102
|
+
)
|
103
|
+
|
94
104
|
<<~TEXT
|
95
105
|
#{@metrics.map(&:to_prometheus_text).join("\n\n")}
|
96
106
|
#{metric_text}
|
97
107
|
TEXT
|
98
108
|
end
|
99
109
|
|
110
|
+
def get_rss
|
111
|
+
@pagesize ||= `getconf PAGESIZE`.to_i rescue 4096
|
112
|
+
File.read("/proc/#{pid}/statm").split(' ')[1].to_i * @pagesize rescue 0
|
113
|
+
end
|
114
|
+
|
100
115
|
def add_gauge(name, help, value)
|
101
116
|
gauge = PrometheusExporter::Metric::Gauge.new(name, help)
|
102
117
|
gauge.observe(value)
|