Copyright | (c) 2023 Tim Emiola |
---|---|
License | BSD3 |
Maintainer | Tim Emiola <adetokunbo@emio.la> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Implements printmem, a command that computes the memory usage of some processes
Synopsis
- getChoices :: IO Choices
- printProcs :: Choices -> IO ()
- readForOnePid :: ProcessID -> IO (Either NotRun (ProcName, MemUsage))
- readMemUsage' :: Ord a => ProcNamer -> Indexer a -> ReportBud -> IO (Either LostPid (Map a MemUsage))
- readMemUsage :: ReportBud -> IO (Either LostPid (Map ProcName MemUsage))
- data NotRun
- data LostPid
- unfoldMemUsage :: Ord a => ProcNamer -> Indexer a -> ReportBud -> IO (Either [ProcessID] ((Map a MemUsage, [ProcessID]), ReportBud))
- unfoldMemUsageAfter' :: (Ord a, Integral seconds) => ProcNamer -> Indexer a -> seconds -> ReportBud -> IO (Either [ProcessID] ((Map a MemUsage, [ProcessID]), ReportBud))
- unfoldMemUsageAfter :: Integral seconds => seconds -> ReportBud -> IO (Either [ProcessID] ((Map Text MemUsage, [ProcessID]), ReportBud))
- type ProcNamer = ProcessID -> IO (Either LostPid ProcName)
- nameFromExeOnly :: ProcNamer
- nameFor :: ProcNamer
- nameAsFullCmd :: ProcNamer
- type ProcName = Text
- type Indexer index = (ProcessID, ProcName, ProcUsage) -> (index, ProcUsage)
- dropId :: Indexer ProcName
- withPid :: Indexer (ProcessID, ProcName)
- printUsage' :: AsCmdName a => (a, MemUsage) -> Bool -> IO ()
- printUsage :: AsCmdName a => (a, MemUsage) -> IO ()
- mkReportBud :: NonEmpty ProcessID -> IO (Maybe ReportBud)
- type ProcessID = CPid
- class AsCmdName a where
Implement printmem
getChoices :: IO Choices Source #
Parses the command line arguments.
printProcs :: Choices -> IO () Source #
Print a report to stdout
displaying the memory usage of the programs
specified by Choices
Read MemUsage
readForOnePid :: ProcessID -> IO (Either NotRun (ProcName, MemUsage)) Source #
Load the
of a program specified by its MemUsage
ProcessID
readMemUsage' :: Ord a => ProcNamer -> Indexer a -> ReportBud -> IO (Either LostPid (Map a MemUsage)) Source #
readMemUsage :: ReportBud -> IO (Either LostPid (Map ProcName MemUsage)) Source #
Like
but uses the default readMemUsage'
ProcNamer
and Indexer
Represents errors that prevent a report from being generated
Instances
Represents reasons a specified pid
may not have memory
records.
NoExeFile ProcessID | |
NoStatusCmd ProcessID | |
NoStatusParent ProcessID | |
NoCmdLine ProcessID | |
BadStatm ProcessID | |
NoProc ProcessID |
Instances
Stream MemUsage periodically
unfoldMemUsage :: Ord a => ProcNamer -> Indexer a -> ReportBud -> IO (Either [ProcessID] ((Map a MemUsage, [ProcessID]), ReportBud)) Source #
unfoldMemUsageAfter' :: (Ord a, Integral seconds) => ProcNamer -> Indexer a -> seconds -> ReportBud -> IO (Either [ProcessID] ((Map a MemUsage, [ProcessID]), ReportBud)) Source #
Like
but computes the unfoldMemUsage
after a delayMemUsage
s
unfoldMemUsageAfter :: Integral seconds => seconds -> ReportBud -> IO (Either [ProcessID] ((Map Text MemUsage, [ProcessID]), ReportBud)) Source #
Like
, but uses the default unfoldMemUsageAfter'
ProcName
and Indexer
Obtain the process/program name
type ProcNamer = ProcessID -> IO (Either LostPid ProcName) Source #
Functions that obtain a process name given its pid
nameFromExeOnly :: ProcNamer Source #
Obtain the ProcName
by examining the path linked by
{proc_root}/pid/exe
Obtain the ProcName
by examining the path linked by
{proc_root}/pid/exe or its parent's name if that is a better match
nameAsFullCmd :: ProcNamer Source #
Obtain the ProcName
as the full cmd path
Index by pid or name
type Indexer index = (ProcessID, ProcName, ProcUsage) -> (index, ProcUsage) Source #
Functions that generate the report index
dropId :: Indexer ProcName Source #
Index a
using just the program nameProcUsage
ProcUsage's
with the same ProcName
will be merged when added to a MemUsage
withPid :: Indexer (ProcessID, ProcName) Source #
Index a
using the program name and process ID.ProcUsage
Each ProcUsage
remains distinct when added to a MemUsage
Print MemUsage
printUsage' :: AsCmdName a => (a, MemUsage) -> Bool -> IO () Source #
Print the program name and memory usage, optionally hiding the swap size
printUsage :: AsCmdName a => (a, MemUsage) -> IO () Source #
Like
, but alway shows the swap sizeprintUsage'
Convenient re-exports
mkReportBud :: NonEmpty ProcessID -> IO (Maybe ReportBud) Source #
Construct a ReportBud
from some ProcessIDs
Generates values for the other fields by inspecting the system
The result is Nothing
only when the KernelVersion
cannot be determined