diff --git a/src/System/MemInfo.hs b/src/System/MemInfo.hs index d2a819c..6310757 100644 --- a/src/System/MemInfo.hs +++ b/src/System/MemInfo.hs @@ -15,37 +15,37 @@ SPDX-License-Identifier: BSD3 Implements a command that computes the memory usage of some processes -} module System.MemInfo ( - -- * implement the system command @printmem@ + -- * Implement @printmem@ getChoices, printProcs, - -- * read @MemUsage@ directly + -- * Read 'MemUsage' LostPid (..), NotRun (..), readMemUsage, readMemUsage', readForOnePid, - -- * unfold @MemUsage@ in a stream + -- * Stream 'MemUsage' periodically unfoldMemUsageAfter', unfoldMemUsageAfter, unfoldMemUsage, - -- * determine the process/program name + -- * Obtain the process/program name nameFromExeOnly, nameFor, nameAsFullCmd, - -- * index by program name or by processID + -- * Index by pid or name ProcName, dropId, withPid, - -- * print @MemUsage@ + -- * Print 'MemUsage' printUsage, printUsage', - -- * re-export + -- * Convenient re-exports mkReportBud, ProcessID, AsCmdName (..), diff --git a/src/System/MemInfo/Choices.hs b/src/System/MemInfo/Choices.hs index a7f03f3..a820c7b 100644 --- a/src/System/MemInfo/Choices.hs +++ b/src/System/MemInfo/Choices.hs @@ -4,16 +4,13 @@ Copyright : (c) 2022 Tim Emiola Maintainer : Tim Emiola SPDX-License-Identifier: BSD3 -Defines the command line flags used to control the behaviour of the core-mem -command +This module defines the command line flags used to control the behavior of the +@printmem@ command -} module System.MemInfo.Choices ( - -- * data types Choices (..), cmdInfo, getChoices, - - -- * functions ) where import Options.Applicative ( diff --git a/src/System/MemInfo/Print.hs b/src/System/MemInfo/Print.hs index 35fc009..5ad3921 100644 --- a/src/System/MemInfo/Print.hs +++ b/src/System/MemInfo/Print.hs @@ -7,13 +7,10 @@ Copyright : (c) 2022 Tim Emiola Maintainer : Tim Emiola SPDX-License-Identifier: BSD3 -This module contains functions for formatting parts of the memory report +This module provides functions that format the output of the @printmem@ command -} module System.MemInfo.Print ( - -- * classes AsCmdName (..), - - -- * functions fmtAsHeader, fmtOverall, fmtMemUsage, diff --git a/src/System/MemInfo/Proc.hs b/src/System/MemInfo/Proc.hs index 49bcfba..61a35d8 100644 --- a/src/System/MemInfo/Proc.hs +++ b/src/System/MemInfo/Proc.hs @@ -10,24 +10,28 @@ Copyright : (c) 2022 Tim Emiola Maintainer : Tim Emiola SPDX-License-Identifier: BSD3 -This module provides data types that model data from files in the @proc@ -filesystem that track memory usage metrics, and combinators for parsing and -grouping the contents of those files. +This module provides data types that model data from files in the @Linux proc +filesystem@ that track memory usage, and combinators for parsing and grouping +the contents of those files. -} module System.MemInfo.Proc ( - -- * data types + -- * Add-up process memory metrics MemUsage (..), - ExeInfo (..), - PerProc (..), - StatusInfo (..), - BadStatus (..), - - -- * functions amass, + + -- * Parse process memory metrics + PerProc (..), parseFromSmap, parseFromStatm, + + -- * Parse \/proc\/\\/exe + ExeInfo (..), parseExeInfo, + + -- * Parse \/proc\/\/status parseStatusInfo, + StatusInfo (..), + BadStatus (..), ) where import qualified Data.Map as Map @@ -58,14 +62,14 @@ instance Validity StatusInfo where ] --- | Specifies why @'parseStatusInfo'@ might fail +-- | Indicates why @'parseStatusInfo'@ failed data BadStatus = NoCmd | NoParent deriving (Eq, Show) --- | Parses the content of /proc//status into a @'StatusInfo'@ +-- | Parses the content of \/proc\/\\/status into a @'StatusInfo'@ parseStatusInfo :: Text -> Either BadStatus StatusInfo parseStatusInfo content = let @@ -83,7 +87,7 @@ parseStatusInfo content = StatusInfo <$> name <*> ppId --- | Parses the target of /proc//exe into a @'ExeInfo'@ +-- | Parses the target of \/proc\/\\/exe into a @'ExeInfo'@ parseExeInfo :: Text -> ExeInfo parseExeInfo x = let eiTarget = takeTillNull x diff --git a/src/System/MemInfo/SysInfo.hs b/src/System/MemInfo/SysInfo.hs index 3aef8a5..25859e7 100644 --- a/src/System/MemInfo/SysInfo.hs +++ b/src/System/MemInfo/SysInfo.hs @@ -8,26 +8,32 @@ Copyright : (c) 2022 Tim Emiola Maintainer : Tim Emiola SPDX-License-Identifier: BSD3 -This module provides information about the system on which the memory is being -measured. +This module provides data types that -@'readKernelVersion'@ determines the system's linux @'KernelVersion'@ +- define memory reports (@'ReportBud'@) and + +- provide info about the system where the report will run (@'KernelVersion'@, +@'SwapFlaw'@ and @'RamFlaw'@). + +along with functions that use these types. -} module System.MemInfo.SysInfo ( - -- * data types - KernelVersion, + -- * define reports ReportBud (..), + mkReportBud, + + -- * indicate calculation flaws RamFlaw (..), SwapFlaw (..), - - -- * functions - mkReportBud, checkForFlaws, fmtRamFlaws, fmtSwapFlaws, - fickleSharing, + + -- * system kernel version + KernelVersion, parseKernelVersion, readKernelVersion, + fickleSharing, ) where import qualified Data.List.NonEmpty as NE @@ -177,9 +183,11 @@ checkForFlaws bud = do pure $ bud {rbRamFlaws, rbSwapFlaws} -{- | Construct a 'ReportBud' for the specified @ProcessIDs@ +{- | Construct a @ReportBud@ from some @ProcessIDs@ + +Generates values for the other fields by checking the system -@Nothing@ is returned if the kernel version cannot be determined +The result is @Nothing@ only when the @KernelVersion@ cannot be determined -} mkReportBud :: NonEmpty ProcessID -> IO (Maybe ReportBud) mkReportBud rbPids = do