Skip to main content
Glama
JackXuyi

Current operating environment

getCpuUsage

Monitor CPU utilization in real-time to identify performance bottlenecks and optimize system resources for the current operating environment.

Instructions

获取当前平台的 CPU 占用率

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Schema definition for the getCpuUsage tool, including name, description, and empty input schema.
      name: "getCpuUsage",
      description: "获取当前平台的 CPU 占用率",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    },
  • Handler implementation for getCpuUsage tool. Calculates overall CPU usage percentage by aggregating idle and total tick times from os.cpus().
    case "getCpuUsage": {
      const cpus = os.cpus();
      const totalIdle = cpus.reduce((acc, cpu) => acc + cpu.times.idle, 0);
      const totalTick = cpus.reduce((acc, cpu) => acc + Object.values(cpu.times).reduce((a, b) => a + b, 0), 0);
      const cpuUsage = 1 - totalIdle / totalTick;
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify({ cpuUsage: (cpuUsage * 100).toFixed(2) + '%' }, null, 2)
        }]
      };
    }

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/JackXuyi/env-mcp'

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