@gazzehamine/armada-watch-agent 1.2.0 → 1.3.1

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.
package/dist/collector.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSystemInfo = getSystemInfo;
7
7
  exports.collectMetrics = collectMetrics;
8
8
  exports.collectProcesses = collectProcesses;
9
+ exports.collectDockerContainers = collectDockerContainers;
9
10
  const systeminformation_1 = __importDefault(require("systeminformation"));
10
11
  const os_1 = __importDefault(require("os"));
11
12
  let lastNetworkStats = null;
@@ -146,3 +147,43 @@ async function collectProcesses() {
146
147
  memory: p.mem,
147
148
  }));
148
149
  }
150
+ async function collectDockerContainers() {
151
+ try {
152
+ // Get basic container info and stats
153
+ const dockerContainers = await systeminformation_1.default.dockerContainers();
154
+ const dockerStats = await systeminformation_1.default.dockerContainerStats('*');
155
+ // Create a map of stats by container ID
156
+ const statsMap = new Map();
157
+ dockerStats.forEach((stat) => {
158
+ statsMap.set(stat.id, stat);
159
+ });
160
+ return dockerContainers.map((container) => {
161
+ const stats = statsMap.get(container.id) || {};
162
+ return {
163
+ id: container.id || '',
164
+ name: container.name || '',
165
+ image: container.image || '',
166
+ state: container.state || 'unknown',
167
+ status: container.state || 'unknown',
168
+ created: container.created || 0,
169
+ started: container.started || 0,
170
+ cpuPercent: stats.cpuPercent || 0,
171
+ memoryPercent: stats.memPercent || 0,
172
+ memoryUsage: stats.memUsage || 0,
173
+ memoryLimit: stats.memLimit || 0,
174
+ netIO: {
175
+ rx: stats.netIO?.rx || 0,
176
+ wx: stats.netIO?.wx || 0,
177
+ },
178
+ blockIO: {
179
+ r: stats.blockIO?.r || 0,
180
+ w: stats.blockIO?.w || 0,
181
+ },
182
+ };
183
+ });
184
+ }
185
+ catch (error) {
186
+ // Docker not available or not running
187
+ return [];
188
+ }
189
+ }
package/dist/index.js CHANGED
@@ -48,6 +48,7 @@ async function sendMetrics() {
48
48
  try {
49
49
  const metrics = await (0, collector_1.collectMetrics)();
50
50
  const processes = await (0, collector_1.collectProcesses)();
51
+ const dockerContainers = await (0, collector_1.collectDockerContainers)();
51
52
  const payload = {
52
53
  instanceInfo,
53
54
  metrics: {
@@ -55,6 +56,7 @@ async function sendMetrics() {
55
56
  ...metrics,
56
57
  },
57
58
  processes,
59
+ dockerContainers,
58
60
  };
59
61
  await axios_1.default.post(`${SERVER_URL}/api/metrics`, payload, {
60
62
  timeout: 5000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gazzehamine/armada-watch-agent",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Monitoring agent for Armada Watch - EC2 instance monitoring",
5
5
  "main": "dist/index.js",
6
6
  "bin": {