dataiotech Labs
Scripts Library/mongodb/#87
Script #87
mongodb
Monitoringread-onlyMin Version: 4.0

MongoDB Connections and WiredTiger Cache Status

Summarizes connection usage and cache fill via serverStatus. Tells you whether the working set fits in RAM.

#serverStatus#connections#wiredtiger#cache
mongodb · javascript
const s = db.serverStatus();
const wt = s.wiredTiger.cache;
({
  connections_current: s.connections.current,
  connections_available: s.connections.available,
  cache_max_gb: +(wt["maximum bytes configured"] / 1073741824).toFixed(2),
  cache_used_gb: +(wt["bytes currently in the cache"] / 1073741824).toFixed(2),
  cache_dirty_gb: +(wt["tracked dirty bytes in the cache"] / 1073741824).toFixed(2),
  pages_read_into_cache: wt["pages read into cache"],
  uptime_hours: +(s.uptime / 3600).toFixed(1)
});
Operational Notes & Remediation Guidance

WiredTiger cache dirty percentage above 20% triggers aggressive foreground application thread eviction.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 4.0).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.

Engineering Triad: Related Runbooks & Incident Response

Which production incidents and emergency drills execute this script as a diagnosis step?

Runbook Library (63)
Related Alerts & Metrics
M49MongoDB Connection UsageMongoDB
M52MongoDB WiredTiger Cache UsageMongoDB
M53MongoDB Dirty Cache RatioMongoDB