amsatop.utils packageο
Module contentsο
This module provides utility logic to simplify the implementation of amsatop. While itβs possible to build your solution without it, these components are designed to make your life easier.
- class amsatop.utils.StatFile(pid: int, command: str, state: str, ppid: int, pgrp: int, session: int, tty_nr: int, tpgid: int, flags: int, minflt: int, cminflt: int, majflt: int, cmajflt: int, utime: int, stime: int, cutime: int, cstime: int, priority: int, nice: int, num_threads: int, starttime: int)[source]ο
Bases:
object
Represents key fields from a processβs or thread /proc/[pid or tgid]/stat file.
- cmajflt: intο
- cminflt: intο
- command: strο
- cstime: intο
- cutime: intο
- flags: intο
- classmethod from_stat_line(line: str) StatFile [source]ο
Get a StatFile from the lines of the file :meta private:
- majflt: intο
- minflt: intο
- nice: intο
- num_threads: intο
- pgrp: intο
- pid: intο
- ppid: intο
- priority: intο
- session: intο
- starttime: intο
- state: strο
- stime: intο
- tpgid: intο
- tty_nr: intο
- utime: intο
- class amsatop.utils.StatusFile(Name: str, State: str, Tgid: int, Ngid: int, Pid: int, PPid: int, TracerPid: int, Uid: ~typing.List[int], Gid: ~typing.List[int], FDSize: int, Groups: ~typing.List[int] = <factory>, NStgid: int = 0, NSpid: int = 0, NSpgid: int = 0, NSsid: int = 0, Kthread: int = 0, VmPeak: int = 0, VmSize: int = 0, VmLck: int = 0, VmPin: int = 0, VmHWM: int = 0, VmRSS: int = 0, RssAnon: int = 0, RssFile: int = 0, RssShmem: int = 0, VmData: int = 0, VmStk: int = 0, VmExe: int = 0, VmLib: int = 0, VmPTE: int = 0, VmSwap: int = 0, HugetlbPages: int = 0, CoreDumping: int = 0, THP_enabled: int = 0, untag_mask: str = '', Threads: int = 0, SigQ: str = '', SigPnd: str = '', ShdPnd: str = '', SigBlk: str = '', SigIgn: str = '', SigCgt: str = '', CapInh: str = '', CapPrm: str = '', CapEff: str = '', CapBnd: str = '', CapAmb: str = '', NoNewPrivs: int = 0, Seccomp: int = 0, Seccomp_filters: int = 0, Speculation_Store_Bypass: str = '', SpeculationIndirectBranch: str = '', Cpus_allowed: str = '', Cpus_allowed_list: str = '', Mems_allowed: str = '', Mems_allowed_list: str = '', voluntary_ctxt_switches: int = 0, nonvoluntary_ctxt_switches: int = 0, x86_Thread_features: str | None = '', x86_Thread_features_locked: str | None = '', Umask: str | None = None)[source]ο
Bases:
object
Represents the parsed contents of a /proc/[pid or tgid]/status file on a Linux system. All fields map to their corresponding values in the status file.
- CapAmb: str = ''ο
- CapBnd: str = ''ο
- CapEff: str = ''ο
- CapInh: str = ''ο
- CapPrm: str = ''ο
- CoreDumping: int = 0ο
- Cpus_allowed: str = ''ο
- Cpus_allowed_list: str = ''ο
- FDSize: intο
- Gid: List[int]ο
- Groups: List[int]ο
- HugetlbPages: int = 0ο
- Kthread: int = 0ο
- Mems_allowed: str = ''ο
- Mems_allowed_list: str = ''ο
- NSpgid: int = 0ο
- NSpid: int = 0ο
- NSsid: int = 0ο
- NStgid: int = 0ο
- Name: strο
- Ngid: intο
- NoNewPrivs: int = 0ο
- PPid: intο
- Pid: intο
- RssAnon: int = 0ο
- RssFile: int = 0ο
- RssShmem: int = 0ο
- Seccomp: int = 0ο
- Seccomp_filters: int = 0ο
- ShdPnd: str = ''ο
- SigBlk: str = ''ο
- SigCgt: str = ''ο
- SigIgn: str = ''ο
- SigPnd: str = ''ο
- SigQ: str = ''ο
- SpeculationIndirectBranch: str = ''ο
- Speculation_Store_Bypass: str = ''ο
- State: strο
- THP_enabled: int = 0ο
- Tgid: intο
- Threads: int = 0ο
- TracerPid: intο
- Uid: List[int]ο
- Umask: str | None = Noneο
- VmData: int = 0ο
- VmExe: int = 0ο
- VmHWM: int = 0ο
- VmLck: int = 0ο
- VmLib: int = 0ο
- VmPTE: int = 0ο
- VmPeak: int = 0ο
- VmPin: int = 0ο
- VmRSS: int = 0ο
- VmSize: int = 0ο
- VmStk: int = 0ο
- VmSwap: int = 0ο
- classmethod from_lines(lines: List[str]) StatusFile [source]ο
Get a StatusFile from the lines of the file :meta private:
- nonvoluntary_ctxt_switches: int = 0ο
- untag_mask: str = ''ο
- voluntary_ctxt_switches: int = 0ο
- x86_Thread_features: str | None = ''ο
- x86_Thread_features_locked: str | None = ''ο
- amsatop.utils.get_stat_file_from_path(path: str) StatFile | None [source]ο
Given a path, returns a StatFile, which can be useful for analyzing a process or thread.
- Parameters:
path β path to the stat file (will be usually in the form of /proc/[pid or tgid]/stat
- Returns:
StatFile or None if the path doesnβt exist.
- Raises:
ValueError if the path isnβt valid.
- amsatop.utils.get_status_file_from_path(path: str) StatusFile | None [source]ο
Given a path, returns a StatusFile, which can be useful for analyzing a process or thread.
- Parameters:
path β path to the status file (will be usually in the form of /proc/[pid or tgid]/status
- Returns:
StatusFile or None if the path doesnβt exist (or other unhandled exception)
- Raises:
ValueError if the path isnβt valid.