-
Notifications
You must be signed in to change notification settings - Fork 0
/
slack.sh
executable file
·35 lines (29 loc) · 1.05 KB
/
slack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/bash
status_json=$(curl -s https://status.slack.com/api/current)
# TODO: To test use this file
# status_json=$(cat /Users/mjohnsey/dev/github.com/mjohnsey/bitbar-plugins/tests/slack_test.json)
status=$(echo "${status_json}" | /usr/local/bin/jq -r '.status')
down_status="🔴"
up_status="👌"
status_light="${down_status}"
error_msg=""
services=""
if [ "${status}" = "ok" ]; then
status_light="${up_status}"
else
error_msg="${status}"
services=$(echo "${status_json}" | /usr/local/bin/jq -r -c '.services[]')
type=$(echo "${status_json}" | /usr/local/bin/jq -r -c '.type')
incident_url=$(echo "${status_json}" | /usr/local/bin/jq -r -c '.url')
date_create=$(echo "${status_json}" | /usr/local/bin/jq -r -c '.date_created')
fi
echo ${status_light}
echo "---"
if [ "${error_msg}" != "" ]; then
echo "Type: ${type}|href=${incident_url}"
echo "Affected Services:"
echo "${services}"
echo "Start Time: ${date_create}"
fi
echo "Slack status|href=https://status.slack.com/"
echo "Last checked: $(date "+%Y-%m-%d %H:%M:%S")"