Safe Haskell | None |
---|---|
Language | Haskell2010 |
A parser for /proc/meminfo
Memory metadata
widget :: Text -> Query Text -> PakejWidget Text Source
Construct a Text
widget from the initial value and the memory metadata query
Make sense of memory metadata
ratio :: Fractional a => Query a -> Query a -> Query a Source
The ratio between the results of two memory metadata queries
available :: Num a => Query a Source
Amount of memory available for consumption
Accurate result requires newer kernels. On older kernels it downgrades to approximate calculations
used :: Num a => Query a Source
Amount of memory already in use
Accurate result requires newer kernels. On older kernels it downgrades to approximate calculations
Memory metadata parser
getData :: FilePath -> IO (Either Text Mem) Source
Parse /proc/meminfo
(or any file with the same format) data
to the key-value mapping, e.g. if
% cat /proc/meminfo MemTotal: 3912112 kB MemFree: 170128 kB
then
>>>
getData "/proc/meminfo"
Right (fromList [("MemTotal", 3912112), ("MemFree", 170128), ...])
If any problems are encountered while parsing it returns the first one
wrapped in Left
Catches I/O exceptions thrown upon opening and reading the file and presents
their error message wrapped in Left