larrabee / ewn-go

Program for reporting errors in the execution of another programs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Execute With Notify

Go Report Card Build Status
This is wrapper script, what can notify you when your tasks failed.

Features

  1. Notify with email
  2. Publish logs to Graylog/Logstash
  3. Prevent duplicate processes
  4. Retry failed commands

Install

  1. Download binary from Release page or build it with go build main.go
  2. Run ewn --initconfig. This command create default config file (default config path: /etc/ewn.conf)
  3. Update config file with your parameters

Usage

  • Exec command with notify for default recipients ('user1@example.com' and 'user2@example.com'):
    ewn -c 'echo "This is test command" && /bin/false'
  • Exec command with notify for custom recipients ('user3@example.com' and 'user4@example.com'):
    ewn -c 'echo "This is test command" && /bin/false' -r "user3@example.com" "user4@example.com"
  • Exec command with comment message. It will be attached to email and Graylog message:
    ewn -c 'echo "This is test command" && /bin/false' --comment "This command will always fail"
  • Exec command that prevent duplicate processes:
    ewn -c 'echo "This is test command" && /bin/sleep 3600' --dont-duplicate
  • Exec command that prevent duplicate processes with custom key (by default it is --command). It useful when you have different commands:
    ewn -c 'echo "This is first command" | tee /tmp/file && /bin/sleep 3600' --dont-duplicate --dont-duplicate-key "conflicting commands" ewn -c 'echo "This is second command" | tee /tmp/file && /bin/sleep 3600' --dont-duplicate --dont-duplicate-key "conflicting command"
  • Exec command with 3 retry on failure and 30 sec interval between retries:
    ewn -c 'echo "This is test command" && /bin/false' --retry 3 --retry-sleep 30
  • Exec command with custom valid exit codes (default is 0). If command exit with exit code 1, 3 or 255 email will not sent.
    ewn -c 'echo "This is test command" && /bin/false' --valid-exitcodes 1 3 255

You can combine any keys like:
ewn -c 'echo "This is test command" && /bin/false' -d --dont-duplicate -r "user3@example.com" "user4@example.com" --retry 3 --retry-sleep 30 --valid-exitcodes 1 --comment "This command will never fail because 1 in valid exitcodes"

License

GPL v3

About

Program for reporting errors in the execution of another programs

License:GNU General Public License v3.0


Languages

Language:Go 100.0%