sysinfo

Author: Ezio416
Created: 2022-10-11
Updated: 2022-11-23
  • Functions for getting basic system information

cpu(json: bool = False, json_indent: int = 4) Union[dict, str][source]
  • gets info on the CPU

Parameters:
  • json (bool) –

    • whether to return the output as a JSON string

    • default: false

  • json_indent (int) –

    • indentation level for JSON output

    • default: 4

Returns:

  • dict(str (float | int | str)) –

    • arch: str
      • architecture (i.e. ‘X86_64’)

    • cores: int
      • number of physical cores (i.e. 12)

    • name: str
      • name (i.e. ‘AMD Ryzen 9 3900X 12-Core Processor’)

    • threads: int
      • number of logical/virtual cores (i.e. 24)

    • used_percent: float
      • current utilization percentage (i.e. 21.2)

      • unreliable as Python uses some overhead to run

  • str

    • JSON string with all above info

disks(json: bool = False, json_indent: int = 4) Union[dict, str][source]
  • gets disk usage on mapped drives on Windows (drives with a letter like C:)

  • all byte values are in GiB (1024^3 bytes)

  • returns empty dict if not on Windows

Parameters:
  • json (bool) –

    • whether to return the output as a JSON string

    • default: false

  • json_indent (int) –

    • indentation level for JSON output

    • default: 4

Returns:

  • dict(str (dict(str: float))) –

    • keys are drive letters (i.e. ‘c’)

    • drive: dict(str: float)
      • free: float
        • amount of free space left

      • total: float
        • total storage capacity

      • used: float
        • amount of space used

      • used_percent: float
        • percentage of space used

  • str

    • JSON string with all above info

full(now: float = 0, json: bool = False, json_indent: int = 4) Union[dict, str][source]
  • gets all system info programmed into this module

Parameters:
  • now (float) –

    • Unix timestamp (presumably current time)

    • default: 0 (current time will be used)

  • json (bool) –

    • whether to return the output as a JSON string

    • default: false

  • json_indent (int) –

    • indentation level for JSON output

    • default: 4

Returns:

  • dict(str (dict)) –

    • keys are this module’s function names (i.e. ‘cpu’)

  • str

    • JSON string with all above info

ram(json: bool = False, json_indent: int = 4) Union[dict, str][source]
  • gets the RAM usage data

  • all byte values are in GiB (1024^3 bytes)

Parameters:
  • json (bool) –

    • whether to return the output as a JSON string

    • default: false

  • json_indent (int) –

    • indentation level for JSON output

    • default: 4

Returns:

  • dict(str (float)) –

    • free: float
      • amount of free space left

    • total: float
      • total storage capacity

    • used: float
      • amount of space used

    • used_percent: float
      • percentage of space used

  • str

    • JSON string with all above info

system(now: float = 0, json: bool = False, json_indent: int = 4) Union[dict, str][source]
  • gets various system info such as boot time

Parameters:
  • now (float) –

    • Unix timestamp (presumably current time)

    • default: 0 (current time will be used)

  • json (bool) –

    • whether to return the output as a JSON string

    • default: false

  • json_indent (int) –

    • indentation level for JSON output

    • default: 4

Returns:

  • dict(str (float | str)) –

    • name: str
      • computer network name (i.e. ‘Ezio-PC’)

    • platform: str
      • operating system info (i.e. ‘Windows-10-10.0.19044-SP0’)

    • boot_time: float
      • system boot time in Unix time (i.e. 1665585199.3431532)

    • boot_time_nice: str
      • human-readable boot time (i.e. ‘2022-10-12 08:33:19 -06:00’)

    • boot_uptime: float
      • number of seconds since boot (i.e. 11636.991024971008)

    • boot_uptime_nice: str
      • human-readable boot uptime (i.e. ‘03h13m56s’)

  • str

    • JSON string with all above info

users(now: float = 0, json: bool = False, json_indent: int = 4) Union[dict, str][source]
  • gets a list of users currently logged in

Parameters:
  • now (float) –

    • Unix timestamp (presumably current time)

    • default: 0 (current time will be used)

  • json (bool) –

    • whether to return the output as a JSON string

    • default: false

  • json_indent (int) –

    • indentation level for JSON output

    • default: 4

Returns:

dict(str

  • keys are account names

  • user: dict(str: float|str))
    • login_time: float
      • user login time in Unix time (i.e. 1665585199.3431532))

    • login_time_nice: str
      • human-readable login time (i.e. ‘2022-10-12 08:33:19 -06:00’)

    • login_uptime: float
      • number of seconds since login (i.e. 11636.991024971008)

    • login_uptime_nice: str
      • human-readable login uptime (i.e. ‘03h13m56s’)

Return type:

dict(str: float|str))