You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-4Lines changed: 18 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,14 +79,25 @@ For more information on the above parameters, please check out the Slack docs:
79
79
*https://api.slack.com/docs/attachments
80
80
81
81
82
-
### Examples
82
+
#Send A Message
83
83
The channel is "general" with username "hacky-slack". The icon is "apple" and the author is "apple". The author name is linked to "apple.com" and the text sent in the message is "Where are the new 2016 Macbook models?"
84
84
85
85
```
86
86
slack -c "#general" -u "hacky-slack" -i "apple" -a "Macbook" -b "http://www.apple.com/ -t "Where are the new 2016 Macbook models?"
87
87
```
88
88
89
-
These examples assumes you have set your token and webhook endpoint.
89
+
Here is a sample message and a screenshot of the message with various flags set.
90
+
91
+
```
92
+
slack -a -t "Hello World" -i ":slack:" -T "Titles are awesome" -p "Pretext is so helpful to include" -s "info"
Note: These examples assume you have set your token and webhook endpoint.
90
101
91
102
## Monit
92
103
Monit is a system monitoring and recovery tool. More on Monit here: https://mmonit.com/monit/
@@ -143,9 +154,12 @@ check process crond with pidfile "/var/run/crond.pid"
143
154
if 2 restarts within 3 cycles then exec /usr/bin/bash -c "sh /usr/local/bin/slack.sh -a -c #testing -s error -M monit" repeat every 3 cycles else if succeeded then exec /usr/bin/bash -c "sh /usr/local/bin/slack.sh -a -c #testing -s ok -M monit"
144
155
if 5 restarts within 5 cycles then timeout
145
156
```
146
-
## Using Hacky Slack in with other apps.
157
+
### Using Hacky Slack in with other apps.
158
+
159
+
Hacky Slack can be extended to support other applications besides Monit. For example, Nagios monitoring or Cron. Really, any application can send messages via Hacky Slack.
160
+
147
161
148
-
Hacky Slack can be extended to support other applications. For example, Nagios monitoring or Cron. Really, any application can send messages via Hacky Slack.
162
+
Since no user (<code>- u</code>) was specified it will default to using the host system IP address
Copy file name to clipboardExpand all lines: slack.sh
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -184,13 +184,13 @@ else
184
184
iftest"${PRIORITY}" = "INFO";thenecho"INFO: STATUS (-s) was set to INFO..."; ICON=${ICON:-':info:'}&& COLOR=${COLOR:-'#439FE0'};fi
185
185
iftest"${PRIORITY}" = "WARN";thenecho"INFO: STATUS (-s) was set to WARN..."; ICON=${ICON:-':warn:'}&& COLOR=${COLOR:-'#ed7d21'};fi
186
186
iftest"${PRIORITY}" = "ERROR";thenecho"INFO: STATUS (-s) was set to ERROR..."; ICON=${ICON:-':error:'}&& COLOR=${COLOR:-'#E21B6C'};fi
187
+
iftest -z "${USERNAME}";thenecho"INFO: A USERNAME (-u) was not specified for this POST to the Slack API. Setting a default username..."; USERNAME="${IP}";fi
187
188
188
189
# Set defaults
189
190
test -z "${TEXT}";echo"WARNING: You do not have any TEXT (-t) specified in the message."; TEXT="${TEXT:-'This message is missing TEXT'}"
190
191
test -z "${TITLE}";echo"WARNING: You do not have a TITLE (-T) specified for the message."; TITLE=${TITLE:-'This message is missing a TITLE'}
191
192
test -z "${PRETEXT}";echo"WARNING: You do not have a PRETEXT (-p) specified for the message."; PRETEXT=${PRETEXT:-'This message is missing a PRETEXT'}
192
193
test -z "${CHANNEL}";echo"WARNING: A CHANNEL (-c) was not set. Using the default CHANNEL..."; CHANNEL=${CHANNEL:-'general'}
193
-
test -z "${USERNAME}";echo"INFO: A USERNAME (-u) was not specified for this POST to the Slack API. Setting a default username..."; USERNAME=${IP}
194
194
test -z "${PRIORITY}";echo"INFO: STATUS (-s) was not set. Setting a default STATUS to INFO..."; PRIORITY=${PRIORITY:-'INFO'}&& ICON=${ICON:-':info:'}&& COLOR=${COLOR:-'#439FE0'}
0 commit comments