diff --git a/support-bundle/README-edge.md b/support-bundle/README-edge.md index f1e4d9b..b2cde48 100644 --- a/support-bundle/README-edge.md +++ b/support-bundle/README-edge.md @@ -207,3 +207,4 @@ For Enterprise and PCG clusters, the script collects MongoDB replica set informa * `rs-conf.json`: Replica set configuration including member settings and priorities * `replication-info.txt`: Oplog information and replication window * `disk-usage.txt`: Actual `df -h /var/lib/mongodb` per mongo pod — the real on-disk size, which can differ from the requested PVC/PV size on thin-provisioned or fixed-disk-offering backends (e.g. CloudStack fixed offerings) +* `db-collection-sizes.txt`: Per-database and per-collection storage/data sizes (MB) and document counts — shows which collections are consuming disk diff --git a/support-bundle/README-infra.md b/support-bundle/README-infra.md index 4941795..972219c 100644 --- a/support-bundle/README-infra.md +++ b/support-bundle/README-infra.md @@ -151,6 +151,7 @@ For Enterprise and PCG clusters, the script collects MongoDB replica set informa * `rs-conf.json`: Replica set configuration including member settings and priorities * `replication-info.txt`: Oplog information and replication window * `disk-usage.txt`: Actual `df -h /var/lib/mongodb` per mongo pod — the real on-disk size, which can differ from the requested PVC/PV size on thin-provisioned or fixed-disk-offering backends (e.g. CloudStack fixed offerings) +* `db-collection-sizes.txt`: Per-database and per-collection storage/data sizes (MB) and document counts — shows which collections are consuming disk ## Important Notes diff --git a/support-bundle/support-bundle-edge.sh b/support-bundle/support-bundle-edge.sh index 730476b..104a0c2 100755 --- a/support-bundle/support-bundle-edge.sh +++ b/support-bundle/support-bundle-edge.sh @@ -682,6 +682,17 @@ function mongo-status() { echo } >> "${TMPDIR}/mongo/disk-usage.txt" done < <(printf '%s\n' "$MONGO_PODS") + + techo "Collecting MongoDB database + collection sizes" + kubectl exec -n hubble-system "$MONGO_POD" -c mongo -- bash -c "$MONGO_CMD $MONGO_AUTH admin --quiet --eval ' + db.adminCommand({listDatabases:1}).databases.forEach(function(d){ + var s = db.getSiblingDB(d.name).stats(1024*1024); + print(\"DB \"+d.name+\" storageSize(MB)=\"+s.storageSize+\" dataSize(MB)=\"+s.dataSize); + db.getSiblingDB(d.name).getCollectionNames().forEach(function(c){ + var cs = db.getSiblingDB(d.name).getCollection(c).stats(1024*1024); + print(\" \"+d.name+\".\"+c+\" storageSize(MB)=\"+cs.storageSize+\" size(MB)=\"+cs.size+\" count=\"+cs.count); + }); + });'" > "${TMPDIR}/mongo/db-collection-sizes.txt" 2>&1 } function k8s-resources() { diff --git a/support-bundle/support-bundle-infra.sh b/support-bundle/support-bundle-infra.sh index e5d6e2e..92641c3 100755 --- a/support-bundle/support-bundle-infra.sh +++ b/support-bundle/support-bundle-infra.sh @@ -192,6 +192,17 @@ function mongo-status() { echo } >> "${TMPDIR}/mongo/disk-usage.txt" done < <(printf '%s\n' "$MONGO_PODS") + + techo "Collecting MongoDB database + collection sizes" + kubectl exec -n hubble-system "$MONGO_POD" -c mongo -- bash -c "$MONGO_CMD $MONGO_AUTH admin --quiet --eval ' + db.adminCommand({listDatabases:1}).databases.forEach(function(d){ + var s = db.getSiblingDB(d.name).stats(1024*1024); + print(\"DB \"+d.name+\" storageSize(MB)=\"+s.storageSize+\" dataSize(MB)=\"+s.dataSize); + db.getSiblingDB(d.name).getCollectionNames().forEach(function(c){ + var cs = db.getSiblingDB(d.name).getCollection(c).stats(1024*1024); + print(\" \"+d.name+\".\"+c+\" storageSize(MB)=\"+cs.storageSize+\" size(MB)=\"+cs.size+\" count=\"+cs.count); + }); + });'" > "${TMPDIR}/mongo/db-collection-sizes.txt" 2>&1 } function k8s-resources() {