Giter Club home page Giter Club logo

matthiaspetermann / netbsd_exporter Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 26 KB

The netbsd_exporter retrieves system metrics such as disk I/O, network I/O, RAM and filesystem usage, as well as CPU load from the running system and exposes them in the format of Prometheus metrics. It is designed to be integrated into inetd, providing a lightweight, NetBSD-focused alternative to the node_exporter.

License: BSD 2-Clause "Simplified" License

Makefile 3.49% Roff 8.08% C 88.43%

netbsd_exporter's People

Contributors

matthiaspetermann avatar

Watchers

 avatar

netbsd_exporter's Issues

Shows negative numbers for file system size values on 32bit arch

How to reproduce:

Simply build and run on a 32bit machine. I tested my usual candidates
for this: port-i386, port-sparc, port-vax. I assume this code was written
and tested on 64bit machines only.

Example output (snipped irrelevant parts):

netbsd_fs_size_bytes{device="wd0a",mountpoint="/"} -1958563840
netbsd_fs_used_bytes{device="wd0a",mountpoint="/"} -1555032064
netbsd_fs_free_bytes{device="wd0a",mountpoint="/"} -1808840704

df says:

/dev/wd0a 26G 2.6G 22G 10% /

How to fix:

This is essentially the old C language trap that identically named integer types are
of different size depending on platform word size. In this case, long is
8 bytes (64bit) on a 64bit machine (which is large enough here) and
4 bytes (32bit) on a 32bit machine (which will cheerfully overflow
here).

There are reasons int64_t, uint64_t, int32_t and friends are defined
these days. Of course with that, gcc rightfully complains about
the formatting args, because uint64_t is long long int on 32bit and
long int on 64bit machines. So I ended up using long long which is
64bit on both.

With that, it works correctly on both 32bit and 64bit machines. Tested
platforms: port-i386, port-amd64, port-vax, port-sparc, port-sparc64.

And for those who no longer have 32bit machines, qemu works very well
(that's how I run my port-sparc machine on an arm64 host).

Patch follows

--- netbsd_exporter.h.orig      2024-05-09 18:58:29.961248161 +0200
+++ netbsd_exporter.h   2024-05-09 19:49:00.021634195 +0200
@@ -31,7 +31,7 @@
 int option_http_header = 1;
 int option_syslog = 1;

-void print_filesystem_metric(const char*, const char*, const char*, long );
+void print_filesystem_metric(const char*, const char*, const char*, long long unsigned int);

 void print_disk_io_metric(const char*, long long unsigned int, long long unsigned int );

--- netbsd_exporter.c.orig      2024-05-07 11:40:44.013487932 +0200
+++ netbsd_exporter.c   2024-05-09 19:49:15.832451252 +0200
@@ -53,8 +53,8 @@
 #include "netbsd_exporter.h"
 #include "version.h"

-void print_filesystem_metric(const char* metric, const char* device, const char* mountpoint, long value) {
-    printf("netbsd_fs_%s_bytes{device=\"%s\",mountpoint=\"%s\"} %ld\n", metric, device, mountpoint, value);
+void print_filesystem_metric(const char* metric, const char* device, const char* mountpoint, long long unsigned int value) {
+    printf("netbsd_fs_%s_bytes{device=\"%s\",mountpoint=\"%s\"} %llu\n", metric, device, mountpoint, value);
 }

 void print_disk_io_metric(const char* device, long long unsigned int rbytes, long long unsigned int wbytes) {

Change metric: Use labels for load window instead of 3 individual load metrics

The snmp_exporter against my Fritzbox returns the load as a
value with labels, so:
laLoadInt{laNames="Load-1"} 10
laLoadInt{laNames="Load-15"} 17
laLoadInt{laNames="Load-5"} 10

The netbsd_exporter has 3 metrics for this:
netbsd_load1 0.059082
netbsd_load5 0.083496
netbsd_load15 0.141113

I find this a bit more convenient with labels, because I can
graph construction I only have to include one metric.

Not a big deal and if you disagree, that's ok too, I just
just wanted to mention it.

(Reported by Thomas Klausner)

Align metric names with Prometheus / Grafana standards

"Beim Basteln des neuen Dashboards ist mir aufgefallen, dass
prometheus/grafana die Namen ein paar der Metriken nicht mögen, weil
sie nicht auf "_total" o.ä. enden. Ich hänge dir die Screenshots an.
(es funktioniert, aber es gibt so ein Warnungsdreieck bei den Graphen)"

(reported by Thomas Klausner)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.