mdbkit 0.6.1__tar.gz → 0.7.0__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.
- {mdbkit-0.6.1/mdbkit.egg-info → mdbkit-0.7.0}/PKG-INFO +90 -16
- mdbkit-0.6.1/PKG-INFO → mdbkit-0.7.0/README.md +88 -41
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/__init__.py +1 -1
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/cli.py +44 -0
- mdbkit-0.7.0/mdbkit/host.py +568 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/triage.py +29 -4
- mdbkit-0.6.1/README.md → mdbkit-0.7.0/mdbkit.egg-info/PKG-INFO +115 -14
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit.egg-info/SOURCES.txt +2 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/pyproject.toml +2 -2
- mdbkit-0.7.0/tests/test_host.py +166 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/LICENSE +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/advisor.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/analysis.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/audit.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/compare.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/demo.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/explain.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/filtering.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/ftdc.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/lab.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/oslog.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/parser.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/rebuild.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/render.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/report.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/scripts.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/serverstatus.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit/shelljson.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit.egg-info/dependency_links.txt +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit.egg-info/entry_points.txt +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit.egg-info/requires.txt +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/mdbkit.egg-info/top_level.txt +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/setup.cfg +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_demo_lab.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_explain.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_ftdc.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_mdbkit.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_oslog_serverstatus.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_real_servers.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_rebuild_report.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_render_e2e.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_triage.py +0 -0
- {mdbkit-0.6.1 → mdbkit-0.7.0}/tests/test_v060_hardening.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdbkit
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Offline toolkit for MongoDB 4.4 to 9.0 structured logs: slow-query shapes, index advice, incident triage, startup configuration audit, FTDC decoding. A spiritual successor to mtools' log tools.
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Offline toolkit for MongoDB 4.4 to 9.0 structured logs: slow-query shapes, index advice, incident triage, multi-instance host checks, startup configuration audit, FTDC decoding. A spiritual successor to mtools' log tools.
|
|
5
5
|
Author: Saqib Ameen Subhan
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/saqibameen86/mdbkit
|
|
@@ -439,6 +439,35 @@ Per-IP churn with first/last seen, plus an authenticated-users table showing
|
|
|
439
439
|
successful and failed logins per account and when each last authenticated —
|
|
440
440
|
the question that starts most access incidents.
|
|
441
441
|
|
|
442
|
+
### 7. Is this host running too many mongods for its memory?
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
mdbkit host /var/log/mongodb # every instance's log under here
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
== mdbkit host: 8 instance(s) on vm ==
|
|
450
|
+
last 1440 minutes of each log | 7.8 GiB RAM (this machine)
|
|
451
|
+
|
|
452
|
+
[CRIT] Cache sizes vs RAM: WiredTiger caches add up to 11.8 GiB, 150% of 7.8 GiB RAM (this machine).
|
|
453
|
+
[CRIT] Instances that crashed: 1 instance(s) started after an unclean stop (crash, kill -9 or OOM kill).
|
|
454
|
+
- vm:29021: 1 unclean start(s)
|
|
455
|
+
[WARN] Default cache size on a shared host: 3 of 8 instances run with the default WiredTiger cache (cacheSizeGB not set). [...]
|
|
456
|
+
|
|
457
|
+
instance set version role cache starts crashes slow ops slow time waiting worst first issue
|
|
458
|
+
-------- ---- ------- ---------- ------- ------ ------- -------- --------- ------- ----- --------------------------
|
|
459
|
+
vm:29021 rs02 8.0.32 SECONDARY 256 MiB 2 1 0 - - CRIT Process start(s) in window
|
|
460
|
+
vm:29030 - 8.0.32 standalone 512 MiB 1 0 9 472ms 0% WARN Collection scans
|
|
461
|
+
vm:29010 rs01 8.0.32 PRIMARY 3.4 GiB 1 0 3 271ms 0% WARN Collection scans
|
|
462
|
+
[...]
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
For hosts that run many mongods side by side, typically one member of each
|
|
466
|
+
of many replica sets. The usual failure is that every instance was left on
|
|
467
|
+
the default WiredTiger cache, which assumes the machine is its alone; the
|
|
468
|
+
caches add up to several times the RAM and the OOM killer picks off
|
|
469
|
+
instances. (Output above is from a real 8-instance test host.)
|
|
470
|
+
|
|
442
471
|
---
|
|
443
472
|
|
|
444
473
|
## Running it on a schedule
|
|
@@ -841,21 +870,65 @@ shutdown was clean, so mdbkit can tell even when the crash happened before
|
|
|
841
870
|
the log you are reading begins. The first election of a newly initiated
|
|
842
871
|
replica set is reported as INFO, not as instability.
|
|
843
872
|
|
|
844
|
-
**Hosts running several mongods.**
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
the host, `triage` uses the pid and dbPath
|
|
873
|
+
**Hosts running several mongods.** `triage` reads one instance's log; don't
|
|
874
|
+
pass several instances' logs to it, because several files are read as one
|
|
875
|
+
stream (that is for the rotated logs of one instance, or the members of one
|
|
876
|
+
replica set). For the whole host at once, use [`mdbkit host`](#mdbkit-host-logs).
|
|
877
|
+
When several mongods run on the host, `triage` uses the pid and dbPath the
|
|
878
|
+
log records (in its startup line, or at the top of a rotated file) to pick
|
|
849
879
|
the right process for its memory, uptime and disk checks, and when
|
|
850
880
|
`--oslog` shows an OOM kill it says whether the killed pid was this
|
|
851
881
|
instance or another one.
|
|
852
882
|
|
|
883
|
+
---
|
|
884
|
+
|
|
885
|
+
### `mdbkit host <logs...>`
|
|
886
|
+
|
|
887
|
+
One host running many mongod instances: one line per instance, and checks
|
|
888
|
+
that only make sense for the host as a whole.
|
|
889
|
+
|
|
890
|
+
| Option | Default | Description |
|
|
891
|
+
|---|---|---|
|
|
892
|
+
| `--window N` | 1440 | Analyze the last N minutes of each log; `0` = whole logs |
|
|
893
|
+
| `--ram SIZE` | | The host's memory (`64G`, `65536M`) when the logs were copied off it. On the host it is read from `/proc` |
|
|
894
|
+
| `--oslog FILE...` | | System log(s): each OOM kill is matched to the instance it killed |
|
|
895
|
+
| `--limit N` | all | Show only the N worst instances |
|
|
896
|
+
| `--exit-code` | | Exit 2 on CRIT, 1 on WARN, else 0 |
|
|
897
|
+
| `--json` | | Machine-readable output |
|
|
898
|
+
|
|
853
899
|
```bash
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
900
|
+
mdbkit host /var/log/mongodb # finds every *.log* below
|
|
901
|
+
mdbkit host /var/log/mongodb --oslog /var/log/syslog # who did the OOM killer hit?
|
|
902
|
+
mdbkit host "/mnt/copied/db7/*/mongod.log*" --ram 256G --limit 15
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
Give it files, globs or directories (searched three levels deep, never into
|
|
906
|
+
a data directory). Files are grouped into instances by the host and port the
|
|
907
|
+
log records, so rotated files join their instance even though they have no
|
|
908
|
+
startup line.
|
|
909
|
+
|
|
910
|
+
**Per instance:** replica set, version, role, WiredTiger cache size, starts
|
|
911
|
+
and crashes (unclean stops), slow operations and their total time, the share
|
|
912
|
+
of that time spent waiting (8.0+), and its worst finding from the same
|
|
913
|
+
detectors `triage` uses.
|
|
914
|
+
|
|
915
|
+
**For the host:**
|
|
916
|
+
|
|
917
|
+
- **Cache sizes vs RAM.** Each instance's cache comes from its own log
|
|
918
|
+
("Opening WiredTiger" states the size, even when it is the default). The
|
|
919
|
+
total is compared with the RAM: WARN above 60%, CRIT above 85%. These are
|
|
920
|
+
rules of thumb: MongoDB's single-instance default is about half the RAM,
|
|
921
|
+
leaving the rest to the OS file cache and each process's connections,
|
|
922
|
+
sorts and aggregations.
|
|
923
|
+
- **Default cache on a shared host.** Instances without `cacheSizeGB` each
|
|
924
|
+
assume the whole machine is theirs.
|
|
925
|
+
- **Crashes** across all instances, and with `--oslog`, every OOM kill
|
|
926
|
+
matched to the instance it hit by pid.
|
|
927
|
+
- **Startup warnings counted across instances.** Kernel and limit settings
|
|
928
|
+
belong to the host, so "Open-file limit is too low: 54 of 54 instances" is
|
|
929
|
+
one fix, not 54.
|
|
930
|
+
- **On the host itself:** instances with a log but no running mongod, and
|
|
931
|
+
running mongods whose logs were not given.
|
|
859
932
|
|
|
860
933
|
---
|
|
861
934
|
|
|
@@ -1286,6 +1359,11 @@ mdbkit export-script serverstatus > export_serverstatus.js
|
|
|
1286
1359
|
Terminal output is and will remain first-class — this tool is built for the
|
|
1287
1360
|
Linux box the database actually runs on.
|
|
1288
1361
|
|
|
1362
|
+
**Shipped in v0.7:** `mdbkit host`, for hosts running many mongods: one
|
|
1363
|
+
line per instance, cache sizes added up against RAM, crashes and OOM kills
|
|
1364
|
+
per instance, startup warnings counted across instances. Rotated logs are
|
|
1365
|
+
tied to their process.
|
|
1366
|
+
|
|
1289
1367
|
**Shipped in v0.6.1:** tested against real MongoDB 7.0, 8.0, 8.3 and 9.0
|
|
1290
1368
|
servers, with the bugs that turned up fixed; crash vs clean restart
|
|
1291
1369
|
detection; correct behaviour on hosts running many mongods.
|
|
@@ -1300,10 +1378,6 @@ shareable reports.
|
|
|
1300
1378
|
|
|
1301
1379
|
Next up, roughly in order:
|
|
1302
1380
|
|
|
1303
|
-
* **Hosts running many mongods.** One line per instance (health, restarts,
|
|
1304
|
-
slow time, startup warnings), the WiredTiger cache sizes of every instance
|
|
1305
|
-
added up against the host's RAM (54 instances on default settings would
|
|
1306
|
-
each claim about half of it), and each OOM kill matched to its instance.
|
|
1307
1381
|
* **Sharded clusters.** `mongos` logs are a different shape, and the classic
|
|
1308
1382
|
sharded failure — a query with no shard key fanning out to every shard — is
|
|
1309
1383
|
visible in the log. Also chunk migrations, balancer windows and jumbo
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: mdbkit
|
|
3
|
-
Version: 0.6.1
|
|
4
|
-
Summary: Offline toolkit for MongoDB 4.4 to 9.0 structured logs: slow-query shapes, index advice, incident triage, startup configuration audit, FTDC decoding. A spiritual successor to mtools' log tools.
|
|
5
|
-
Author: Saqib Ameen Subhan
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/saqibameen86/mdbkit
|
|
8
|
-
Project-URL: Repository, https://github.com/saqibameen86/mdbkit
|
|
9
|
-
Project-URL: Documentation, https://github.com/saqibameen86/mdbkit#readme
|
|
10
|
-
Project-URL: Issues, https://github.com/saqibameen86/mdbkit/issues
|
|
11
|
-
Project-URL: Changelog, https://github.com/saqibameen86/mdbkit/releases
|
|
12
|
-
Keywords: mongodb,mongodb-logs,logv2,mtools,mloginfo,mongod,slow-query,slow-query-log,log-analysis,log-parser,index-advisor,dba,sre,devops,ftdc,diagnostic-data,explain-plan,query-performance,database-performance,replica-set,wiredtiger,troubleshooting,incident-response
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: Environment :: Console
|
|
15
|
-
Classifier: Intended Audience :: System Administrators
|
|
16
|
-
Classifier: Intended Audience :: Developers
|
|
17
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Topic :: Database
|
|
20
|
-
Classifier: Topic :: System :: Systems Administration
|
|
21
|
-
Requires-Python: >=3.8
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
23
|
-
License-File: LICENSE
|
|
24
|
-
Provides-Extra: dev
|
|
25
|
-
Requires-Dist: pytest>=7; extra == "dev"
|
|
26
|
-
Dynamic: license-file
|
|
27
|
-
|
|
28
1
|
# mdbkit
|
|
29
2
|
|
|
30
3
|
[](https://github.com/saqibameen86/mdbkit/actions)
|
|
@@ -439,6 +412,35 @@ Per-IP churn with first/last seen, plus an authenticated-users table showing
|
|
|
439
412
|
successful and failed logins per account and when each last authenticated —
|
|
440
413
|
the question that starts most access incidents.
|
|
441
414
|
|
|
415
|
+
### 7. Is this host running too many mongods for its memory?
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
mdbkit host /var/log/mongodb # every instance's log under here
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
== mdbkit host: 8 instance(s) on vm ==
|
|
423
|
+
last 1440 minutes of each log | 7.8 GiB RAM (this machine)
|
|
424
|
+
|
|
425
|
+
[CRIT] Cache sizes vs RAM: WiredTiger caches add up to 11.8 GiB, 150% of 7.8 GiB RAM (this machine).
|
|
426
|
+
[CRIT] Instances that crashed: 1 instance(s) started after an unclean stop (crash, kill -9 or OOM kill).
|
|
427
|
+
- vm:29021: 1 unclean start(s)
|
|
428
|
+
[WARN] Default cache size on a shared host: 3 of 8 instances run with the default WiredTiger cache (cacheSizeGB not set). [...]
|
|
429
|
+
|
|
430
|
+
instance set version role cache starts crashes slow ops slow time waiting worst first issue
|
|
431
|
+
-------- ---- ------- ---------- ------- ------ ------- -------- --------- ------- ----- --------------------------
|
|
432
|
+
vm:29021 rs02 8.0.32 SECONDARY 256 MiB 2 1 0 - - CRIT Process start(s) in window
|
|
433
|
+
vm:29030 - 8.0.32 standalone 512 MiB 1 0 9 472ms 0% WARN Collection scans
|
|
434
|
+
vm:29010 rs01 8.0.32 PRIMARY 3.4 GiB 1 0 3 271ms 0% WARN Collection scans
|
|
435
|
+
[...]
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
For hosts that run many mongods side by side, typically one member of each
|
|
439
|
+
of many replica sets. The usual failure is that every instance was left on
|
|
440
|
+
the default WiredTiger cache, which assumes the machine is its alone; the
|
|
441
|
+
caches add up to several times the RAM and the OOM killer picks off
|
|
442
|
+
instances. (Output above is from a real 8-instance test host.)
|
|
443
|
+
|
|
442
444
|
---
|
|
443
445
|
|
|
444
446
|
## Running it on a schedule
|
|
@@ -841,21 +843,65 @@ shutdown was clean, so mdbkit can tell even when the crash happened before
|
|
|
841
843
|
the log you are reading begins. The first election of a newly initiated
|
|
842
844
|
replica set is reported as INFO, not as instability.
|
|
843
845
|
|
|
844
|
-
**Hosts running several mongods.**
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
the host, `triage` uses the pid and dbPath
|
|
846
|
+
**Hosts running several mongods.** `triage` reads one instance's log; don't
|
|
847
|
+
pass several instances' logs to it, because several files are read as one
|
|
848
|
+
stream (that is for the rotated logs of one instance, or the members of one
|
|
849
|
+
replica set). For the whole host at once, use [`mdbkit host`](#mdbkit-host-logs).
|
|
850
|
+
When several mongods run on the host, `triage` uses the pid and dbPath the
|
|
851
|
+
log records (in its startup line, or at the top of a rotated file) to pick
|
|
849
852
|
the right process for its memory, uptime and disk checks, and when
|
|
850
853
|
`--oslog` shows an OOM kill it says whether the killed pid was this
|
|
851
854
|
instance or another one.
|
|
852
855
|
|
|
856
|
+
---
|
|
857
|
+
|
|
858
|
+
### `mdbkit host <logs...>`
|
|
859
|
+
|
|
860
|
+
One host running many mongod instances: one line per instance, and checks
|
|
861
|
+
that only make sense for the host as a whole.
|
|
862
|
+
|
|
863
|
+
| Option | Default | Description |
|
|
864
|
+
|---|---|---|
|
|
865
|
+
| `--window N` | 1440 | Analyze the last N minutes of each log; `0` = whole logs |
|
|
866
|
+
| `--ram SIZE` | | The host's memory (`64G`, `65536M`) when the logs were copied off it. On the host it is read from `/proc` |
|
|
867
|
+
| `--oslog FILE...` | | System log(s): each OOM kill is matched to the instance it killed |
|
|
868
|
+
| `--limit N` | all | Show only the N worst instances |
|
|
869
|
+
| `--exit-code` | | Exit 2 on CRIT, 1 on WARN, else 0 |
|
|
870
|
+
| `--json` | | Machine-readable output |
|
|
871
|
+
|
|
853
872
|
```bash
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
873
|
+
mdbkit host /var/log/mongodb # finds every *.log* below
|
|
874
|
+
mdbkit host /var/log/mongodb --oslog /var/log/syslog # who did the OOM killer hit?
|
|
875
|
+
mdbkit host "/mnt/copied/db7/*/mongod.log*" --ram 256G --limit 15
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
Give it files, globs or directories (searched three levels deep, never into
|
|
879
|
+
a data directory). Files are grouped into instances by the host and port the
|
|
880
|
+
log records, so rotated files join their instance even though they have no
|
|
881
|
+
startup line.
|
|
882
|
+
|
|
883
|
+
**Per instance:** replica set, version, role, WiredTiger cache size, starts
|
|
884
|
+
and crashes (unclean stops), slow operations and their total time, the share
|
|
885
|
+
of that time spent waiting (8.0+), and its worst finding from the same
|
|
886
|
+
detectors `triage` uses.
|
|
887
|
+
|
|
888
|
+
**For the host:**
|
|
889
|
+
|
|
890
|
+
- **Cache sizes vs RAM.** Each instance's cache comes from its own log
|
|
891
|
+
("Opening WiredTiger" states the size, even when it is the default). The
|
|
892
|
+
total is compared with the RAM: WARN above 60%, CRIT above 85%. These are
|
|
893
|
+
rules of thumb: MongoDB's single-instance default is about half the RAM,
|
|
894
|
+
leaving the rest to the OS file cache and each process's connections,
|
|
895
|
+
sorts and aggregations.
|
|
896
|
+
- **Default cache on a shared host.** Instances without `cacheSizeGB` each
|
|
897
|
+
assume the whole machine is theirs.
|
|
898
|
+
- **Crashes** across all instances, and with `--oslog`, every OOM kill
|
|
899
|
+
matched to the instance it hit by pid.
|
|
900
|
+
- **Startup warnings counted across instances.** Kernel and limit settings
|
|
901
|
+
belong to the host, so "Open-file limit is too low: 54 of 54 instances" is
|
|
902
|
+
one fix, not 54.
|
|
903
|
+
- **On the host itself:** instances with a log but no running mongod, and
|
|
904
|
+
running mongods whose logs were not given.
|
|
859
905
|
|
|
860
906
|
---
|
|
861
907
|
|
|
@@ -1286,6 +1332,11 @@ mdbkit export-script serverstatus > export_serverstatus.js
|
|
|
1286
1332
|
Terminal output is and will remain first-class — this tool is built for the
|
|
1287
1333
|
Linux box the database actually runs on.
|
|
1288
1334
|
|
|
1335
|
+
**Shipped in v0.7:** `mdbkit host`, for hosts running many mongods: one
|
|
1336
|
+
line per instance, cache sizes added up against RAM, crashes and OOM kills
|
|
1337
|
+
per instance, startup warnings counted across instances. Rotated logs are
|
|
1338
|
+
tied to their process.
|
|
1339
|
+
|
|
1289
1340
|
**Shipped in v0.6.1:** tested against real MongoDB 7.0, 8.0, 8.3 and 9.0
|
|
1290
1341
|
servers, with the bugs that turned up fixed; crash vs clean restart
|
|
1291
1342
|
detection; correct behaviour on hosts running many mongods.
|
|
@@ -1300,10 +1351,6 @@ shareable reports.
|
|
|
1300
1351
|
|
|
1301
1352
|
Next up, roughly in order:
|
|
1302
1353
|
|
|
1303
|
-
* **Hosts running many mongods.** One line per instance (health, restarts,
|
|
1304
|
-
slow time, startup warnings), the WiredTiger cache sizes of every instance
|
|
1305
|
-
added up against the host's RAM (54 instances on default settings would
|
|
1306
|
-
each claim about half of it), and each OOM kill matched to its instance.
|
|
1307
1354
|
* **Sharded clusters.** `mongos` logs are a different shape, and the classic
|
|
1308
1355
|
sharded failure — a query with no shard key fanning out to every shard — is
|
|
1309
1356
|
visible in the log. Also chunk migrations, balancer windows and jumbo
|
|
@@ -499,6 +499,29 @@ def cmd_audit(args) -> int:
|
|
|
499
499
|
return 0
|
|
500
500
|
|
|
501
501
|
|
|
502
|
+
def cmd_host(args) -> int:
|
|
503
|
+
from .host import render_host, run_host, worst_severity
|
|
504
|
+
|
|
505
|
+
def progress(done, total):
|
|
506
|
+
if total > 3:
|
|
507
|
+
print("\rreading instance %d/%d" % (done, total),
|
|
508
|
+
end="" if done < total else "\n", file=sys.stderr)
|
|
509
|
+
try:
|
|
510
|
+
rep = run_host(args.logs, window_min=args.window, ram=args.ram,
|
|
511
|
+
oslog=args.oslog, progress=progress)
|
|
512
|
+
except ValueError as exc:
|
|
513
|
+
print("error: %s" % exc, file=sys.stderr)
|
|
514
|
+
return 2
|
|
515
|
+
if args.json:
|
|
516
|
+
print(dump_json(rep.to_dict()))
|
|
517
|
+
else:
|
|
518
|
+
print(render_host(rep, limit=args.limit))
|
|
519
|
+
if args.exit_code:
|
|
520
|
+
sev = worst_severity(rep)
|
|
521
|
+
return 2 if sev == "CRIT" else (1 if sev == "WARN" else 0)
|
|
522
|
+
return 0
|
|
523
|
+
|
|
524
|
+
|
|
502
525
|
def cmd_compare(args) -> int:
|
|
503
526
|
from .compare import aggregate_file, compare
|
|
504
527
|
from .render import render_compare
|
|
@@ -805,6 +828,27 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
805
828
|
sp.add_argument("--json", action="store_true")
|
|
806
829
|
sp.set_defaults(func=cmd_audit)
|
|
807
830
|
|
|
831
|
+
sp = sub.add_parser("host",
|
|
832
|
+
help="a host running many mongods: one line per "
|
|
833
|
+
"instance, cache sizes vs RAM, crashes, OOM kills")
|
|
834
|
+
sp.add_argument("logs", nargs="+", metavar="LOG",
|
|
835
|
+
help="every instance's log: files, globs, or directories "
|
|
836
|
+
"(searched three levels deep, e.g. /var/log/mongodb)")
|
|
837
|
+
sp.add_argument("--window", type=NON_NEG, default=1440, metavar="MINUTES",
|
|
838
|
+
help="analyze the last N minutes of each log "
|
|
839
|
+
"(default 1440 = 24h; 0 = whole logs)")
|
|
840
|
+
sp.add_argument("--ram", metavar="SIZE",
|
|
841
|
+
help="the host's memory, e.g. 64G, when the logs were "
|
|
842
|
+
"copied off it (on the host it is read from /proc)")
|
|
843
|
+
sp.add_argument("--oslog", nargs="+", metavar="FILE",
|
|
844
|
+
help="system log(s) to match OOM kills to instances")
|
|
845
|
+
sp.add_argument("--limit", type=NON_NEG, default=0, metavar="N",
|
|
846
|
+
help="show only the N worst instances (default all)")
|
|
847
|
+
sp.add_argument("--exit-code", action="store_true",
|
|
848
|
+
help="exit 2 on CRIT, 1 on WARN, else 0")
|
|
849
|
+
sp.add_argument("--json", action="store_true")
|
|
850
|
+
sp.set_defaults(func=cmd_host)
|
|
851
|
+
|
|
808
852
|
sp = sub.add_parser("oslog",
|
|
809
853
|
help="scan a system log for OOM kills, fd limits, "
|
|
810
854
|
"I/O errors and service restarts")
|