SysMonitoring
  • Introduction
  • Installation
  • Configuration
  • Troubleshooting
  • Functions
    • startServer()
    • stopServer()
    • getCpuLoad()
    • getMemoryUsage()
    • getPing()
  • API
    • /cpu
    • /memory
    • /ping
  • Terminal Commands
    • echo
    • time
    • help
    • stats
Powered by GitBook
On this page
  • Overview
  • Endpoint
  • Example
  • Response
  • Description
  1. API

/cpu

/api/cpu

Overview

The /api/cpu endpoint returns the current CPU load of the system in the form of a JSON response.

Endpoint

GET /api/cpu

Example

fetch('/api/cpu')
  .then(response => response.json())
  .then(data => {
    console.log(`CPU Load: ${data.cpuLoad}%`);
  });

Response

The response will return a JSON object containing the cpuLoad value:

{
  "cpuLoad": "15.34"
}

Description

  • /api/cpu provides the current CPU load as a percentage value.

  • It uses the getCpuLoad() function internally to fetch the data.

  • The result is returned as a floating-point number with two decimal places, representing the CPU load in percentage.

PreviousgetPing()Next/memory

Last updated 5 months ago