From 8f3d63b7d8a4c63e528ff985d9dfc91b097c387d Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sun, 16 Jul 2017 11:53:46 -0700 Subject: [PATCH] Moving to Go --- README.md | 14 +++++++------- defaults | 11 ----------- pipe.sh | 28 ---------------------------- service.sh | 18 ------------------ systemd.service | 8 -------- 5 files changed, 7 insertions(+), 72 deletions(-) delete mode 100644 defaults delete mode 100755 pipe.sh delete mode 100755 service.sh delete mode 100644 systemd.service diff --git a/README.md b/README.md index 786f6cc..9995f57 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -Logs to alerts -============== +Log Alerting +============ -Pipe logs to Mattermost or Slack webhooks +Pipe logs to Mattermost (or Slack) webhooks # Requirements -* Mattermost or Slack instance -* `curl`, `jq`, `tail` +* Go 1.8.3 # Installation -1. `git clone https://git.ethitter.com/debian/eth-log-alerting.git /usr/local/eth-log-alerting` +1. TBD +<!-- 1. `git clone https://git.ethitter.com/debian/eth-log-alerting.git /usr/local/eth-log-alerting` 2. `cp /usr/local/eth-log-alerting/systemd.service /etc/systemd/system/eth_log_alerting.service` 3. `cp /usr/local/eth-log-alerting/defaults /etc/default/eth_log_alerting` 4. Edit `/etc/default/eth_log_alerting` 5. `systemctl daemon-reload` 6. `systemctl enable eth_log_alerting.service` -6. `systemctl start eth_log_alerting.service` +6. `systemctl start eth_log_alerting.service` --> diff --git a/defaults b/defaults deleted file mode 100644 index 8c52073..0000000 --- a/defaults +++ /dev/null @@ -1,11 +0,0 @@ -# Set log details -LOG_FILE="" -WEBHOOK_URL="" -USERNAME="" -CHANNEL="" -COLOR="" -ICON_URL="" -GREP="" - -# DO NOT MODIFY BELOW THIS LINE! -DAEMON_OPTIONS="$LOG_FILE \"$WEBHOOK_URL\" \"$USERNAME\" \"$CHANNEL\" \"$COLOR\" \"$ICON_URL\" \"$GREP\"" diff --git a/pipe.sh b/pipe.sh deleted file mode 100755 index f22c875..0000000 --- a/pipe.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Defaults and aliases -LOG_FILE=$1 -WEBHOOK_URL=$2 -USERNAME=${3:-logbot} -CHANNEL=${4:-#logs} -COLOR=${5:-default} -ICON_URL=$6 -GREP=$7 - -tail -Fq "$LOG_FILE" | while read LINE; do - (echo "$LINE" | grep -e "$GREP") && jq -n --arg line_encoded " $LINE" \ "{ \ - channel: \"$CHANNEL\", \ - username: \"$USERNAME\", \ - attachments: [ { \ - fallback: \"New entry in $LOG_FILE\", \ - pretext: \"\`$LOG_FILE\`\", \ - text: \$line_encoded, \ - color: \"$COLOR\" \ - } ],\ - icon_url: \"$ICON_URL\" \ - }" | cat <(echo "payload=") <(cat -) | curl \ - -X POST \ - -s \ - -d@- \ - $WEBHOOK_URL > /dev/null; -done diff --git a/service.sh b/service.sh deleted file mode 100755 index 1f1414d..0000000 --- a/service.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -DAEMON="/usr/local/eth-log-alerting/pipe.sh" -NAME="eth_log_alerting" - -# Check if DAEMON binary exist -[ -f $DAEMON ] || exit 0 - -# Check if config exists -if [ -f "/etc/default/$NAME" ] -then - . /etc/default/$NAME -else - exit 0 -fi - -# On with it! -$DAEMON $DAEMON_OPTIONS diff --git a/systemd.service b/systemd.service deleted file mode 100644 index f9a0354..0000000 --- a/systemd.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -After=network.target - -[Service] -ExecStart=/usr/local/eth-log-alerting/service.sh - -[Install] -WantedBy=default.target \ No newline at end of file -- GitLab