# How to import freebsd statistics into prometheus



## Alain De Vos (Jul 17, 2021)

There is an application which produces prometheus statistics.
prometheus_sysctl_exporter and
man 8 prometheus_sysctl_exporter

But prometheus exporters normally work with a web-listener.
I should in theory not be that diffucult to make a web-listener out of this.
Give it the parameter " -h      Precede the output with a HTTP response header.  This flag is required when running this utility through inetd(8)"
But i don't like inetd as it is insecure.
Maybe with a bit of python-code. Anyone ?


----------



## Phishfry (Jul 17, 2021)

We seem to have all the exporters mentioned in this tutorial.
sysutils/node_exporter
net-mgmt/blackbox_exporter
sysutils/snmp_exporter





						Home Network Monitoring using Prometheus • FreeBSD Adventures
					

This blog post describes my setup for monitoring various devices on my home network suh as servers, laptops/desktops, networking gear etc. The setup and configuration is squarely geared towards small/medium sized network monitoring. A similar setup might work for large networks, but you will...




					linux-bsd.github.io


----------



## Phishfry (Jul 17, 2021)

I had to read up on sysctl_exporter. I could not find it in ports but found the review.





						⚙ D8792 Add the Prometheus sysctl exporter.
					






					reviews.freebsd.org
				



Some really valid questions by manu about why is this needed in base.


----------



## Alain De Vos (Jul 17, 2021)

I found something,








						GitHub - IMMORTALxJO/sysctl_exporter: Sysctl Exporter
					

Sysctl Exporter. Contribute to IMMORTALxJO/sysctl_exporter development by creating an account on GitHub.




					github.com
				




```
./sysctl_exporter -h                                                   0
Usage of ./sysctl_exporter:
  -exclude string
        RegExp for skipping sysctl parameters
  -include string
        RegExp for sysctl parameters (default ".*")
  -listen-address string
        Address to listen on for telemetry (default ":9141")
  -log-level string
        Verbosity of logging (default "info")
  -metrics-prefix string
        Prefix of prometheus metrics (default "sysctl")
HOST:x: /home/x/sysctl_exporter >
```


----------



## Alain De Vos (Jul 17, 2021)

The sysctl prober is not working for me. No sysctl data,


----------



## Alain De Vos (Jul 17, 2021)

Create a prometheus exporter for freebsd
					

Freebsd create statistics as a command-line application which writes statistics in prometheus format.  https://www.freebsd.org/cgi/man.cgi?query=prometheus_sysctl_exporter  The output of the program on the commandline looks like this,  HTTP/1.1 200 OK  Connection: close  Content-Length: 407302...




					discuss.prometheus.io


----------



## Alain De Vos (Jul 17, 2021)

py38-prometheus-client-0.11.0,
It should be not too difficult to wrap this around "prometheus_sysctl_exporter",








						GitHub - prometheus/client_python: Prometheus instrumentation library for Python applications
					

Prometheus instrumentation library for Python applications - GitHub - prometheus/client_python: Prometheus instrumentation library for Python applications




					github.com


----------



## schmitmd (Nov 10, 2021)

A cheap and easy way of doing this might be just making a crontab entry that runs `prometheus_sysctl_exporter` every X seconds and tosses the output in, say, "sysctls.prom" in /var/tmp/node_exporter .  A running node_exporter installation with default settings will pick those metrics right up.  Not necessarily glamorous, but it does the trick.


----------

