packages feed

sensu-run 0.3.0 → 0.4.0

raw patch · 4 files changed

+36/−9 lines, 4 files

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for sensu-run +## 0.4.0 -- 2017-08-03++* Include command output in response even on timeout/failure (#14)+ ## 0.3.0 -- 2017-07-25  * Add user field to result JSON (#7)
README.md view
@@ -48,11 +48,29 @@ {   "name": "check-home-src-size",   "command": "du -s /home/maoe/src",-  "issued": 1500526383,-  "executed": 1500526383,-  "duration": 1.168139,+  "issued": 1501041549,+  "executed": 1501041549,+  "duration": 1.674895,   "status": 0,-  "output": "55186828\t/home/maoe/src\n",+  "output": "55513524\t/home/maoe/src\n",+  "handlers": [+    "foo"+  ],+  "user": "maoe"+}+```++Use the `--shell` option if you want to use shell functions:+```console+% sensu-run --name check-home-src-size --handler foo --dry-run --shell -- "cd $HOME/src; du -s ." | jq .+{+  "name": "check-home-src-size",+  "command": "cd /home/maoe/src; du -s .",+  "issued": 1501041568,+  "executed": 1501041568,+  "duration": 1.224157,+  "status": 0,+  "output": "55513524\t.\n",   "handlers": [     "foo"   ],
sensu-run.cabal view
@@ -1,5 +1,5 @@ name: sensu-run-version: 0.3.0+version: 0.4.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
sensu-run.hs view
@@ -38,6 +38,7 @@ import qualified Data.Text as T import qualified Data.Text.Encoding.Error as TE import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Builder as TL import qualified Data.Text.Lazy.Encoding as TL import qualified Network.HTTP.Types.Status as HT import qualified Network.Socket.ByteString.Lazy as Socket@@ -71,10 +72,14 @@       let         encoded = encode CheckResult           { command = cmdspec-          , output = case rawStatus of-            Left ioe -> TL.pack $ show (ioe :: IOException)-            Right Nothing -> "timed out"-            Right _ -> TL.decodeUtf8With TE.lenientDecode rawOutput+          , output = TL.toLazyText $ mconcat+            [ TL.fromLazyText (TL.decodeUtf8With TE.lenientDecode rawOutput)+            , "\n"+            , TL.fromString $ case rawStatus of+              Left ioe -> show (ioe :: IOException)+              Right Nothing -> "sensu-run: timed out"+              Right _ -> mempty+            ]           , status = case rawStatus of             Right (Just ExitSuccess) -> OK             Right (Just ExitFailure {}) -> CRITICAL