commit fd00feae06dda9f595a3bbaa34dc340dd9225405 Author: Johan Tibell Date: Sat Oct 29 13:29:32 2011 -0700 Initial import diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d9cf75c --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +Copyright (c)2011, Johan Tibell + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Johan Tibell nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/System/Remote/Monitoring.hs b/System/Remote/Monitoring.hs new file mode 100644 index 0000000..b821ba3 --- /dev/null +++ b/System/Remote/Monitoring.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE OverloadedStrings, RecordWildCards #-} +module System.Remote.Monitoring where + +import qualified Data.Aeson.Encode as A +import Data.Aeson.Types ((.=)) +import qualified Data.Aeson.Types as A +import qualified Data.ByteString.Lazy as L +import GHC.Stats + +instance A.ToJSON GCStats where + toJSON (GCStats {..}) = A.object [ + "bytes_allocated" .= bytesAllocated + , "num_gcs" .= numGcs + , "max_bytes_used" .= maxBytesUsed + , "num_bytes_usage_samples" .= numByteUsageSamples + , "cumulative_butes_used" .= cumulativeBytesUsed + , "bytes_copied" .= bytesCopied + , "current_bytes_used" .= currentBytesUsed + , "current_bytes_slop" .= currentBytesSlop + , "max_bytes_slop" .= maxBytesSlop + , "peak_megabytes_allocated" .= peakMegabytesAllocated + , "mutator_cpu_seconds" .= mutatorCpuSeconds + , "mutator_wall_seconds" .= mutatorWallSeconds + , "gc_cpu_seconds" .= gcCpuSeconds + , "gc_wall_seconds" .= gcWallSeconds + , "cpu_seconds" .= cpuSeconds + , "wall_seconds" .= wallSeconds + , "par_avg_bytes_copied" .= parAvgBytesCopied + , "par_max_bytes_copied" .= parMaxBytesCopied + ] + +getStatsAsJson :: IO L.ByteString +getStatsAsJson = (A.encode . A.toJSON) `fmap` getGCStats diff --git a/ekg.cabal b/ekg.cabal new file mode 100644 index 0000000..9035f92 --- /dev/null +++ b/ekg.cabal @@ -0,0 +1,19 @@ +Name: ekg +Version: 0.1.0.0 +Synopsis: Remote monitoring of executables +-- Description: +Homepage: https://github.com/tibbe/ekg +License: BSD3 +License-file: LICENSE +Author: Johan Tibell +Maintainer: johan.tibell@gmail.com +Category: System +Build-type: Simple +Cabal-version: >=1.2 + +Library + Exposed-modules: System.Remote.Monitoring + + Build-depends: aeson < 0.4, + base >= 4.3.1 && < 5, + bytestring < 1.0