sensu-run 0.0.0 → 0.1.0
raw patch · 3 files changed
+20/−10 lines, 3 files
Files
- CHANGELOG.md +6/−0
- sensu-run.cabal +2/−2
- sensu-run.hs +12/−8
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for sensu-run +## 0.1.0 -- 2017-06-07++* Fix a bug that ignores --handle option by accident+* Small documentation fixes+* Enable AppVeyor builds+ ## 0.0.0 -- 2017-05-16 * Initial release
sensu-run.cabal view
@@ -1,5 +1,5 @@ name: sensu-run-version: 0.0.0+version: 0.1.0 synopsis: A tool to send command execution results to Sensu description: @sensu-run@ is a command line tool to send command execution results to Sensu@@ -15,7 +15,7 @@ build-type: Simple extra-source-files: CHANGELOG.md cabal-version: >= 1.10-tested-with: GHC >= 8.0.1 && < 8.1+tested-with: GHC == 8.0.2 executable sensu-run main-is: sensu-run.hs
sensu-run.hs view
@@ -53,13 +53,13 @@ exited <- getCurrentTime rawOutput <- BL.readFile path let- encoded = encode $ CheckResult+ encoded = encode CheckResult { command = cmdspec , output = TL.decodeUtf8With TE.lenientDecode rawOutput , status = case rawStatus of Nothing -> UNKNOWN Just ExitSuccess -> OK- Just (ExitFailure {}) -> CRITICAL+ Just ExitFailure {} -> CRITICAL , duration = diffUTCTime exited executed , .. }@@ -73,7 +73,7 @@ Nothing -> do hPutStrLn stderr $ showCmdSpec cmdspec ++ " timed out" exitFailure- Just (ExitFailure {}) -> exitFailure+ Just ExitFailure {} -> exitFailure sendToClientSocketInput :: PortNumber -- ^ Listening port of Sensu client socket@@ -85,7 +85,8 @@ Socket.sendAll sock payload `catch` \(ioe :: IOException) -> do hPutStrLn stderr $- "Failed to write results to localhost:3030 (" ++ show ioe ++ ")"+ "Failed to write results to localhost:" ++ show port+ ++ " (" ++ show ioe ++ ")" exitFailure where open = socket AF_INET Stream defaultProtocol@@ -154,10 +155,11 @@ = ClientSocketInput PortNumber -- ^ Local client socket input | SensuServer (NonEmpty String)- -- ^ Sensu server API+ -- ^ Sensu server API or a client HTTP socket --- -- Multiple servers can be specified. sensu-run retries sequentially until it- -- succeeds.+ -- Multiple HTTP endpoints can be specified. sensu-run retries sequentially+ -- until it succeeds. By default Sensu servers listen on port 4567 and+ -- client HTTP sockets listen on 3031. options :: O.Parser Options options = do@@ -238,6 +240,7 @@ , executed :: UTCTime , duration :: NominalDiffTime , output :: TL.Text+ , handlers :: [T.Text] } pattern OK :: ExitCode@@ -263,9 +266,10 @@ , "command" .= showCmdSpec command , "issued" .= (floor (utcTimeToPOSIXSeconds issued) :: Int) , "executed" .= (floor (utcTimeToPOSIXSeconds executed) :: Int)- , "duration" .= (round duration :: Int)+ , "duration" .= (realToFrac duration :: Double) , "status" .= statusToInt status , "output" .= output+ , "handlers" .= handlers ] where addOptional key val ps = maybe ps (\val' -> key .= val' : ps) val