network-metrics 0.2.6 → 0.2.8
raw patch · 8 files changed
+40/−50 lines, 8 files
Files
- network-metrics.cabal +1/−1
- src/GMetric.hs +6/−11
- src/Network/Metric.hs +2/−2
- src/Network/Metric/Internal.hs +23/−23
- src/Network/Metric/Sink/Ganglia.hs +2/−7
- src/Network/Metric/Sink/Graphite.hs +2/−2
- src/Network/Metric/Sink/Handle.hs +2/−2
- src/Network/Metric/Sink/Statsd.hs +2/−2
network-metrics.cabal view
@@ -1,5 +1,5 @@ name: network-metrics-version: 0.2.6+version: 0.2.8 synopsis: Send metrics to Ganglia, Graphite, and statsd. license: OtherLicense license-file: LICENSE
src/GMetric.hs view
@@ -1,11 +1,11 @@ -- | -- Module : GMetric.Main--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --@@ -15,16 +15,11 @@ ) where -import Control.Monad (liftM, when)-import Data.Binary.Put (runPut)-import Data.Word (Word16)-import Network.Socket (SocketType(..))+import Control.Monad (when) import System.Console.CmdArgs-import System.Environment (getArgs, withArgs)-import System.Exit (ExitCode(..), exitWith)-import Network.Metric.Internal+import System.Environment (getArgs, withArgs)+import System.Exit (ExitCode(..), exitWith) -import qualified Data.ByteString.Char8 as BS import qualified Network.Metric.Sink.Ganglia as G data Options = Options@@ -81,7 +76,7 @@ programName = "gmetric-haskell" programVersion = "0.1.0" programInfo = programName ++ " version " ++ programVersion-copyright = "(C) Brendan Hay <brendan@soundcloud.com> 2012"+copyright = "(C) Brendan Hay <brendan.g.hay@gmail.com> 2012-2013" parse :: IO Options parse = do
src/Network/Metric.hs view
@@ -1,11 +1,11 @@ -- | -- Module : Network.Metric--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --
src/Network/Metric/Internal.hs view
@@ -2,12 +2,12 @@ -- | -- Module : Network.Metric.Internal--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --@@ -39,21 +39,21 @@ , hPush -- * Re-exports- , HostName- , PortNumber(..)+ , S.HostName+ , S.PortNumber(..) ) where -import Control.Monad (liftM, unless)-import Data.Typeable (Typeable)-import Network.Socket hiding (send)-import Network.Socket.ByteString.Lazy (send)-import Text.Printf (printf)+import Control.Monad (liftM, unless)+import Data.Typeable (Typeable)+import Text.Printf (printf) -import qualified Data.ByteString.Char8 as BS-import qualified Data.ByteString.Lazy.Char8 as BL+import qualified Data.ByteString.Char8 as BS+import qualified Data.ByteString.Lazy.Char8 as BL+import qualified Network.Socket as S+import qualified Network.Socket.ByteString.Lazy as SBL -- | Socket handle-data Handle = Handle Socket SockAddr deriving (Show)+data Handle = Handle S.Socket S.SockAddr deriving (Show) -- | Metric host type Host = BS.ByteString@@ -139,27 +139,27 @@ -- | Helper to curry a constructor function for a sink fOpen :: Sink a => (Handle -> a)- -> SocketType- -> HostName- -> PortNumber+ -> S.SocketType+ -> S.HostName+ -> S.PortNumber -> IO AnySink fOpen ctor typ host port = liftM (AnySink . ctor) (hOpen typ host port) -- | Create a new socket handle (in a disconnected state) for UDP communication-hOpen :: SocketType -> HostName -> PortNumber -> IO Handle-hOpen typ host (PortNum port) = do- (addr:_) <- getAddrInfo Nothing (Just host) (Just $ show port)- sock <- socket (addrFamily addr) typ defaultProtocol- return $ Handle sock (addrAddress addr)+hOpen :: S.SocketType -> S.HostName -> S.PortNumber -> IO Handle+hOpen typ host (S.PortNum port) = do+ (addr:_) <- S.getAddrInfo Nothing (Just host) (Just $ show port)+ sock <- S.socket (S.addrFamily addr) typ S.defaultProtocol+ return $ Handle sock (S.addrAddress addr) -- | Close a socket handle hClose :: Handle -> IO ()-hClose (Handle sock _) = sClose sock+hClose (Handle sock _) = S.sClose sock -- | Direct access for writing a bytestring to a socket handle hPush :: Handle -> BL.ByteString -> IO () hPush (Handle sock addr) bstr | BL.null bstr = return () | otherwise = do- sIsConnected sock >>= \b -> unless b $ connect sock addr- _ <- send sock bstr+ S.sIsConnected sock >>= \b -> unless b $ S.connect sock addr+ _ <- SBL.send sock bstr return ()
src/Network/Metric/Sink/Ganglia.hs view
@@ -1,11 +1,11 @@ -- | -- Module : Network.Metric.Sink.Ganglia--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --@@ -136,11 +136,6 @@ -- -- Private ------ TODO: enforce max buffer size length checks.--- Magic number is per libgmond.c-bufferSize :: Integer-bufferSize = 1500 -- | Oh, the horror put :: Encodable a
src/Network/Metric/Sink/Graphite.hs view
@@ -1,11 +1,11 @@ -- | -- Module : Network.Metric.Sink.Graphite--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --
src/Network/Metric/Sink/Handle.hs view
@@ -1,11 +1,11 @@ -- | -- Module : Network.Metric.Sink.Handle--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --
src/Network/Metric/Sink/Statsd.hs view
@@ -1,11 +1,11 @@ -- | -- Module : Network.Metric.Sink.Statsd--- Copyright : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- Copyright : (c) 2012-2013 Brendan Hay <brendan.g.hay@gmail.com> -- License : This Source Code Form is subject to the terms of -- the Mozilla Public License, v. 2.0. -- A copy of the MPL can be found in the LICENSE file or -- you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer : Brendan Hay <brendan@soundcloud.com>+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : experimental -- Portability : non-portable (GHC extensions) --