From 85a1674a870395bb71f6510952565a3fdfa402d2 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Fri, 22 Jun 2007 12:51:28 +0200 Subject: removed monitor.hs (useless now) darcs-hash:20070622105128-d6583-053972c4d23c7b88907cb1008d219c9d09551f6f.gz --- monitor.hs | 70 -------------------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100755 monitor.hs diff --git a/monitor.hs b/monitor.hs deleted file mode 100755 index 7705bc6..0000000 --- a/monitor.hs +++ /dev/null @@ -1,70 +0,0 @@ -#! /usr/bin/env runhaskell - - -import Data.Time (getZonedTime) -import Text.Printf (printf) -import System.Process (runInteractiveCommand) -import Data.List -import System.IO (hGetContents) - - -getOutput :: String -> IO String -getOutput cmd = do - (_, out, _, _) <- runInteractiveCommand cmd - hGetContents out - -memParse :: String -> String -memParse file = - let content = map words $ take 4 $ lines file - [total, free, buffer, cache] = map (\line -> (read $ line !! 1 :: Float) / 1024) content - rest = free + buffer + cache - used = total - rest - usedratio = used * 100 / total - realused = if usedratio > 50 then "^#FF0000"++show used++"^#FFFFFF" - else "^#FF00FF"++show used++"^#FFFFFF" - in - printf "MEM: %sM %.1f%% used %.0fM rest" realused usedratio rest - - -mem :: IO String -mem = do - file <- readFile "/proc/meminfo" - return $ memParse file - - -time :: IO String -time = do - now <- getZonedTime - return $ take 16 $ show now - - -temp :: IO String -temp = do - file <- readFile "/proc/acpi/thermal_zone/THRM/temperature" - let t = (words file) !! 1 - f t | read t > 60 = "^#FF0000"++t++"^#FFFFFF" - | otherwise = "^#00FF00"++t++"^#FFFFFF" - return $ "TEMP: " ++ (f t) ++ "C" - - -takeTail :: Int -> [a] -> [a] -takeTail n xs = - let len = length xs in - drop (len-n) xs - - -load :: IO String -load = do - content <- getOutput "uptime" - let l = map (delete ',') $ takeTail 3 $ words content - return $ unwords $ "LOAD:" : l - - -sep :: IO String -sep = return " " - - -main = do - putStr "" - mapM_ (>>=putStr) $ intersperse sep [load, temp, mem, time] - putChar '\n' \ No newline at end of file -- cgit v1.2.3