jool-exporter 20.12.20__tar.gz → 25.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2020, Cooper Lees
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.2
2
+ Name: jool-exporter
3
+ Version: 25.3.8
4
+ Summary: Export `jool stats display` for prometheus
5
+ Home-page: http://github.com/cooperlees/jool-exporter
6
+ Author: Cooper Lees
7
+ Author-email: me@cooperlees.com
8
+ License: BSD
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: prometheus_client
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
27
+
28
+ # jool-exporter
29
+
30
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
31
+ [![Actions Status](https://github.com/cooperlees/jool-exporter/workflows/ci/badge.svg)](https://github.com/cooperlees/jool-exporter/actions)
32
+ [![PyPI](https://img.shields.io/pypi/v/jool-exporter)](https://pypi.org/project/jool-exporter/)
33
+ [![Downloads](https://pepy.tech/badge/jool-exporter/week)](https://pepy.tech/project/jool-exporter/week)
34
+
35
+ jool SIIT-DC + NAT64 stats prometheus exporter
36
+
37
+ ## What is this?
38
+
39
+ jool-exporter is a prometheus exporter HTTP service that wraps `jool stats display`
40
+ and reads the statistics at the time of the request into promerthues compatible
41
+ format.
42
+
43
+ - jool-exporter changes `JSTAT` prefix to `jool_` prefix for key names
44
+ - We attach the explanation of each stat to the guages
45
+
46
+ ## Install
47
+
48
+ From PyPI:
49
+
50
+ - `pip install jool-exporter`
51
+
52
+ From GitHub:
53
+
54
+ - `pip install git+git://github.com/cooperlees/jool-exporter`
55
+
56
+ ## Running
57
+
58
+ `jool` CLI needs `CAP_NET_ADMIN` capability in order to pull the statistics. Due to this,
59
+ so does the jool-exporter process. It also need to ability to pass the capability to child
60
+ processes.
61
+
62
+ - From version **4.1.5** jool will no longer require this capability to query stats
63
+
64
+ The process can also just run was `root`, but running things listening externally as `root`
65
+ is a bad security process.
66
+
67
+ ### SystemD
68
+
69
+ We have a [Systemd Service](jool-exporter.service) unit file commited to the repo that runs as nobody and passes the
70
+ capability to all children process.
71
+ - This is the recommended way to run the service
72
+
73
+ #### SystemD install
74
+
75
+ - `cp jool-exporter.service /etc/systemd/system`
76
+ - `sudo systemctl daemon-reload`
77
+ - `sudo systemctl enable jool-exporter`
78
+ - `sudo systemctl start jool-exporter`
79
+
80
+ Logs will by default go to journald
81
+
82
+ - `journalctl -u jool-exporter [-f]`
83
+
84
+ ## Example Return
85
+
86
+ - curl http://localhost:6971/metrics
87
+
88
+ ```prometheus
89
+ cooper@home1:~$ curl http://localhost:6971/metrics
90
+ # HELP python_gc_objects_collected_total Objects collected during gc
91
+ # TYPE python_gc_objects_collected_total counter
92
+ python_gc_objects_collected_total{generation="0"} 373.0
93
+ python_gc_objects_collected_total{generation="1"} 0.0
94
+ python_gc_objects_collected_total{generation="2"} 0.0
95
+ # HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
96
+ # TYPE python_gc_objects_uncollectable_total counter
97
+ python_gc_objects_uncollectable_total{generation="0"} 0.0
98
+ python_gc_objects_uncollectable_total{generation="1"} 0.0
99
+ python_gc_objects_uncollectable_total{generation="2"} 0.0
100
+ # HELP python_gc_collections_total Number of times this generation was collected
101
+ # TYPE python_gc_collections_total counter
102
+ python_gc_collections_total{generation="0"} 40.0
103
+ python_gc_collections_total{generation="1"} 3.0
104
+ python_gc_collections_total{generation="2"} 0.0
105
+ # HELP python_info Python platform information
106
+ # TYPE python_info gauge
107
+ python_info{implementation="CPython",major="3",minor="8",patchlevel="5",version="3.8.5"} 1.0
108
+ # HELP process_virtual_memory_bytes Virtual memory size in bytes.
109
+ # TYPE process_virtual_memory_bytes gauge
110
+ process_virtual_memory_bytes 1.81788672e+08
111
+ # HELP process_resident_memory_bytes Resident memory size in bytes.
112
+ # TYPE process_resident_memory_bytes gauge
113
+ process_resident_memory_bytes 2.0611072e+07
114
+ # HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
115
+ # TYPE process_start_time_seconds gauge
116
+ process_start_time_seconds 1.60830649484e+09
117
+ # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
118
+ # TYPE process_cpu_seconds_total counter
119
+ process_cpu_seconds_total 15.11
120
+ # HELP process_open_fds Number of open file descriptors.
121
+ # TYPE process_open_fds gauge
122
+ process_open_fds 6.0
123
+ # HELP process_max_fds Maximum number of open file descriptors.
124
+ # TYPE process_max_fds gauge
125
+ process_max_fds 1024.0
126
+ # HELP jool_received6 jool metric
127
+ # TYPE jool_received6 gauge
128
+ jool_received6{hostname="home1.cooperlees.com"} 7.9109475e+07
129
+ # HELP jool_received4 jool metric
130
+ # TYPE jool_received4 gauge
131
+ jool_received4{hostname="home1.cooperlees.com"} 1.3273675e+08
132
+ # HELP jool_success Successful translations. (Note: 'Successful translation' does not imply that the packet was actually delivered.)
133
+ # TYPE jool_success gauge
134
+ jool_success{hostname="home1.cooperlees.com"} 4.501274e+06
135
+ # HELP jool_bib_entries Number of BIB entries currently held in the BIB.
136
+ # TYPE jool_bib_entries gauge
137
+ jool_bib_entries{hostname="home1.cooperlees.com"} 245.0
138
+ # HELP jool_sessions Number of session entries currently held in the BIB.
139
+ # TYPE jool_sessions gauge
140
+ jool_sessions{hostname="home1.cooperlees.com"} 245.0
141
+ # HELP jool_unknown_l4_proto Translations cancelled: Packet carried an unknown transport protocol. (Untranslatable by NAT64.)
142
+ # TYPE jool_unknown_l4_proto gauge
143
+ jool_unknown_l4_proto{hostname="home1.cooperlees.com"} 6783.0
144
+ # HELP jool_unknown_icmp6_type Translations cancelled: ICMPv6 header's type value has no ICMPv4 counterpart.
145
+ # TYPE jool_unknown_icmp6_type gauge
146
+ jool_unknown_icmp6_type{hostname="home1.cooperlees.com"} 279293.0
147
+ # HELP jool_pool6_mismatch Translations cancelled: IPv6 packet's destination address did not match pool6. (ie. Packet was not meant to be translated.)
148
+ # TYPE jool_pool6_mismatch gauge
149
+ jool_pool6_mismatch{hostname="home1.cooperlees.com"} 7.7009472e+07
150
+ # HELP jool_pool4_mismatch Translations cancelled: IPv4 packet's destination address and transport protocol did not match pool4. (ie. Packet was not meant to be translated.)\nIf the instance is a Netfilter translator, this counter increases randomly from normal operation, and is harmless.\nIf the instance is an iptables translator, this counter being positive suggests a mismatch between the IPv4 iptables rule(s) and the instance's configuration.
151
+ # TYPE jool_pool4_mismatch gauge
152
+ jool_pool4_mismatch{hostname="home1.cooperlees.com"} 1.30048136e+08
153
+ # HELP jool_bib4_not_found Translations cancelled: IPv4 packet did not match a BIB entry from the database.
154
+ # TYPE jool_bib4_not_found gauge
155
+ jool_bib4_not_found{hostname="home1.cooperlees.com"} 238.0
156
+ # HELP jool_syn6_expected Translations cancelled: Incoming IPv6 packet was the first of a TCP connection, but its SYN flag was disabled.
157
+ # TYPE jool_syn6_expected gauge
158
+ jool_syn6_expected{hostname="home1.cooperlees.com"} 268.0
159
+ # HELP jool_syn4_expected Translations cancelled: Incoming IPv4 packet was the first of a TCP connection, but its SYN flag was disabled.
160
+ # TYPE jool_syn4_expected gauge
161
+ jool_syn4_expected{hostname="home1.cooperlees.com"} 461.0
162
+ # HELP jool_type1pkt Total number of Type 1 packets stored. (See https://github.com/NICMx/Jool/blob/584a846d09e891a0cd6342426b7a25c6478c90d6/src/mod/nat64/bib/pkt_queue.h#L77) (This counter is not decremented when a packet leaves the queue.)
163
+ # TYPE jool_type1pkt gauge
164
+ jool_type1pkt{hostname="home1.cooperlees.com"} 299.0
165
+ # HELP jool_so_exists Translations cancelled: Packet was a Simultaneous Open retry. (Client was trying to punch a hole, and was being unnecessarily greedy.)
166
+ # TYPE jool_so_exists gauge
167
+ jool_so_exists{hostname="home1.cooperlees.com"} 1.0
168
+ ```
169
+
170
+ ## Grafana Dashbaord Example
171
+
172
+ ![Grafana jool Dashboard Example](https://github.com/cooperlees/jool-exporter/blob/main/grafana_jool_example.png)
173
+
174
+ ## Development
175
+
176
+ We use Facebook's [ptr](https://github.com/facebookincubator/ptr) for testing.
177
+
178
+ - `pip install ptr`
179
+ - `cd .` # This repo
180
+ - `ptr [-k]`
181
+
182
+ It is driven by config in setup.py.
183
+
184
+
@@ -32,6 +32,8 @@ From GitHub:
32
32
  so does the jool-exporter process. It also need to ability to pass the capability to child
33
33
  processes.
34
34
 
35
+ - From version **4.1.5** jool will no longer require this capability to query stats
36
+
35
37
  The process can also just run was `root`, but running things listening externally as `root`
36
38
  is a bad security process.
37
39
 
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.2
2
+ Name: jool-exporter
3
+ Version: 25.3.8
4
+ Summary: Export `jool stats display` for prometheus
5
+ Home-page: http://github.com/cooperlees/jool-exporter
6
+ Author: Cooper Lees
7
+ Author-email: me@cooperlees.com
8
+ License: BSD
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: prometheus_client
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
27
+
28
+ # jool-exporter
29
+
30
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
31
+ [![Actions Status](https://github.com/cooperlees/jool-exporter/workflows/ci/badge.svg)](https://github.com/cooperlees/jool-exporter/actions)
32
+ [![PyPI](https://img.shields.io/pypi/v/jool-exporter)](https://pypi.org/project/jool-exporter/)
33
+ [![Downloads](https://pepy.tech/badge/jool-exporter/week)](https://pepy.tech/project/jool-exporter/week)
34
+
35
+ jool SIIT-DC + NAT64 stats prometheus exporter
36
+
37
+ ## What is this?
38
+
39
+ jool-exporter is a prometheus exporter HTTP service that wraps `jool stats display`
40
+ and reads the statistics at the time of the request into promerthues compatible
41
+ format.
42
+
43
+ - jool-exporter changes `JSTAT` prefix to `jool_` prefix for key names
44
+ - We attach the explanation of each stat to the guages
45
+
46
+ ## Install
47
+
48
+ From PyPI:
49
+
50
+ - `pip install jool-exporter`
51
+
52
+ From GitHub:
53
+
54
+ - `pip install git+git://github.com/cooperlees/jool-exporter`
55
+
56
+ ## Running
57
+
58
+ `jool` CLI needs `CAP_NET_ADMIN` capability in order to pull the statistics. Due to this,
59
+ so does the jool-exporter process. It also need to ability to pass the capability to child
60
+ processes.
61
+
62
+ - From version **4.1.5** jool will no longer require this capability to query stats
63
+
64
+ The process can also just run was `root`, but running things listening externally as `root`
65
+ is a bad security process.
66
+
67
+ ### SystemD
68
+
69
+ We have a [Systemd Service](jool-exporter.service) unit file commited to the repo that runs as nobody and passes the
70
+ capability to all children process.
71
+ - This is the recommended way to run the service
72
+
73
+ #### SystemD install
74
+
75
+ - `cp jool-exporter.service /etc/systemd/system`
76
+ - `sudo systemctl daemon-reload`
77
+ - `sudo systemctl enable jool-exporter`
78
+ - `sudo systemctl start jool-exporter`
79
+
80
+ Logs will by default go to journald
81
+
82
+ - `journalctl -u jool-exporter [-f]`
83
+
84
+ ## Example Return
85
+
86
+ - curl http://localhost:6971/metrics
87
+
88
+ ```prometheus
89
+ cooper@home1:~$ curl http://localhost:6971/metrics
90
+ # HELP python_gc_objects_collected_total Objects collected during gc
91
+ # TYPE python_gc_objects_collected_total counter
92
+ python_gc_objects_collected_total{generation="0"} 373.0
93
+ python_gc_objects_collected_total{generation="1"} 0.0
94
+ python_gc_objects_collected_total{generation="2"} 0.0
95
+ # HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
96
+ # TYPE python_gc_objects_uncollectable_total counter
97
+ python_gc_objects_uncollectable_total{generation="0"} 0.0
98
+ python_gc_objects_uncollectable_total{generation="1"} 0.0
99
+ python_gc_objects_uncollectable_total{generation="2"} 0.0
100
+ # HELP python_gc_collections_total Number of times this generation was collected
101
+ # TYPE python_gc_collections_total counter
102
+ python_gc_collections_total{generation="0"} 40.0
103
+ python_gc_collections_total{generation="1"} 3.0
104
+ python_gc_collections_total{generation="2"} 0.0
105
+ # HELP python_info Python platform information
106
+ # TYPE python_info gauge
107
+ python_info{implementation="CPython",major="3",minor="8",patchlevel="5",version="3.8.5"} 1.0
108
+ # HELP process_virtual_memory_bytes Virtual memory size in bytes.
109
+ # TYPE process_virtual_memory_bytes gauge
110
+ process_virtual_memory_bytes 1.81788672e+08
111
+ # HELP process_resident_memory_bytes Resident memory size in bytes.
112
+ # TYPE process_resident_memory_bytes gauge
113
+ process_resident_memory_bytes 2.0611072e+07
114
+ # HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
115
+ # TYPE process_start_time_seconds gauge
116
+ process_start_time_seconds 1.60830649484e+09
117
+ # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
118
+ # TYPE process_cpu_seconds_total counter
119
+ process_cpu_seconds_total 15.11
120
+ # HELP process_open_fds Number of open file descriptors.
121
+ # TYPE process_open_fds gauge
122
+ process_open_fds 6.0
123
+ # HELP process_max_fds Maximum number of open file descriptors.
124
+ # TYPE process_max_fds gauge
125
+ process_max_fds 1024.0
126
+ # HELP jool_received6 jool metric
127
+ # TYPE jool_received6 gauge
128
+ jool_received6{hostname="home1.cooperlees.com"} 7.9109475e+07
129
+ # HELP jool_received4 jool metric
130
+ # TYPE jool_received4 gauge
131
+ jool_received4{hostname="home1.cooperlees.com"} 1.3273675e+08
132
+ # HELP jool_success Successful translations. (Note: 'Successful translation' does not imply that the packet was actually delivered.)
133
+ # TYPE jool_success gauge
134
+ jool_success{hostname="home1.cooperlees.com"} 4.501274e+06
135
+ # HELP jool_bib_entries Number of BIB entries currently held in the BIB.
136
+ # TYPE jool_bib_entries gauge
137
+ jool_bib_entries{hostname="home1.cooperlees.com"} 245.0
138
+ # HELP jool_sessions Number of session entries currently held in the BIB.
139
+ # TYPE jool_sessions gauge
140
+ jool_sessions{hostname="home1.cooperlees.com"} 245.0
141
+ # HELP jool_unknown_l4_proto Translations cancelled: Packet carried an unknown transport protocol. (Untranslatable by NAT64.)
142
+ # TYPE jool_unknown_l4_proto gauge
143
+ jool_unknown_l4_proto{hostname="home1.cooperlees.com"} 6783.0
144
+ # HELP jool_unknown_icmp6_type Translations cancelled: ICMPv6 header's type value has no ICMPv4 counterpart.
145
+ # TYPE jool_unknown_icmp6_type gauge
146
+ jool_unknown_icmp6_type{hostname="home1.cooperlees.com"} 279293.0
147
+ # HELP jool_pool6_mismatch Translations cancelled: IPv6 packet's destination address did not match pool6. (ie. Packet was not meant to be translated.)
148
+ # TYPE jool_pool6_mismatch gauge
149
+ jool_pool6_mismatch{hostname="home1.cooperlees.com"} 7.7009472e+07
150
+ # HELP jool_pool4_mismatch Translations cancelled: IPv4 packet's destination address and transport protocol did not match pool4. (ie. Packet was not meant to be translated.)\nIf the instance is a Netfilter translator, this counter increases randomly from normal operation, and is harmless.\nIf the instance is an iptables translator, this counter being positive suggests a mismatch between the IPv4 iptables rule(s) and the instance's configuration.
151
+ # TYPE jool_pool4_mismatch gauge
152
+ jool_pool4_mismatch{hostname="home1.cooperlees.com"} 1.30048136e+08
153
+ # HELP jool_bib4_not_found Translations cancelled: IPv4 packet did not match a BIB entry from the database.
154
+ # TYPE jool_bib4_not_found gauge
155
+ jool_bib4_not_found{hostname="home1.cooperlees.com"} 238.0
156
+ # HELP jool_syn6_expected Translations cancelled: Incoming IPv6 packet was the first of a TCP connection, but its SYN flag was disabled.
157
+ # TYPE jool_syn6_expected gauge
158
+ jool_syn6_expected{hostname="home1.cooperlees.com"} 268.0
159
+ # HELP jool_syn4_expected Translations cancelled: Incoming IPv4 packet was the first of a TCP connection, but its SYN flag was disabled.
160
+ # TYPE jool_syn4_expected gauge
161
+ jool_syn4_expected{hostname="home1.cooperlees.com"} 461.0
162
+ # HELP jool_type1pkt Total number of Type 1 packets stored. (See https://github.com/NICMx/Jool/blob/584a846d09e891a0cd6342426b7a25c6478c90d6/src/mod/nat64/bib/pkt_queue.h#L77) (This counter is not decremented when a packet leaves the queue.)
163
+ # TYPE jool_type1pkt gauge
164
+ jool_type1pkt{hostname="home1.cooperlees.com"} 299.0
165
+ # HELP jool_so_exists Translations cancelled: Packet was a Simultaneous Open retry. (Client was trying to punch a hole, and was being unnecessarily greedy.)
166
+ # TYPE jool_so_exists gauge
167
+ jool_so_exists{hostname="home1.cooperlees.com"} 1.0
168
+ ```
169
+
170
+ ## Grafana Dashbaord Example
171
+
172
+ ![Grafana jool Dashboard Example](https://github.com/cooperlees/jool-exporter/blob/main/grafana_jool_example.png)
173
+
174
+ ## Development
175
+
176
+ We use Facebook's [ptr](https://github.com/facebookincubator/ptr) for testing.
177
+
178
+ - `pip install ptr`
179
+ - `cd .` # This repo
180
+ - `ptr [-k]`
181
+
182
+ It is driven by config in setup.py.
183
+
184
+
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  jool_exporter.py
3
4
  setup.py
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  jool-exporter = jool_exporter:main
3
-
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
- # This source code is licensed under the MIT license found in the
3
+ # This source code is licensed under the BSD license found in the
4
4
  # LICENSE file in the root directory of this source tree.
5
5
  # coding=utf8
6
6
 
@@ -14,16 +14,18 @@ from socket import getfqdn
14
14
  from subprocess import CompletedProcess, PIPE, run
15
15
  from typing import Generator, Union
16
16
 
17
- from prometheus_client.core import GaugeMetricFamily, REGISTRY # type: ignore
18
- from prometheus_client import start_http_server # type: ignore
17
+ from prometheus_client import start_http_server
18
+ from prometheus_client.core import GaugeMetricFamily, REGISTRY
19
+ from prometheus_client.registry import Collector
19
20
 
20
21
 
22
+ DEFAULT_ADDR = "0.0.0.0"
21
23
  DEFAULT_PORT = 6971
22
24
  HOSTNAME = getfqdn()
23
25
  LOG = logging.getLogger(__name__)
24
26
 
25
27
 
26
- class JoolCollector:
28
+ class JoolCollector(Collector):
27
29
  key_prefix = "jool"
28
30
  labels = ["hostname"]
29
31
 
@@ -61,7 +63,15 @@ class JoolCollector:
61
63
  LOG.info(f"Collection finished in {run_time}s")
62
64
 
63
65
  def run_jool(self) -> Union[str, CompletedProcess]:
64
- cmd = ["jool", "stats", "display", "--csv", "--no-headers", "--explain"]
66
+ cmd = [
67
+ "jool",
68
+ "stats",
69
+ "display",
70
+ "--csv",
71
+ "--no-headers",
72
+ "--explain",
73
+ "--all",
74
+ ]
65
75
  cp = run(cmd, stderr=PIPE, stdout=PIPE, encoding="utf8")
66
76
  if cp.returncode:
67
77
  return cp
@@ -81,6 +91,12 @@ def main() -> int:
81
91
  parser = argparse.ArgumentParser(
82
92
  description="Export `jool stats display` for prometheus"
83
93
  )
94
+ parser.add_argument(
95
+ "-a",
96
+ "--addr",
97
+ default=DEFAULT_ADDR,
98
+ help=f"Address to bind socket to [Default = {DEFAULT_ADDR}]",
99
+ )
84
100
  parser.add_argument(
85
101
  "-d", "--debug", action="store_true", help="Verbose debug output"
86
102
  )
@@ -95,7 +111,7 @@ def main() -> int:
95
111
  _handle_debug(args.debug)
96
112
 
97
113
  LOG.info(f"Starting {sys.argv[0]}")
98
- start_http_server(args.port)
114
+ start_http_server(args.port, args.addr)
99
115
  REGISTRY.register(JoolCollector())
100
116
  LOG.info(f"jool prometheus exporter - listening on {args.port}")
101
117
  try:
@@ -4,6 +4,7 @@
4
4
  # LICENSE file in the root directory of this source tree.
5
5
 
6
6
  from pathlib import Path
7
+
7
8
  from setuptools import setup
8
9
 
9
10
 
@@ -15,6 +16,7 @@ ptr_params = {
15
16
  "run_black": True,
16
17
  "run_mypy": True,
17
18
  "run_flake8": True,
19
+ "run_usort": True,
18
20
  }
19
21
 
20
22
 
@@ -31,7 +33,7 @@ def get_long_desc() -> str:
31
33
 
32
34
  setup(
33
35
  name="jool-exporter",
34
- version="20.12.20",
36
+ version="25.3.8",
35
37
  description="Export `jool stats display` for prometheus",
36
38
  long_description=get_long_desc(),
37
39
  long_description_content_type="text/markdown",
@@ -45,8 +47,6 @@ setup(
45
47
  "License :: OSI Approved :: BSD License",
46
48
  "Programming Language :: Python :: 3",
47
49
  "Programming Language :: Python :: 3 :: Only",
48
- "Programming Language :: Python :: 3.8",
49
- "Programming Language :: Python :: 3.9",
50
50
  ],
51
51
  python_requires=">=3.8",
52
52
  entry_points={"console_scripts": ["jool-exporter = jool_exporter:main"]},
@@ -1,173 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: jool-exporter
3
- Version: 20.12.20
4
- Summary: Export `jool stats display` for prometheus
5
- Home-page: http://github.com/cooperlees/jool-exporter
6
- Author: Cooper Lees
7
- Author-email: me@cooperlees.com
8
- License: BSD
9
- Description: # jool-exporter
10
-
11
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
12
- [![Actions Status](https://github.com/cooperlees/jool-exporter/workflows/ci/badge.svg)](https://github.com/cooperlees/jool-exporter/actions)
13
- [![PyPI](https://img.shields.io/pypi/v/jool-exporter)](https://pypi.org/project/jool-exporter/)
14
- [![Downloads](https://pepy.tech/badge/jool-exporter/week)](https://pepy.tech/project/jool-exporter/week)
15
-
16
- jool SIIT-DC + NAT64 stats prometheus exporter
17
-
18
- ## What is this?
19
-
20
- jool-exporter is a prometheus exporter HTTP service that wraps `jool stats display`
21
- and reads the statistics at the time of the request into promerthues compatible
22
- format.
23
-
24
- - jool-exporter changes `JSTAT` prefix to `jool_` prefix for key names
25
- - We attach the explanation of each stat to the guages
26
-
27
- ## Install
28
-
29
- From PyPI:
30
-
31
- - `pip install jool-exporter`
32
-
33
- From GitHub:
34
-
35
- - `pip install git+git://github.com/cooperlees/jool-exporter`
36
-
37
- ## Running
38
-
39
- `jool` CLI needs `CAP_NET_ADMIN` capability in order to pull the statistics. Due to this,
40
- so does the jool-exporter process. It also need to ability to pass the capability to child
41
- processes.
42
-
43
- The process can also just run was `root`, but running things listening externally as `root`
44
- is a bad security process.
45
-
46
- ### SystemD
47
-
48
- We have a [Systemd Service](jool-exporter.service) unit file commited to the repo that runs as nobody and passes the
49
- capability to all children process.
50
- - This is the recommended way to run the service
51
-
52
- #### SystemD install
53
-
54
- - `cp jool-exporter.service /etc/systemd/system`
55
- - `sudo systemctl daemon-reload`
56
- - `sudo systemctl enable jool-exporter`
57
- - `sudo systemctl start jool-exporter`
58
-
59
- Logs will by default go to journald
60
-
61
- - `journalctl -u jool-exporter [-f]`
62
-
63
- ## Example Return
64
-
65
- - curl http://localhost:6971/metrics
66
-
67
- ```prometheus
68
- cooper@home1:~$ curl http://localhost:6971/metrics
69
- # HELP python_gc_objects_collected_total Objects collected during gc
70
- # TYPE python_gc_objects_collected_total counter
71
- python_gc_objects_collected_total{generation="0"} 373.0
72
- python_gc_objects_collected_total{generation="1"} 0.0
73
- python_gc_objects_collected_total{generation="2"} 0.0
74
- # HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
75
- # TYPE python_gc_objects_uncollectable_total counter
76
- python_gc_objects_uncollectable_total{generation="0"} 0.0
77
- python_gc_objects_uncollectable_total{generation="1"} 0.0
78
- python_gc_objects_uncollectable_total{generation="2"} 0.0
79
- # HELP python_gc_collections_total Number of times this generation was collected
80
- # TYPE python_gc_collections_total counter
81
- python_gc_collections_total{generation="0"} 40.0
82
- python_gc_collections_total{generation="1"} 3.0
83
- python_gc_collections_total{generation="2"} 0.0
84
- # HELP python_info Python platform information
85
- # TYPE python_info gauge
86
- python_info{implementation="CPython",major="3",minor="8",patchlevel="5",version="3.8.5"} 1.0
87
- # HELP process_virtual_memory_bytes Virtual memory size in bytes.
88
- # TYPE process_virtual_memory_bytes gauge
89
- process_virtual_memory_bytes 1.81788672e+08
90
- # HELP process_resident_memory_bytes Resident memory size in bytes.
91
- # TYPE process_resident_memory_bytes gauge
92
- process_resident_memory_bytes 2.0611072e+07
93
- # HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
94
- # TYPE process_start_time_seconds gauge
95
- process_start_time_seconds 1.60830649484e+09
96
- # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
97
- # TYPE process_cpu_seconds_total counter
98
- process_cpu_seconds_total 15.11
99
- # HELP process_open_fds Number of open file descriptors.
100
- # TYPE process_open_fds gauge
101
- process_open_fds 6.0
102
- # HELP process_max_fds Maximum number of open file descriptors.
103
- # TYPE process_max_fds gauge
104
- process_max_fds 1024.0
105
- # HELP jool_received6 jool metric
106
- # TYPE jool_received6 gauge
107
- jool_received6{hostname="home1.cooperlees.com"} 7.9109475e+07
108
- # HELP jool_received4 jool metric
109
- # TYPE jool_received4 gauge
110
- jool_received4{hostname="home1.cooperlees.com"} 1.3273675e+08
111
- # HELP jool_success Successful translations. (Note: 'Successful translation' does not imply that the packet was actually delivered.)
112
- # TYPE jool_success gauge
113
- jool_success{hostname="home1.cooperlees.com"} 4.501274e+06
114
- # HELP jool_bib_entries Number of BIB entries currently held in the BIB.
115
- # TYPE jool_bib_entries gauge
116
- jool_bib_entries{hostname="home1.cooperlees.com"} 245.0
117
- # HELP jool_sessions Number of session entries currently held in the BIB.
118
- # TYPE jool_sessions gauge
119
- jool_sessions{hostname="home1.cooperlees.com"} 245.0
120
- # HELP jool_unknown_l4_proto Translations cancelled: Packet carried an unknown transport protocol. (Untranslatable by NAT64.)
121
- # TYPE jool_unknown_l4_proto gauge
122
- jool_unknown_l4_proto{hostname="home1.cooperlees.com"} 6783.0
123
- # HELP jool_unknown_icmp6_type Translations cancelled: ICMPv6 header's type value has no ICMPv4 counterpart.
124
- # TYPE jool_unknown_icmp6_type gauge
125
- jool_unknown_icmp6_type{hostname="home1.cooperlees.com"} 279293.0
126
- # HELP jool_pool6_mismatch Translations cancelled: IPv6 packet's destination address did not match pool6. (ie. Packet was not meant to be translated.)
127
- # TYPE jool_pool6_mismatch gauge
128
- jool_pool6_mismatch{hostname="home1.cooperlees.com"} 7.7009472e+07
129
- # HELP jool_pool4_mismatch Translations cancelled: IPv4 packet's destination address and transport protocol did not match pool4. (ie. Packet was not meant to be translated.)\nIf the instance is a Netfilter translator, this counter increases randomly from normal operation, and is harmless.\nIf the instance is an iptables translator, this counter being positive suggests a mismatch between the IPv4 iptables rule(s) and the instance's configuration.
130
- # TYPE jool_pool4_mismatch gauge
131
- jool_pool4_mismatch{hostname="home1.cooperlees.com"} 1.30048136e+08
132
- # HELP jool_bib4_not_found Translations cancelled: IPv4 packet did not match a BIB entry from the database.
133
- # TYPE jool_bib4_not_found gauge
134
- jool_bib4_not_found{hostname="home1.cooperlees.com"} 238.0
135
- # HELP jool_syn6_expected Translations cancelled: Incoming IPv6 packet was the first of a TCP connection, but its SYN flag was disabled.
136
- # TYPE jool_syn6_expected gauge
137
- jool_syn6_expected{hostname="home1.cooperlees.com"} 268.0
138
- # HELP jool_syn4_expected Translations cancelled: Incoming IPv4 packet was the first of a TCP connection, but its SYN flag was disabled.
139
- # TYPE jool_syn4_expected gauge
140
- jool_syn4_expected{hostname="home1.cooperlees.com"} 461.0
141
- # HELP jool_type1pkt Total number of Type 1 packets stored. (See https://github.com/NICMx/Jool/blob/584a846d09e891a0cd6342426b7a25c6478c90d6/src/mod/nat64/bib/pkt_queue.h#L77) (This counter is not decremented when a packet leaves the queue.)
142
- # TYPE jool_type1pkt gauge
143
- jool_type1pkt{hostname="home1.cooperlees.com"} 299.0
144
- # HELP jool_so_exists Translations cancelled: Packet was a Simultaneous Open retry. (Client was trying to punch a hole, and was being unnecessarily greedy.)
145
- # TYPE jool_so_exists gauge
146
- jool_so_exists{hostname="home1.cooperlees.com"} 1.0
147
- ```
148
-
149
- ## Grafana Dashbaord Example
150
-
151
- ![Grafana jool Dashboard Example](https://github.com/cooperlees/jool-exporter/blob/main/grafana_jool_example.png)
152
-
153
- ## Development
154
-
155
- We use Facebook's [ptr](https://github.com/facebookincubator/ptr) for testing.
156
-
157
- - `pip install ptr`
158
- - `cd .` # This repo
159
- - `ptr [-k]`
160
-
161
- It is driven by config in setup.py.
162
-
163
-
164
-
165
- Platform: UNKNOWN
166
- Classifier: Development Status :: 3 - Alpha
167
- Classifier: License :: OSI Approved :: BSD License
168
- Classifier: Programming Language :: Python :: 3
169
- Classifier: Programming Language :: Python :: 3 :: Only
170
- Classifier: Programming Language :: Python :: 3.8
171
- Classifier: Programming Language :: Python :: 3.9
172
- Requires-Python: >=3.8
173
- Description-Content-Type: text/markdown
@@ -1,173 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: jool-exporter
3
- Version: 20.12.20
4
- Summary: Export `jool stats display` for prometheus
5
- Home-page: http://github.com/cooperlees/jool-exporter
6
- Author: Cooper Lees
7
- Author-email: me@cooperlees.com
8
- License: BSD
9
- Description: # jool-exporter
10
-
11
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
12
- [![Actions Status](https://github.com/cooperlees/jool-exporter/workflows/ci/badge.svg)](https://github.com/cooperlees/jool-exporter/actions)
13
- [![PyPI](https://img.shields.io/pypi/v/jool-exporter)](https://pypi.org/project/jool-exporter/)
14
- [![Downloads](https://pepy.tech/badge/jool-exporter/week)](https://pepy.tech/project/jool-exporter/week)
15
-
16
- jool SIIT-DC + NAT64 stats prometheus exporter
17
-
18
- ## What is this?
19
-
20
- jool-exporter is a prometheus exporter HTTP service that wraps `jool stats display`
21
- and reads the statistics at the time of the request into promerthues compatible
22
- format.
23
-
24
- - jool-exporter changes `JSTAT` prefix to `jool_` prefix for key names
25
- - We attach the explanation of each stat to the guages
26
-
27
- ## Install
28
-
29
- From PyPI:
30
-
31
- - `pip install jool-exporter`
32
-
33
- From GitHub:
34
-
35
- - `pip install git+git://github.com/cooperlees/jool-exporter`
36
-
37
- ## Running
38
-
39
- `jool` CLI needs `CAP_NET_ADMIN` capability in order to pull the statistics. Due to this,
40
- so does the jool-exporter process. It also need to ability to pass the capability to child
41
- processes.
42
-
43
- The process can also just run was `root`, but running things listening externally as `root`
44
- is a bad security process.
45
-
46
- ### SystemD
47
-
48
- We have a [Systemd Service](jool-exporter.service) unit file commited to the repo that runs as nobody and passes the
49
- capability to all children process.
50
- - This is the recommended way to run the service
51
-
52
- #### SystemD install
53
-
54
- - `cp jool-exporter.service /etc/systemd/system`
55
- - `sudo systemctl daemon-reload`
56
- - `sudo systemctl enable jool-exporter`
57
- - `sudo systemctl start jool-exporter`
58
-
59
- Logs will by default go to journald
60
-
61
- - `journalctl -u jool-exporter [-f]`
62
-
63
- ## Example Return
64
-
65
- - curl http://localhost:6971/metrics
66
-
67
- ```prometheus
68
- cooper@home1:~$ curl http://localhost:6971/metrics
69
- # HELP python_gc_objects_collected_total Objects collected during gc
70
- # TYPE python_gc_objects_collected_total counter
71
- python_gc_objects_collected_total{generation="0"} 373.0
72
- python_gc_objects_collected_total{generation="1"} 0.0
73
- python_gc_objects_collected_total{generation="2"} 0.0
74
- # HELP python_gc_objects_uncollectable_total Uncollectable object found during GC
75
- # TYPE python_gc_objects_uncollectable_total counter
76
- python_gc_objects_uncollectable_total{generation="0"} 0.0
77
- python_gc_objects_uncollectable_total{generation="1"} 0.0
78
- python_gc_objects_uncollectable_total{generation="2"} 0.0
79
- # HELP python_gc_collections_total Number of times this generation was collected
80
- # TYPE python_gc_collections_total counter
81
- python_gc_collections_total{generation="0"} 40.0
82
- python_gc_collections_total{generation="1"} 3.0
83
- python_gc_collections_total{generation="2"} 0.0
84
- # HELP python_info Python platform information
85
- # TYPE python_info gauge
86
- python_info{implementation="CPython",major="3",minor="8",patchlevel="5",version="3.8.5"} 1.0
87
- # HELP process_virtual_memory_bytes Virtual memory size in bytes.
88
- # TYPE process_virtual_memory_bytes gauge
89
- process_virtual_memory_bytes 1.81788672e+08
90
- # HELP process_resident_memory_bytes Resident memory size in bytes.
91
- # TYPE process_resident_memory_bytes gauge
92
- process_resident_memory_bytes 2.0611072e+07
93
- # HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
94
- # TYPE process_start_time_seconds gauge
95
- process_start_time_seconds 1.60830649484e+09
96
- # HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
97
- # TYPE process_cpu_seconds_total counter
98
- process_cpu_seconds_total 15.11
99
- # HELP process_open_fds Number of open file descriptors.
100
- # TYPE process_open_fds gauge
101
- process_open_fds 6.0
102
- # HELP process_max_fds Maximum number of open file descriptors.
103
- # TYPE process_max_fds gauge
104
- process_max_fds 1024.0
105
- # HELP jool_received6 jool metric
106
- # TYPE jool_received6 gauge
107
- jool_received6{hostname="home1.cooperlees.com"} 7.9109475e+07
108
- # HELP jool_received4 jool metric
109
- # TYPE jool_received4 gauge
110
- jool_received4{hostname="home1.cooperlees.com"} 1.3273675e+08
111
- # HELP jool_success Successful translations. (Note: 'Successful translation' does not imply that the packet was actually delivered.)
112
- # TYPE jool_success gauge
113
- jool_success{hostname="home1.cooperlees.com"} 4.501274e+06
114
- # HELP jool_bib_entries Number of BIB entries currently held in the BIB.
115
- # TYPE jool_bib_entries gauge
116
- jool_bib_entries{hostname="home1.cooperlees.com"} 245.0
117
- # HELP jool_sessions Number of session entries currently held in the BIB.
118
- # TYPE jool_sessions gauge
119
- jool_sessions{hostname="home1.cooperlees.com"} 245.0
120
- # HELP jool_unknown_l4_proto Translations cancelled: Packet carried an unknown transport protocol. (Untranslatable by NAT64.)
121
- # TYPE jool_unknown_l4_proto gauge
122
- jool_unknown_l4_proto{hostname="home1.cooperlees.com"} 6783.0
123
- # HELP jool_unknown_icmp6_type Translations cancelled: ICMPv6 header's type value has no ICMPv4 counterpart.
124
- # TYPE jool_unknown_icmp6_type gauge
125
- jool_unknown_icmp6_type{hostname="home1.cooperlees.com"} 279293.0
126
- # HELP jool_pool6_mismatch Translations cancelled: IPv6 packet's destination address did not match pool6. (ie. Packet was not meant to be translated.)
127
- # TYPE jool_pool6_mismatch gauge
128
- jool_pool6_mismatch{hostname="home1.cooperlees.com"} 7.7009472e+07
129
- # HELP jool_pool4_mismatch Translations cancelled: IPv4 packet's destination address and transport protocol did not match pool4. (ie. Packet was not meant to be translated.)\nIf the instance is a Netfilter translator, this counter increases randomly from normal operation, and is harmless.\nIf the instance is an iptables translator, this counter being positive suggests a mismatch between the IPv4 iptables rule(s) and the instance's configuration.
130
- # TYPE jool_pool4_mismatch gauge
131
- jool_pool4_mismatch{hostname="home1.cooperlees.com"} 1.30048136e+08
132
- # HELP jool_bib4_not_found Translations cancelled: IPv4 packet did not match a BIB entry from the database.
133
- # TYPE jool_bib4_not_found gauge
134
- jool_bib4_not_found{hostname="home1.cooperlees.com"} 238.0
135
- # HELP jool_syn6_expected Translations cancelled: Incoming IPv6 packet was the first of a TCP connection, but its SYN flag was disabled.
136
- # TYPE jool_syn6_expected gauge
137
- jool_syn6_expected{hostname="home1.cooperlees.com"} 268.0
138
- # HELP jool_syn4_expected Translations cancelled: Incoming IPv4 packet was the first of a TCP connection, but its SYN flag was disabled.
139
- # TYPE jool_syn4_expected gauge
140
- jool_syn4_expected{hostname="home1.cooperlees.com"} 461.0
141
- # HELP jool_type1pkt Total number of Type 1 packets stored. (See https://github.com/NICMx/Jool/blob/584a846d09e891a0cd6342426b7a25c6478c90d6/src/mod/nat64/bib/pkt_queue.h#L77) (This counter is not decremented when a packet leaves the queue.)
142
- # TYPE jool_type1pkt gauge
143
- jool_type1pkt{hostname="home1.cooperlees.com"} 299.0
144
- # HELP jool_so_exists Translations cancelled: Packet was a Simultaneous Open retry. (Client was trying to punch a hole, and was being unnecessarily greedy.)
145
- # TYPE jool_so_exists gauge
146
- jool_so_exists{hostname="home1.cooperlees.com"} 1.0
147
- ```
148
-
149
- ## Grafana Dashbaord Example
150
-
151
- ![Grafana jool Dashboard Example](https://github.com/cooperlees/jool-exporter/blob/main/grafana_jool_example.png)
152
-
153
- ## Development
154
-
155
- We use Facebook's [ptr](https://github.com/facebookincubator/ptr) for testing.
156
-
157
- - `pip install ptr`
158
- - `cd .` # This repo
159
- - `ptr [-k]`
160
-
161
- It is driven by config in setup.py.
162
-
163
-
164
-
165
- Platform: UNKNOWN
166
- Classifier: Development Status :: 3 - Alpha
167
- Classifier: License :: OSI Approved :: BSD License
168
- Classifier: Programming Language :: Python :: 3
169
- Classifier: Programming Language :: Python :: 3 :: Only
170
- Classifier: Programming Language :: Python :: 3.8
171
- Classifier: Programming Language :: Python :: 3.9
172
- Requires-Python: >=3.8
173
- Description-Content-Type: text/markdown