Skip to content

Commit 64557bd

Browse files
authored
Update documentation a bit (#24)
* Update documentation a bit * Formatting * Linebreaks * Reformat example output as code block
1 parent cf51ae1 commit 64557bd

File tree

2 files changed

+136
-53
lines changed

2 files changed

+136
-53
lines changed

README.md

Lines changed: 135 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,96 +22,178 @@ It currently prints:
2222
- Reverse Lookup for those IP addresses (IP Address => List of hostnames)
2323
- Forward lookup for those hostnames (Hostname => List of IP addresses)
2424

25-
Here is an example of what it looks like on my Laptop:
25+
Here is an example of what it looks like on my virtual machine:
26+
27+
```text
28+
2025-02-03T11:37:47.420479Z INFO containerdebug: stackable_operator::utils::logging: Starting
29+
2025-02-03T11:37:47.420521Z INFO containerdebug: stackable_operator::utils::logging: This is version 0.1.1 (Git information: 0.1.1-1-gcf51ae1), built for x86_64-unknown-linux-gnu by rustc 1.84.1 (e71f9a9a9 2025-01-27) at Tue, 1 Jan 1980 00:00:00 +0000
30+
2025-02-03T11:37:47.420544Z INFO containerdebug:SystemInformation::init: containerdebug::system_information: initializing
31+
2025-02-03T11:37:47.426065Z INFO containerdebug:SystemInformation::init: containerdebug::system_information: init finished
32+
2025-02-03T11:37:47.426135Z INFO containerdebug:SystemInformation::collect: containerdebug::system_information: Starting data collection
33+
2025-02-03T11:37:47.426693Z INFO containerdebug:SystemInformation::collect:Resources::collect: containerdebug::system_information::resources: cpus cpus.physical=8 cpus.cores.physical=8
34+
2025-02-03T11:37:47.426727Z INFO containerdebug:SystemInformation::collect:Resources::collect: containerdebug::system_information::resources: memory memory.total=24604889088 memory.free=17235124224 memory.available=22974955520 memory.used=1629933568
35+
2025-02-03T11:37:47.426746Z INFO containerdebug:SystemInformation::collect:Resources::collect: containerdebug::system_information::resources: swap swap.total=0 swap.free=0 swap.used=0
36+
2025-02-03T11:37:47.426857Z INFO containerdebug:SystemInformation::collect:Resources::collect: containerdebug::system_information::resources: not in a cgroup
37+
2025-02-03T11:37:47.426940Z INFO containerdebug:SystemInformation::collect:OperatingSystem::collect: containerdebug::system_information::os: operating system os.name="NixOS" os.kernel.version="6.6.46" os.version="Linux 24.11 NixOS" os.host_name="nixos2" os.cpu_arch="x86_64"
38+
2025-02-03T11:37:47.427031Z INFO containerdebug:SystemInformation::collect:User::collect_current: containerdebug::system_information::user: current user user.name="nat" user.uid="Uid(1000)" user.gid="Uid(1000)"
39+
2025-02-03T11:37:47.427436Z INFO containerdebug:SystemInformation::collect:Disk::collect_all: containerdebug::system_information::disk: found disk disk.mount_point="/" disk.name="/dev/sda2" disk.space.total=106298343424 disk.space.available=72663478272
40+
2025-02-03T11:37:47.427483Z INFO containerdebug:SystemInformation::collect:Disk::collect_all: containerdebug::system_information::disk: found disk disk.mount_point="/nix/store" disk.name="/dev/sda2" disk.space.total=106298343424 disk.space.available=72663478272
41+
2025-02-03T11:37:47.427499Z INFO containerdebug:SystemInformation::collect:Disk::collect_all: containerdebug::system_information::disk: found disk disk.mount_point="/boot" disk.name="/dev/sda1" disk.space.total=1071624192 disk.space.available=1022820352
42+
2025-02-03T11:37:47.428771Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="lo" network.interface.address=127.0.0.1
43+
2025-02-03T11:37:47.428821Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="enp1s0" network.interface.address=192.168.122.138
44+
2025-02-03T11:37:47.428836Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="br-82bbc663b8a3" network.interface.address=172.18.0.1
45+
2025-02-03T11:37:47.428847Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="docker0" network.interface.address=172.17.0.1
46+
2025-02-03T11:37:47.428861Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="lo" network.interface.address=::1
47+
2025-02-03T11:37:47.428874Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="enp1s0" network.interface.address=fe80::5054:ff:fe91:5652
48+
2025-02-03T11:37:47.428885Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: found network interface network.interface.name="br-82bbc663b8a3" network.interface.address=fc00:f853:ccd:e793::1
49+
2025-02-03T11:37:47.428910Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: ip addresses network.addresses.ip={127.0.0.1, 172.17.0.1, 172.18.0.1, 192.168.122.138, ::1, fc00:f853:ccd:e793::1, fe80::5054:ff:fe91:5652}
50+
2025-02-03T11:37:47.429002Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed reverse DNS lookup for IP ip=127.0.0.1 hostnames=["localhost."]
51+
2025-02-03T11:37:47.437343Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed reverse DNS lookup for IP ip=172.17.0.1 hostnames=["nixos2.", "nixos2.local."]
52+
2025-02-03T11:37:47.439911Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed reverse DNS lookup for IP ip=172.18.0.1 hostnames=["nixos2.", "nixos2.local."]
53+
2025-02-03T11:37:47.440526Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed reverse DNS lookup for IP ip=192.168.122.138 hostnames=["nixos2.kvm."]
54+
2025-02-03T11:37:47.440678Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed reverse DNS lookup for IP ip=::1 hostnames=["localhost."]
55+
2025-02-03T11:37:47.441339Z WARN containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: reverse DNS lookup failed ip=fc00:f853:ccd:e793::1 error=no record found for Query { name: Name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.9.7.e.d.c.c.0.3.5.8.f.0.0.c.f.ip6.arpa."), query_type: PTR, query_class: IN }
56+
2025-02-03T11:37:47.442068Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed reverse DNS lookup for IP ip=fe80::5054:ff:fe91:5652 hostnames=["nixos2."]
57+
2025-02-03T11:37:47.442149Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: hostnames network.addresses.hostname={"localhost.", "nixos2.", "nixos2.kvm.", "nixos2.local."}
58+
2025-02-03T11:37:47.442300Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed forward DNS lookup for hostname hostname="localhost." ips=[127.0.0.1]
59+
2025-02-03T11:37:47.442755Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed forward DNS lookup for hostname hostname="nixos2." ips=[127.0.0.2]
60+
2025-02-03T11:37:47.443144Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed forward DNS lookup for hostname hostname="nixos2.kvm." ips=[127.0.0.2]
61+
2025-02-03T11:37:47.443628Z INFO containerdebug:SystemInformation::collect:SystemNetworkInfo::collect: containerdebug::system_information::network: performed forward DNS lookup for hostname hostname="nixos2.local." ips=[192.168.122.138, 172.18.0.1, 172.17.0.1]
62+
2025-02-03T11:37:47.443837Z INFO containerdebug:SystemInformation::collect: containerdebug::system_information: Data collection finished
63+
```
64+
65+
## Log output
66+
67+
The log-style output above is written to stdout.
68+
It can also be output to files by setting the environment variable
69+
`CONTAINERDEBUG_LOG_DIRECTORY=/path/to/logs/directory`.
70+
71+
This file output will be output as _JSON-formatted logs_, in order to
72+
ease ingestion into a log aggregation system (such as
73+
[Vector](https://vector.dev/)).
74+
These log files will also automatically be rotated over time.
75+
76+
## Data output
77+
78+
The containerdebug tool can write its collected data into a JSON dump,
79+
by setting the `--output=/path/to/dump.json` flag.
80+
81+
This is intended to be queried with tools like [jq](https://jqlang.org/).
82+
However, note that the output format is currently not stable, and may
83+
change over time.
84+
85+
For example:
2686

2787
```json
2888
{
29-
"cpu_count": 8,
30-
"physical_core_count": 4,
31-
"total_memory": 50161664000,
32-
"free_memory": 2400735232,
33-
"available_memory": 35192512512,
34-
"used_memory": 14969151488,
35-
"total_swap": 53687087104,
36-
"free_swap": 53687087104,
37-
"used_swap": 0,
38-
"total_memory_cgroup": null,
39-
"free_memory_cgroup": null,
40-
"free_swap_cgroup": null,
41-
"system_name": "Arch Linux",
42-
"kernel_version": "6.7.8-arch1-1",
43-
"os_version": "Linux rolling Arch Linux",
44-
"host_name": "lars-laptop",
45-
"cpu_arch": "x86_64",
89+
"resources": {
90+
"cpu_count": 8,
91+
"physical_core_count": 8,
92+
"total_memory": 24604889088,
93+
"free_memory": 17228574720,
94+
"available_memory": 22974619648,
95+
"used_memory": 1630269440,
96+
"total_swap": 0,
97+
"free_swap": 0,
98+
"used_swap": 0,
99+
"total_memory_cgroup": null,
100+
"free_memory_cgroup": null,
101+
"free_swap_cgroup": null
102+
},
103+
"os": {
104+
"name": "NixOS",
105+
"kernel_version": "6.6.46",
106+
"version": "Linux 24.11 NixOS",
107+
"host_name": "nixos2",
108+
"cpu_arch": "x86_64"
109+
},
110+
"current_user": {
111+
"name": "nat",
112+
"uid": "1000",
113+
"gid": "100"
114+
},
46115
"disks": [
47116
{
117+
"name": "/dev/sda2",
48118
"mount_point": "/",
49-
"total_space": 754416877568,
50-
"available_space": 55915364352
51-
},
52-
{
53-
"mount_point": "/home",
54-
"total_space": 754416877568,
55-
"available_space": 55915364352
119+
"total_space": 106298343424,
120+
"available_space": 72267354112
56121
},
57122
{
58-
"mount_point": "/var/swap",
59-
"total_space": 754416877568,
60-
"available_space": 55915364352
123+
"name": "/dev/sda2",
124+
"mount_point": "/nix/store",
125+
"total_space": 106298343424,
126+
"available_space": 72267354112
61127
},
62128
{
129+
"name": "/dev/sda1",
63130
"mount_point": "/boot",
64-
"total_space": 2095079424,
65-
"available_space": 1896505344
131+
"total_space": 1071624192,
132+
"available_space": 1022820352
66133
}
67134
],
68-
"network_information": {
69-
"network_interfaces": {
70-
"wlan0": [
71-
"192.168.1.23",
72-
"fe80::90bf:60ff:fe78:836a"
135+
"network": {
136+
"interfaces": {
137+
"enp1s0": [
138+
"192.168.122.138",
139+
"fe80::5054:ff:fe91:5652"
73140
],
74141
"lo": [
75142
"127.0.0.1",
76143
"::1"
77144
],
78-
"virbr0": [
79-
"192.168.122.1"
145+
"br-82bbc663b8a3": [
146+
"172.18.0.1",
147+
"fc00:f853:ccd:e793::1"
148+
],
149+
"docker0": [
150+
"172.17.0.1"
80151
]
81152
},
82153
"reverse_lookups": {
83-
"192.168.1.23": [
84-
"lars-laptop.localdomain."
85-
],
86-
"192.168.122.1": [
87-
"lars-laptop.",
88-
"lars-laptop.local."
154+
"fe80::5054:ff:fe91:5652": [
155+
"nixos2."
89156
],
90157
"127.0.0.1": [
91158
"localhost."
92159
],
160+
"192.168.122.138": [
161+
"nixos2.kvm."
162+
],
93163
"::1": [
94164
"localhost."
95165
],
96-
"fe80::90bf:60ff:fe78:836a": [
97-
"lars-laptop."
166+
"172.17.0.1": [
167+
"nixos2.",
168+
"nixos2.local."
169+
],
170+
"172.18.0.1": [
171+
"nixos2.",
172+
"nixos2.local."
98173
]
99174
},
100175
"forward_lookups": {
101-
"lars-laptop.": [
102-
"127.0.0.1"
176+
"nixos2.kvm.": [
177+
"127.0.0.2"
103178
],
104-
"lars-laptop.local.": [
105-
"192.168.1.23",
106-
"192.168.122.1"
179+
"nixos2.": [
180+
"127.0.0.2"
107181
],
108-
"localhost.": [
109-
"127.0.0.1"
182+
"nixos2.local.": [
183+
"192.168.122.138",
184+
"172.18.0.1",
185+
"172.17.0.1"
110186
],
111-
"lars-laptop.localdomain.": [
187+
"localhost.": [
112188
"127.0.0.1"
113189
]
114190
}
115191
}
116192
}
117193
```
194+
195+
## Continuous mode
196+
197+
If given the `--loop` flag, containerdebug will stay in the background and
198+
re-run on a fixed interval. The default interval is `30m` (every 30 minutes), but
199+
it can be customized as desired (e.g. `--loop=30s`).

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct Opts {
2323
)]
2424
loop_interval: Option<stackable_operator::time::Duration>,
2525

26+
/// Write collected information to OUTPUT as JSON
2627
#[clap(long, short = 'o')]
2728
output: Option<PathBuf>,
2829

0 commit comments

Comments
 (0)