loadavg-0.1: Load average parsing from /proc/loadavg and bindings to getloadavg (3)

System.Posix.LoadAvg

Description

There are two basic ways you can get load average on a modern Linux system. First is getloadavg (3) system call. The second is /proc/loadavg file. This module provides means of getting the information from both sources. /proc/loadavg provides some additional information but we ignore that.

Synopsis

Documentation

data LoadAvg Source

Constructors

LoadAvg 

Fields

sample_1 :: !Double

sample for last 1 minute

sample_5 :: !Double

sample for last 5 minutes

sample_15 :: !Double

sample for last 15 minutes

parseLoadAvg :: String -> LoadAvgSource

Tries to parse the output of /proc/loadavg. If anything goes wrong an arbitrary exception will be raised.

getLoadAvg :: IO LoadAvgSource

Discards error checking from getLoadAvgSafe. Will raise IO exception on error.

getLoadAvgSafe :: IO (Maybe LoadAvg)Source

Calls getloadavg (3) to get system load average. Provides error checking, and the result may be Nothing in case of error. If there is not enough data the samples will be copied from more recent samples.

getLoadAvgProc :: IO LoadAvgSource

Tries to read /proc/loadavg and parse it's output with parseLoadAvg. Either may fail with IO exception.