-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation to improve haddocks
- Loading branch information
1 parent
1aa57b0
commit a3292ea
Showing
5 changed files
with
46 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,13 @@ Copyright : (c) 2022 Tim Emiola | |
Maintainer : Tim Emiola <[email protected]> | ||
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 ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,10 @@ Copyright : (c) 2022 Tim Emiola | |
Maintainer : Tim Emiola <[email protected]> | ||
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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,24 +10,28 @@ Copyright : (c) 2022 Tim Emiola | |
Maintainer : Tim Emiola <[email protected]> | ||
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\/\<pid\>\/exe | ||
ExeInfo (..), | ||
parseExeInfo, | ||
|
||
-- * Parse \/proc\/<pid\>\/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/<pid>/status into a @'StatusInfo'@ | ||
-- | Parses the content of \/proc\/\<pid\>\/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/<pid>/exe into a @'ExeInfo'@ | ||
-- | Parses the target of \/proc\/\<pid\>\/exe into a @'ExeInfo'@ | ||
parseExeInfo :: Text -> ExeInfo | ||
parseExeInfo x = | ||
let eiTarget = takeTillNull x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,32 @@ Copyright : (c) 2022 Tim Emiola | |
Maintainer : Tim Emiola <[email protected]> | ||
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 | ||
|