summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/CoreCommon.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/Monitors/CoreCommon.hs')
-rw-r--r--Plugins/Monitors/CoreCommon.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Plugins/Monitors/CoreCommon.hs b/Plugins/Monitors/CoreCommon.hs
index de737d4..9a19cd5 100644
--- a/Plugins/Monitors/CoreCommon.hs
+++ b/Plugins/Monitors/CoreCommon.hs
@@ -18,6 +18,10 @@ import Plugins.Monitors.Common
import System.Posix.Files (fileExist)
import System.Directory
+-- |
+-- Function checks the existence of first file specified by pattern and if the
+-- file doesn't exists failure message is shown, otherwise the data retrieval
+-- is performed.
checkedDataRetrieval :: String -> String -> String -> String -> Double -> Monitor String
checkedDataRetrieval failureMessage dir file pattern divisor = do
exists <- io $ fileExist $ foldl (++) dir ["/", pattern, "0/", file]
@@ -25,6 +29,10 @@ checkedDataRetrieval failureMessage dir file pattern divisor = do
False -> return failureMessage
True -> retrieveData dir file pattern divisor
+-- |
+-- Function retrieves data from files in directory dir specified by pattern.
+-- String values are converted to double and adjusted with divisor. Final array
+-- is processed by template parser function and returned as monitor string.
retrieveData :: String -> String -> String -> Double -> Monitor String
retrieveData dir file pattern divisor = do
count <- io $ dirCount dir pattern