1.0.0 • Published 9 months ago

als-swap-mem-info v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Swap Memory Info

A simple Node.js module to fetch swap memory information. It supports both Linux and Windows platforms.

Installation

npm install als-swap-mem-info

Usage

const getSwapMemory = require('als-swap-mem-info');

(async () => {
    const swapInfo = await getSwapMemory();
    console.log(swapInfo);
    // Output example:
    // { total: 4096, used: 128, perc: 0.03125 }
})();

Output

The function returns an object with the following properties:

  • total: Total swap memory (in MB)
  • used: Used swap memory (in MB)
  • perc: Percentage of used swap memory (0 to 1 scale). If total memory is 0, it returns null.

Platform Support

  • Linux: Uses the free command.
  • Windows: Uses the wmic command.

Note: Ensure you have appropriate permissions to run system commands in your environment.

Errors

Throws an "Unsupported platform" error if the OS is not supported.