statgrab-0.1.3: Collect system level metrics and statistics

Safe HaskellNone
LanguageHaskell2010

System.Statgrab

Contents

Description

Monadic context and data types for managing the underlying libstatgrab FFI calls with transparent resource allocation and deallocation.

Synopsis

Running the Stats Monad

runStats :: MonadIO m => Stats a -> m a

Run the Stats Monad, bracketing libstatgrab's sg_init and sg_shutdown calls via reference counting to ensure reentrancy.

async :: Stats a -> Stats (Async a)

Run the Stats Monad asynchronously. wait from the async package can be used to block and retrieve the result of the asynchronous computation.

Retrieving Statistics

snapshot :: (Stat (Struct a), Copy a) => Stats a

Retrieve statistics from the underlying operating system, copying them to the Haskell heap and freeing the related Ptr a.

The *_r variants of the libstatgrab functions are used and the deallocation strategy is bracketed.

snapshots :: (Stat (Struct a), Copy a) => Stats [a]

Retrieve a list of statistics from the underlying operating system.

See: snapshot.

class Stat a

Bracket routines for acquiring and releasing Ptr as.

Minimal complete definition

acquire, release

data family Struct a

Instances

Storable (Struct ProcessCount) 
Storable (Struct Process) 
Storable (Struct Page) 
Storable (Struct NetworkInterface) 
Storable (Struct NetworkIO) 
Storable (Struct DiskIO) 
Storable (Struct FileSystem) 
Storable (Struct Swap) 
Storable (Struct User) 
Storable (Struct Load) 
Storable (Struct Memory) 
Storable (Struct CPUPercent) 
Storable (Struct CPU) 
Storable (Struct Host) 
Stat (Struct Process) 
Stat (Struct Page) 
Stat (Struct NetworkInterface) 
Stat (Struct NetworkIO) 
Stat (Struct DiskIO) 
Stat (Struct FileSystem) 
Stat (Struct Swap) 
Stat (Struct User) 
Stat (Struct Load) 
Stat (Struct Memory) 
Stat (Struct CPU) 
Stat (Struct Host) 
data Struct ProcessCount = CProcessCount {} 
data Struct Process = CProcess {} 
data Struct Page = CPage {} 
data Struct NetworkInterface = CNetworkInterface {} 
data Struct NetworkIO = CNetworkIO {} 
data Struct DiskIO = CDiskIO {} 
data Struct FileSystem = CFileSystem {} 
data Struct Swap = CSwap {} 
data Struct User = CUser {} 
data Struct Load = CLoad {} 
data Struct Memory = CMemory {} 
data Struct CPUPercent = CCPUPercent {} 
data Struct CPU = CCPU {} 
data Struct Host = CHost {} 

Statistic Types

Enums

Re-exported

data Async a :: * -> *

An asynchronous action spawned by async or withAsync. Asynchronous actions are executed in a separate thread, and operations are provided for waiting for asynchronous actions to complete and obtaining their results (see e.g. wait).

Instances

wait :: Async a -> IO a

Wait for an asynchronous action to complete, and return its value. If the asynchronous action threw an exception, then the exception is re-thrown by wait.

wait = atomically . waitSTM