mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-01 09:42:16 +00:00
feat: enhance Docker stats monitoring with disk I/O statistics
- Updated OSUtils instantiation to include disk I/O statistics. - Implemented filtering to exclude virtual devices from disk stats, ensuring only real disk devices are monitored.
This commit is contained in:
@@ -53,7 +53,11 @@ export const setupDockerStatsMonitoringSocketServer = (
|
|||||||
try {
|
try {
|
||||||
// Special case: when monitoring "dokploy", get host system stats instead of container stats
|
// Special case: when monitoring "dokploy", get host system stats instead of container stats
|
||||||
if (appName === "dokploy") {
|
if (appName === "dokploy") {
|
||||||
const osutils = new OSUtils();
|
const osutils = new OSUtils({
|
||||||
|
disk: {
|
||||||
|
includeStats: true, // Enable disk I/O statistics
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Get CPU usage
|
// Get CPU usage
|
||||||
const cpuResult = await osutils.cpu.usage();
|
const cpuResult = await osutils.cpu.usage();
|
||||||
@@ -85,7 +89,17 @@ export const setupDockerStatsMonitoringSocketServer = (
|
|||||||
let blockWriteBytes = 0;
|
let blockWriteBytes = 0;
|
||||||
const diskStats = await osutils.disk.stats();
|
const diskStats = await osutils.disk.stats();
|
||||||
if (diskStats.success && diskStats.data.length > 0) {
|
if (diskStats.success && diskStats.data.length > 0) {
|
||||||
|
// Filter out virtual devices (loop, ram, sr, etc.) - only include real disk devices
|
||||||
|
const excludePatterns = [/^loop/, /^ram/, /^sr\d+$/, /^fd\d+$/];
|
||||||
for (const stat of diskStats.data) {
|
for (const stat of diskStats.data) {
|
||||||
|
// Skip virtual devices
|
||||||
|
if (
|
||||||
|
stat.device &&
|
||||||
|
excludePatterns.some((pattern) => pattern.test(stat.device))
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// readBytes and writeBytes are DataSize objects with .toBytes() method
|
||||||
blockReadBytes += stat.readBytes.toBytes();
|
blockReadBytes += stat.readBytes.toBytes();
|
||||||
blockWriteBytes += stat.writeBytes.toBytes();
|
blockWriteBytes += stat.writeBytes.toBytes();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user