mdbkit 0.5.5__tar.gz → 0.6.1__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.
Files changed (42) hide show
  1. {mdbkit-0.5.5 → mdbkit-0.6.1}/PKG-INFO +239 -44
  2. {mdbkit-0.5.5 → mdbkit-0.6.1}/README.md +237 -42
  3. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/__init__.py +1 -1
  4. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/advisor.py +4 -4
  5. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/analysis.py +180 -22
  6. mdbkit-0.6.1/mdbkit/audit.py +297 -0
  7. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/cli.py +103 -21
  8. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/demo.py +85 -9
  9. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/explain.py +5 -5
  10. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/filtering.py +3 -3
  11. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/ftdc.py +44 -12
  12. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/lab.py +215 -58
  13. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/oslog.py +23 -9
  14. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/parser.py +110 -16
  15. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/render.py +170 -13
  16. mdbkit-0.6.1/mdbkit/scripts.py +123 -0
  17. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/serverstatus.py +30 -26
  18. mdbkit-0.6.1/mdbkit/shelljson.py +262 -0
  19. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/triage.py +392 -47
  20. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit.egg-info/PKG-INFO +239 -44
  21. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit.egg-info/SOURCES.txt +5 -1
  22. {mdbkit-0.5.5 → mdbkit-0.6.1}/pyproject.toml +2 -2
  23. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_demo_lab.py +2 -1
  24. mdbkit-0.6.1/tests/test_real_servers.py +362 -0
  25. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_triage.py +4 -2
  26. mdbkit-0.6.1/tests/test_v060_hardening.py +706 -0
  27. mdbkit-0.5.5/mdbkit/scripts.py +0 -83
  28. {mdbkit-0.5.5 → mdbkit-0.6.1}/LICENSE +0 -0
  29. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/compare.py +0 -0
  30. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/rebuild.py +0 -0
  31. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit/report.py +0 -0
  32. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit.egg-info/dependency_links.txt +0 -0
  33. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit.egg-info/entry_points.txt +0 -0
  34. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit.egg-info/requires.txt +0 -0
  35. {mdbkit-0.5.5 → mdbkit-0.6.1}/mdbkit.egg-info/top_level.txt +0 -0
  36. {mdbkit-0.5.5 → mdbkit-0.6.1}/setup.cfg +0 -0
  37. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_explain.py +0 -0
  38. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_ftdc.py +0 -0
  39. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_mdbkit.py +0 -0
  40. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_oslog_serverstatus.py +0 -0
  41. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_rebuild_report.py +0 -0
  42. {mdbkit-0.5.5 → mdbkit-0.6.1}/tests/test_render_e2e.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdbkit
3
- Version: 0.5.5
4
- Summary: Offline toolkit for MongoDB 4.4+ structured logs: log analysis, slow-query shapes, connection churn, and deterministic index advice. A spiritual successor to mtools' log tools.
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
5
  Author: Saqib Ameen Subhan
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/saqibameen86/mdbkit
@@ -33,8 +33,11 @@ Dynamic: license-file
33
33
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
34
34
 
35
35
  **An offline toolkit for MongoDB structured logs** — slow-query analysis,
36
- deterministic index advice, incident triage, and diagnostic-data decoding.
37
- For MongoDB 4.4 – 8.0, from the terminal, without connecting to anything.
36
+ deterministic index advice, incident triage, a startup configuration audit,
37
+ and diagnostic-data decoding. For MongoDB 4.4 through 8.x and 9.0, from the
38
+ terminal, without connecting to anything.
39
+ **[Tested against real MongoDB 9.0.2, 8.3.11, 8.0.32 and 7.0.43](#compatibility)**
40
+ (October 2026).
38
41
 
39
42
  A spiritual successor to mtools' log tools, which never learned to read the
40
43
  JSON log format introduced in 4.4.
@@ -64,6 +67,7 @@ mdbkit demo --with-extras -o demo.log # a log + indexes.json, schema.json, e
64
67
  mdbkit loginfo demo.log # what is in this log?
65
68
  mdbkit queries demo.log # which query shapes cost the most?
66
69
  mdbkit triage demo.log --window 0 # what went wrong, and when?
70
+ mdbkit audit demo.log # what did mongod warn about at startup?
67
71
  mdbkit connections demo.log # who connected, and did anyone fail to?
68
72
  mdbkit advise demo.log --indexes indexes.json --schema schema.json
69
73
  mdbkit explain explain.json # read a saved explain plan
@@ -74,11 +78,13 @@ election, an index build, five failed logins from a service account, and an
74
78
  aggregation burning 25 million document reads to return 261 documents — then
75
79
  `advise` tells you which index fixes it.
76
80
 
77
- Output is deterministic: the same `--seed` always produces the same log, so a
78
- demo behaves identically every time. Scenarios are `incident`, `healthy` (the
81
+ Output is deterministic: the same `--seed` produces the same log, byte for
82
+ byte, on any machine and any Python version, so a demo behaves identically
83
+ every time. (Before 0.6.0 this held only within one Python process; across
84
+ runs some identifiers changed. Fixed.) Scenarios are `incident`, `healthy` (the
79
85
  control case — useful for seeing what "nothing wrong" looks like) and `mixed`.
80
86
 
81
- Ready for a real server? Jump to [the workflows](#the-four-questions-it-answers).
87
+ Ready for a real server? Jump to [the workflows](#the-questions-it-answers).
82
88
 
83
89
  ---
84
90
 
@@ -103,7 +109,7 @@ codebase specifically so that you can:
103
109
  ```bash
104
110
  # 1. No network, no shell-outs, no eval anywhere in the analysis code
105
111
  pip show -f mdbkit | head -3
106
- grep -rn "socket\|urllib\|requests\|http\|eval(\|exec(" $(python -c "import mdbkit,os;print(os.path.dirname(mdbkit.__file__))")
112
+ grep -rn --include='*.py' "socket\|urllib\|requests\|http\|eval(\|exec(" $(python -c "import mdbkit,os;print(os.path.dirname(mdbkit.__file__))")
107
113
 
108
114
  # 2. Confirm it has no dependencies
109
115
  pip show mdbkit | grep Requires
@@ -112,9 +118,10 @@ pip show mdbkit | grep Requires
112
118
  strace -f -e trace=network mdbkit queries mongod.log 2>&1 | grep -c socket
113
119
  ```
114
120
 
115
- The grep returns nothing for every analysis module. The only file that starts
116
- a process is `lab.py`, which exists to create a *throwaway test cluster* and
117
- is documented as an explicit exception below.
121
+ The grep matches exactly one file, `lab.py`: before it starts a *throwaway
122
+ test cluster* it tries to bind `127.0.0.1:<port>` to check the port is free.
123
+ That is also the only file that starts a process. Every analysis module comes
124
+ back clean. The lab is documented as an explicit exception below.
118
125
 
119
126
  **What it does read:** the log file you point it at; optionally
120
127
  `diagnostic.data` (metrics only, never documents); optionally `indexes.json`
@@ -257,7 +264,50 @@ updates — upgrades are always explicit.
257
264
 
258
265
  ---
259
266
 
260
- ## The four questions it answers
267
+ ## Compatibility
268
+
269
+ **Tested against (October 2026):** MongoDB **9.0.2**, **8.3.11**, **8.0.32**
270
+ (LTS) and **7.0.43** (LTS), the newest release in each series at the time.
271
+ mdbkit reads the structured JSON log format, so anything from **4.4** onwards
272
+ works; 4.2 and earlier wrote plain text logs and are not supported.
273
+
274
+ | MongoDB | What mdbkit uses from it |
275
+ |---|---|
276
+ | 4.4 – 7.0 | Everything except the 8.x-only fields below |
277
+ | 8.0 | `workingMillis` (time executing, as distinct from waiting), `queues.execution.totalTimeQueuedMicros` (ticket queue time), `queryShapeHash` (usable with `setQuerySettings`), `planCacheShapeHash`, the 8.0 transparent-huge-page guidance |
278
+ | 8.1+ | `<stage>Spills` / `<stage>SpilledBytes` (disk spills per stage) |
279
+ | 8.3+ | "Slow in-progress query" lines (id 1794200, component `SLOWPROG`), logged by default for operations still running after 5 s (`--defaultSlowInProgMS`), and `peakTrackedMemBytes` |
280
+ | 9.0 | Same log fields as 8.3. Adds a few fields mdbkit does not use yet (`delinquencyInfo`, `queues.ingress`) |
281
+
282
+ When a field is missing because the log predates it, that part of the output
283
+ is left out. It is never guessed. FTDC decoding and `serverstatus` read
284
+ concurrency tickets from either the older `wiredTiger.concurrentTransactions`
285
+ or the newer `queues.execution` layout.
286
+
287
+ **How it was tested.** Official MongoDB builds of each version were run with
288
+ `mdbkit lab` (a three-node replica set and a standalone), seeded, and put
289
+ through a workload built to produce every field above: unindexed queries,
290
+ sorts and groups forced to spill to disk, writes blocked behind `fsyncLock` so
291
+ they wait rather than work, long-running server-side JavaScript, a clean
292
+ restart and a `kill -9`. Every mdbkit command was then run on the resulting
293
+ logs, `diagnostic.data`, serverStatus and explain output and `getLog`
294
+ captures, and compared with what the server actually did. Trimmed copies of
295
+ that output are in [`tests/fixtures/real/`](tests/fixtures/real/) and run with
296
+ every test.
297
+
298
+ > **Correction.** The 0.6.0 README and release notes said "last checked
299
+ > against 9.0.2, 8.3.13, 8.0.34 and 7.0.45". Three of those version numbers
300
+ > were wrong: MongoDB's release index has no 8.3.13, 8.0.34 or 7.0.45. That
301
+ > release was also checked against release notes and server source only, not
302
+ > a running server. Testing against real servers in 0.6.1 found several bugs
303
+ > 0.6.0 had missed (see the release notes).
304
+
305
+ If mdbkit misreads a line from your deployment, please
306
+ [open an issue](../../issues) with the line (redact as you like).
307
+
308
+ ---
309
+
310
+ ## The questions it answers
261
311
 
262
312
  Every command reads files or stdin and accepts several files or a glob, so
263
313
  rotated logs work as one stream: `mdbkit queries "mongod.log*"`.
@@ -272,7 +322,13 @@ mdbkit queries mongod.log --shape 1 # full detail on one shape
272
322
 
273
323
  `cumMs` is time summed across **all** occurrences of a shape, not one query.
274
324
  `scan` is documents examined per document returned — `1:1` is healthy,
275
- `98889:1` is a missing index. `plan` shows what MongoDB actually chose.
325
+ `98889:1` is a missing index. `plan` shows what MongoDB actually chose, with
326
+ `+SPILL` when the sort or group overflowed to disk.
327
+
328
+ On MongoDB 8.0+ mdbkit also separates **executing** from **waiting**. A
329
+ query that took 2 seconds but worked for 200 ms is not an index problem. It
330
+ was queued behind tickets, locks or flow control, and adding an index will
331
+ not help.
276
332
 
277
333
  ### 2. What index would fix it?
278
334
 
@@ -281,7 +337,7 @@ mdbkit queries mongod.log --shape 1 # full detail on one shape
281
337
  mdbkit export-script indexes > export_indexes.js
282
338
  mdbkit export-script schema > export_schema.js
283
339
 
284
- mongosh --quiet --host your_db_host --port 27017 \
340
+ mongosh --quiet "mongodb://your_db_host:27017/" \
285
341
  --username your_username --password your_password \
286
342
  --authenticationDatabase admin \
287
343
  --eval "$(cat export_indexes.js)" > indexes.json # repeat for schema
@@ -302,9 +358,11 @@ mdbkit triage mongod.log --report incident.html # something to attach to a ticke
302
358
  ```
303
359
 
304
360
  Cluster health, elections, connection storms, hot collections, index builds,
305
- error clusters, slow-query peaks — plus disk, memory, CPU and FTDC metrics
306
- when run on the database host. Every finding ends with the next command to
307
- run.
361
+ error clusters, slow-query peaks, startup misconfiguration, time spent
362
+ waiting rather than working (8.0+), and still-running operations (8.3+) —
363
+ plus disk, memory, CPU and FTDC metrics when run on the database host. Every
364
+ finding ends with the next command to run. A shutdown followed by the server
365
+ listening again is reported as a restart (WARN), not an outage (CRIT).
308
366
 
309
367
  ### 4. Did my change actually help?
310
368
 
@@ -324,7 +382,28 @@ IMPROVED
324
382
  The natural follow-up to `advise`: you created the index, a day passed, and
325
383
  this tells you whether it worked.
326
384
 
327
- ### 5. Why did it die? (and what does serverStatus say?)
385
+ ### 5. Is this server configured properly?
386
+
387
+ ```bash
388
+ mdbkit audit /var/log/mongodb/mongod.log
389
+ ```
390
+
391
+ ```
392
+ [CRIT] Access control is not enabled
393
+ mongod said: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
394
+ fix: Anyone who can reach the port can read and write every database. Enable security.authorization ...
395
+
396
+ [WARN] Transparent huge pages should be re-enabled (8.0+ guidance)
397
+ mongod said: For customers running the current memory allocator, we suggest re-enabling transparent hugepages [...]
398
+ fix: MongoDB 8.0 recommends THP enabled for its new memory allocator, the opposite of the advice for 7.0 and earlier.
399
+ ```
400
+
401
+ mongod checks its environment at every start and logs a warning for each
402
+ thing it does not like: no access control, low file limits, transparent huge
403
+ pages, NUMA, swappiness, running as root. They sit in the log right after
404
+ every restart, where almost nobody reads them. `triage` raises them too.
405
+
406
+ ### 6. Why did it die? (and what does serverStatus say?)
328
407
 
329
408
  ```bash
330
409
  mdbkit oslog /var/log/syslog # OOM kills, fd limits, I/O errors
@@ -502,9 +581,16 @@ query with different parameters is counted once.
502
581
  | `mean` / `max` | Per-occurrence average and worst case |
503
582
  | `docsEx` | Documents examined, summed across all occurrences |
504
583
  | `scan` | Documents examined per document returned. `1:1` is ideal; `3444:1` means a missing or weak index |
505
- | `plan` | The plan MongoDB chose: `COLLSCAN` (no index), `IXSCAN{fields}` (index used), `IDHACK` (`_id` lookup), `+SORT` (in-memory sort). `?` = the plan was not recorded on that line |
584
+ | `plan` | The plan MongoDB chose: `COLLSCAN` (no index), `IXSCAN{fields}` (index used), `IDHACK` (`_id` lookup), `+SORT` (in-memory sort), `+SPILL` (wrote temporary files to disk). `?` = the plan was not recorded on that line |
506
585
  | `shape` | Fields and operators queried, with the sort |
507
586
 
587
+ Two kinds of row are worth knowing about. A `getMore(find)` or
588
+ `getMore(aggregate)` row is a cursor fetching more results; it is grouped
589
+ under the shape of the query that opened the cursor. Slow `insert` rows are
590
+ included even though no index can speed up an insert: a slow insert is still
591
+ latency your application saw, and on 8.0+ the `--shape` view says whether it
592
+ was executing or waiting (on locks, flow control or write concern).
593
+
508
594
  ```bash
509
595
  mdbkit queries mongod.log
510
596
  mdbkit queries mongod.log --sort scanRatio --limit 10
@@ -513,31 +599,49 @@ mdbkit queries "mongod.log*" # rotated logs as one stream
513
599
  mdbkit queries mongod.log --shape 1 # drill into the worst offender
514
600
  ```
515
601
 
516
- `--shape N` expands one row of the table:
602
+ `--shape N` expands one row of the table. On an 8.0+ log it also shows where
603
+ the time went and the identifiers MongoDB uses for this shape:
517
604
 
518
605
  ```
519
606
  namespace : shop.events
607
+ operation : aggregate
520
608
  shape : {tenantId:eq, ts:gte} sort:{ts:-1}
521
609
 
522
- occurrences : 29
523
- total time : 3.2m
524
- mean / max : 6.6s / 8.9s
525
- docs examined : 25,810,000
526
- docs returned : 261
610
+ occurrences : 53
611
+ total time : 5.7m
612
+ mean / max : 6.5s / 8.7s
613
+ docs examined : 47,170,000
614
+ docs returned : 477
527
615
  scan ratio : 98889 examined per document returned
528
616
 
529
617
  plans observed
530
- COLLSCAN 29x
618
+ COLLSCAN 53x
531
619
 
532
620
  flags
533
621
  COLLSCAN — no index used for at least one execution
534
622
  in-memory SORT — results sorted after retrieval
535
623
 
536
- client applications
537
- ReportWorker 15x
538
- OrderService 7x
624
+ where the time went (MongoDB 8.0+)
625
+ executing : 5.5m
626
+ waiting : 13.3s (4%) — tickets, locks, flow control
627
+ ticket queue : 12.0s of the wait
628
+
629
+ resources
630
+ disk spills : 159 (13.6 GiB written)
631
+ CPU time : 5.5m total
632
+
633
+ server identifiers
634
+ queryShapeHash : BDC6B796B132EBAF671210F40FC5155C05ED250F79996E68DC6C620CBD8972AE
635
+ pin or block this shape without a code change (8.0+):
636
+ db.adminCommand({setQuerySettings: "BDC6...72AE", settings: {...}})
637
+ planCacheShapeHash : 0F877C7D (queryHash before 8.0)
539
638
  ```
540
639
 
640
+ The `queryShapeHash` is the same value MongoDB shows in `explain`, the
641
+ profiler, `$currentOp` and `$queryStats`, so you can follow one shape
642
+ across all of them. mdbkit only prints the `setQuerySettings` command. It
643
+ never runs it.
644
+
541
645
  ---
542
646
 
543
647
  ### `mdbkit connections <log>`
@@ -730,6 +834,60 @@ mdbkit triage mongod.log --report incident.html
730
834
  mdbkit triage mongod.log --window 0 --no-sysprobe
731
835
  ```
732
836
 
837
+ **Restarts and crashes.** A restart after a clean shutdown is a WARN; a start
838
+ with no clean shutdown before it is a CRIT, because that is what a crash,
839
+ `kill -9` or OOM kill looks like. mongod itself records whether its previous
840
+ shutdown was clean, so mdbkit can tell even when the crash happened before
841
+ the log you are reading begins. The first election of a newly initiated
842
+ replica set is reported as INFO, not as instability.
843
+
844
+ **Hosts running several mongods.** Run mdbkit once per instance, on that
845
+ instance's own log; don't pass several instances' logs in one command,
846
+ because several files are read as one stream (that is for the rotated logs of
847
+ one instance, or the members of one replica set). When several mongods run on
848
+ the host, `triage` uses the pid and dbPath in the log's startup line to pick
849
+ the right process for its memory, uptime and disk checks, and when
850
+ `--oslog` shows an OOM kill it says whether the killed pid was this
851
+ instance or another one.
852
+
853
+ ```bash
854
+ for log in /var/log/mongodb/*/mongod.log; do
855
+ echo "== $log"
856
+ mdbkit triage "$log" --only CRIT,WARN
857
+ done
858
+ ```
859
+
860
+ ---
861
+
862
+ ### `mdbkit audit <log>`
863
+
864
+ Reads the warnings mongod logged when it started and explains each one:
865
+ access control, running as root, TLS certificate checks, file and
866
+ locked-memory limits, `vm.max_map_count`, transparent huge pages (with the
867
+ **8.0 reversal**: 7.0 and earlier want THP off, 8.0's new allocator wants it
868
+ on), glibc `rseq`, NUMA, overcommit, zone reclaim, swappiness, filesystem.
869
+ Warnings mdbkit does not recognise are still reported, in mongod's own words.
870
+
871
+ | Option | Description |
872
+ |---|---|
873
+ | `--exit-code` | Exit 2 on CRIT, 1 on WARN, else 0 |
874
+ | `--json` | Machine-readable output |
875
+
876
+ ```bash
877
+ mdbkit audit /var/log/mongodb/mongod.log
878
+ mdbkit audit "/var/log/mongodb/mongod.log*" # include rotated logs
879
+ ```
880
+
881
+ Startup warnings are written only when mongod starts. If the log covering
882
+ the last restart has rotated away, ask the running server instead. The
883
+ output of `getLog` works directly, in EJSON, mongosh's printed form, or a
884
+ UTF-16 file from Windows PowerShell:
885
+
886
+ ```bash
887
+ mongosh --quiet --eval 'EJSON.stringify(db.adminCommand({getLog: "startupWarnings"}))' > startup.json
888
+ mdbkit audit startup.json
889
+ ```
890
+
733
891
  ---
734
892
 
735
893
  ### `mdbkit ftdc {summary|timeline|export} <path>`
@@ -769,6 +927,10 @@ mdbkit ftdc timeline diagnostic.data --metric conns.current --step 300
769
927
  mdbkit ftdc export diagnostic.data > metrics.csv
770
928
  ```
771
929
 
930
+ In `timeline`, gauges (connections, cache bytes, tickets) show the peak in
931
+ each bucket and cumulative counters (`ops.*`, `sys.cpu.*`) show their rate
932
+ per second over it.
933
+
772
934
  Metric labels include `ops.*` (insert/query/update/delete/getmore/command),
773
935
  `conns.current`, `conns.available`, `queue.readers`, `queue.writers`,
774
936
  `cache.usedBytes`, `cache.maxBytes`, `cache.dirtyBytes`, `tickets.*`,
@@ -902,8 +1064,8 @@ mdbkit triage $(mdbkit lab logs) # all three as one stream
902
1064
  mdbkit loginfo $(mdbkit lab logs | sed -n 2p) # a specific secondary
903
1065
  ```
904
1066
 
905
- **A single node**, when you do not need replication — faster to start and it
906
- does not require `mongosh`:
1067
+ **A single node**, when you do not need replication. It starts faster, and
1068
+ `start` works without `mongosh` (`seed` still needs it):
907
1069
 
908
1070
  ```bash
909
1071
  mdbkit lab start --standalone
@@ -955,6 +1117,13 @@ log immediately contains something worth analysing.
955
1117
 
956
1118
  **Safety.** The lab binds to `127.0.0.1` only, refuses to use or delete any
957
1119
  directory it did not create, and never touches a MongoDB it did not start.
1120
+ Before it signals a process it checks that the pid still belongs to one of
1121
+ its own `mongod`s (its command line names the lab's data directory), so a
1122
+ stale pid file can never kill something unrelated. `destroy` refuses to
1123
+ delete data while a lab node is still running. If a port is already taken it
1124
+ says so before starting anything. If a start fails halfway, the lab is left
1125
+ in a state `mdbkit lab destroy --yes` can clean up, and the error says so.
1126
+ Logs are appended across restarts rather than overwritten.
958
1127
  It is a laptop and scratch-VM tool, not a deployment tool.
959
1128
 
960
1129
  ---
@@ -1022,8 +1191,16 @@ looks like slowness with no slow query to blame), **WiredTiger cache** against
1022
1191
  the 80% background-eviction and 95% application-thread-eviction thresholds,
1023
1192
  **dirty cache**, **application-thread eviction**, **connection headroom**,
1024
1193
  **queued readers and writers**, **assertions**, **flow control**, replication
1025
- role and process memory. Ticket layout is read from either
1026
- `wiredTiger.concurrentTransactions` (pre-7.0) or `queues.execution` (7.0+).
1194
+ role and process memory. Tickets are read from either the older
1195
+ `wiredTiger.concurrentTransactions` layout or the newer `queues.execution`.
1196
+
1197
+ **Paste-friendly.** The file can be strict JSON, EJSON, or exactly what
1198
+ mongosh prints when you run `db.serverStatus()` and copy the output:
1199
+ unquoted keys, `Long('42')`, `ISODate(...)`, `Timestamp({...})`. A file
1200
+ redirected in Windows PowerShell (UTF-16) works too. Nothing in the file is
1201
+ ever evaluated; it is tokenised as data. Dumps taken with the 0.6.0 export
1202
+ script, which wrote 64-bit counters as `{"low": …, "high": …}` objects, are
1203
+ read correctly too.
1027
1204
 
1028
1205
  **Two dumps give true rates.** Almost everything in serverStatus is cumulative
1029
1206
  since process start, so a single dump only yields lifetime averages:
@@ -1084,13 +1261,22 @@ duration moving by more than 20%.
1084
1261
  ### `mdbkit export-script {schema|indexes}`
1085
1262
 
1086
1263
  Prints a small `mongosh` script to stdout. **mdbkit never connects to your
1087
- database** — you run these yourself, so you can read exactly what they do
1088
- first. Both are read-only and export **field names and types only, never
1089
- document values**.
1264
+ database**. You run these yourself, so you can read exactly what they do
1265
+ first. Both are read-only. `schema` exports **field names and types only,
1266
+ never document values**. `indexes` exports the index definitions from
1267
+ `getIndexes()`; a partial index's filter expression can contain literal
1268
+ values.
1269
+
1270
+ Both cover **every database you can read** (`admin`, `config` and `local`
1271
+ skipped) and key collections by full namespace, so it does not matter which
1272
+ database mongosh connects to. To export one database only, set `ONLY_DB` at
1273
+ the top of the script. The `serverstatus` script writes relaxed Extended
1274
+ JSON, so 64-bit counters come out as plain numbers.
1090
1275
 
1091
1276
  ```bash
1092
1277
  mdbkit export-script indexes > export_indexes.js
1093
1278
  mdbkit export-script schema > export_schema.js
1279
+ mdbkit export-script serverstatus > export_serverstatus.js
1094
1280
  ```
1095
1281
 
1096
1282
  ---
@@ -1100,20 +1286,28 @@ mdbkit export-script schema > export_schema.js
1100
1286
  Terminal output is and will remain first-class — this tool is built for the
1101
1287
  Linux box the database actually runs on.
1102
1288
 
1103
- **Shipped in v0.4:** `compare`, rotated-log globbing, per-shape drill-down —
1104
- on top of v0.3's `demo` and `lab`, and v0.2's FTDC decoding, incident triage,
1105
- query reconstruction and shareable reports.
1289
+ **Shipped in v0.6.1:** tested against real MongoDB 7.0, 8.0, 8.3 and 9.0
1290
+ servers, with the bugs that turned up fixed; crash vs clean restart
1291
+ detection; correct behaviour on hosts running many mongods.
1292
+
1293
+ **Shipped in v0.6:** MongoDB 8.x/9.0 support (executing vs waiting time,
1294
+ query shape hashes, disk spills, peak memory, in-progress operations, the
1295
+ 8.0 ticket layout in FTDC), the `audit` command, mongosh-paste input, and a
1296
+ hardening pass. Before that: v0.5's `oslog` and `serverstatus`, v0.4's
1297
+ `compare`, rotated-log globbing and per-shape drill-down, v0.3's `demo` and
1298
+ `lab`, and v0.2's FTDC decoding, incident triage, query reconstruction and
1299
+ shareable reports.
1106
1300
 
1107
1301
  Next up, roughly in order:
1108
1302
 
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.
1109
1307
  * **Sharded clusters.** `mongos` logs are a different shape, and the classic
1110
1308
  sharded failure — a query with no shard key fanning out to every shard — is
1111
1309
  visible in the log. Also chunk migrations, balancer windows and jumbo
1112
1310
  chunks. Would come with `mdbkit lab --sharded` so it can be tested.
1113
- * **Startup configuration audit.** mongod logs warnings at startup about
1114
- transparent huge pages, readahead, ulimits, NUMA and filesystem choice.
1115
- These are classic production misconfigurations and they are already in
1116
- your log — nothing new needs collecting.
1117
1311
  * **Index usage candidates.** Prefix-redundant indexes (an index on `{a: 1}`
1118
1312
  when `{a: 1, b: 1}` exists) are worth *examining*, but static analysis is
1119
1313
  not sufficient grounds to drop one — the planner may still be choosing it.
@@ -1124,7 +1318,8 @@ Next up, roughly in order:
1124
1318
  `docs/TESTING-PLAYBOOK.md`. Real logs and metrics very welcome.
1125
1319
 
1126
1320
  mdbkit is validated against real-world structured logs (tens of thousands of
1127
- lines) in addition to its synthetic test fixtures.
1321
+ lines) in addition to its synthetic test fixtures, and its tests include real
1322
+ output from MongoDB 7.0.43, 8.0.32, 8.3.11 and 9.0.2.
1128
1323
 
1129
1324
  ## Bugs, feature requests, questions
1130
1325