Skip to main content
Glama

Advanced Docker Monitoring

docker_monitoring_advanced

Monitor Docker containers with health checks, events, and detailed statistics to track performance and system information.

Instructions

Enhanced monitoring with health checks, events, and detailed statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesMonitoring action
containerNoContainer name (for container-specific actions)
sinceNoTime period for events (e.g., '1h', '30m', '1d')
formatNoOutput formattable

Implementation Reference

  • src/index.ts:982-1072 (registration)
    Registration of the 'docker_monitoring_advanced' tool, including input schema definition and the complete handler function that implements various advanced monitoring features like live stats, health checks, events, system info, and performance overview.
    server.registerTool(
      "docker_monitoring_advanced",
      {
        title: "Advanced Docker Monitoring",
        description: "Enhanced monitoring with health checks, events, and detailed statistics",
        inputSchema: {
          action: z.enum(["live_stats", "health", "events", "system_info", "performance"]).describe("Monitoring action"),
          container: z.string().optional().describe("Container name (for container-specific actions)"),
          since: z.string().optional().describe("Time period for events (e.g., '1h', '30m', '1d')"),
          format: z.enum(["table", "json"]).optional().default("table").describe("Output format")
        }
      },
      async ({ action, container, since, format }) => {
        try {
          switch (action) {
            case "live_stats":
              const stats = await DockerMonitor.getLiveStats(container);
              return {
                content: [
                  {
                    type: "text",
                    text: `## Live Docker Statistics\n\n\`\`\`\n${stats}\n\`\`\``
                  }
                ]
              };
    
            case "health":
              if (!container) {
                throw new Error("Container name is required for health check");
              }
              const health = await DockerMonitor.getContainerHealth(container);
              return {
                content: [
                  {
                    type: "text",
                    text: `## Container Health Check\n\n${health}`
                  }
                ]
              };
    
            case "events":
              const events = await DockerMonitor.getSystemEvents(since || "1h");
              return {
                content: [
                  {
                    type: "text",
                    text: `## Docker System Events (last ${since || "1h"})\n\n\`\`\`\n${events}\n\`\`\``
                  }
                ]
              };
    
            case "system_info":
              const systemInfo = await executeDockerCommand("docker system info");
              return {
                content: [
                  {
                    type: "text",
                    text: `## Docker System Information\n\n\`\`\`\n${systemInfo.stdout}\n\`\`\``
                  }
                ]
              };
    
            case "performance":
              const [diskUsage, version, containers] = await Promise.all([
                executeDockerCommand("docker system df -v"),
                executeDockerCommand("docker version"),
                executeDockerCommand("docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'")
              ]);
              
              return {
                content: [
                  {
                    type: "text",
                    text: `## Docker Performance Overview\n\n### Disk Usage\n\`\`\`\n${diskUsage.stdout}\n\`\`\`\n\n### Running Containers\n\`\`\`\n${containers.stdout}\n\`\`\`\n\n### Version\n\`\`\`\n${version.stdout}\n\`\`\``
                  }
                ]
              };
          }
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error with advanced monitoring: ${error instanceof Error ? error.message : String(error)}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • The handler function for the tool that handles different monitoring actions: live_stats, health, events, system_info, and performance by calling DockerMonitor methods and executeDockerCommand.
    async ({ action, container, since, format }) => {
      try {
        switch (action) {
          case "live_stats":
            const stats = await DockerMonitor.getLiveStats(container);
            return {
              content: [
                {
                  type: "text",
                  text: `## Live Docker Statistics\n\n\`\`\`\n${stats}\n\`\`\``
                }
              ]
            };
    
          case "health":
            if (!container) {
              throw new Error("Container name is required for health check");
            }
            const health = await DockerMonitor.getContainerHealth(container);
            return {
              content: [
                {
                  type: "text",
                  text: `## Container Health Check\n\n${health}`
                }
              ]
            };
    
          case "events":
            const events = await DockerMonitor.getSystemEvents(since || "1h");
            return {
              content: [
                {
                  type: "text",
                  text: `## Docker System Events (last ${since || "1h"})\n\n\`\`\`\n${events}\n\`\`\``
                }
              ]
            };
    
          case "system_info":
            const systemInfo = await executeDockerCommand("docker system info");
            return {
              content: [
                {
                  type: "text",
                  text: `## Docker System Information\n\n\`\`\`\n${systemInfo.stdout}\n\`\`\``
                }
              ]
            };
    
          case "performance":
            const [diskUsage, version, containers] = await Promise.all([
              executeDockerCommand("docker system df -v"),
              executeDockerCommand("docker version"),
              executeDockerCommand("docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'")
            ]);
            
            return {
              content: [
                {
                  type: "text",
                  text: `## Docker Performance Overview\n\n### Disk Usage\n\`\`\`\n${diskUsage.stdout}\n\`\`\`\n\n### Running Containers\n\`\`\`\n${containers.stdout}\n\`\`\`\n\n### Version\n\`\`\`\n${version.stdout}\n\`\`\``
                }
              ]
            };
        }
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error with advanced monitoring: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema definition using Zod for the tool's parameters: action (required enum), optional container, since, and format.
    title: "Advanced Docker Monitoring",
    description: "Enhanced monitoring with health checks, events, and detailed statistics",
    inputSchema: {
      action: z.enum(["live_stats", "health", "events", "system_info", "performance"]).describe("Monitoring action"),
      container: z.string().optional().describe("Container name (for container-specific actions)"),
      since: z.string().optional().describe("Time period for events (e.g., '1h', '30m', '1d')"),
      format: z.enum(["table", "json"]).optional().default("table").describe("Output format")
    }
  • DockerMonitor class providing helper methods: getLiveStats, getSystemEvents, getContainerHealth, which are called by the tool handler to perform the actual monitoring tasks.
    class DockerMonitor {
      static async getLiveStats(containerName?: string): Promise<string> {
        const command = containerName 
          ? `docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}" ${containerName}`
          : `docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}"`;
        
        const result = await executeDockerCommand(command);
        return result.stdout;
      }
    
      static async getSystemEvents(since: string = "1h"): Promise<string> {
        const command = `docker events --since ${since} --until now`;
        const result = await executeDockerCommand(command);
        return result.stdout;
      }
    
      static async getContainerHealth(containerName: string): Promise<string> {
        try {
          const inspect = await executeDockerCommand(`docker inspect ${containerName}`);
          const data = JSON.parse(inspect.stdout)[0];
          
          const health = data.State.Health || { Status: "none" };
          const state = data.State;
          
          return `Container: ${containerName}\nStatus: ${state.Status}\nHealth: ${health.Status}\nStarted: ${state.StartedAt}\nFinished: ${state.FinishedAt || 'N/A'}`;
        } catch (error) {
          throw new Error(`Failed to get health info: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'enhanced monitoring' but doesn't specify whether this requires special permissions, has rate limits, affects system performance, or what the output looks like. The description is too vague about actual behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (8 words) and front-loaded with the core purpose. Every word contributes to understanding the tool's enhanced capabilities compared to basic monitoring.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a monitoring tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'enhanced' means operationally, what format the monitoring data returns, or how the different actions differ in behavior and output.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description mentions 'health checks, events, and detailed statistics' which loosely maps to some action enum values but doesn't add meaningful semantic context beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs 'enhanced monitoring' with specific capabilities (health checks, events, detailed statistics), which distinguishes it from the simpler 'docker_monitoring' sibling tool. However, it doesn't specify the exact verb or resource scope beyond 'monitoring'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus the simpler 'docker_monitoring' sibling or other monitoring alternatives. It mentions capabilities but doesn't specify appropriate contexts or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TauqeerAhmad5201/docker-mcp-extension'

If you have feedback or need assistance with the MCP directory API, please join our Discord server