sysstat_webhook : accept custom message_text
This commit is contained in:
parent
08f0e4dd93
commit
ad32f07d5b
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
while getopts 'w:crdnf:o:' flag
|
while getopts 'w:crdnt:f:o:' flag
|
||||||
do
|
do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
w) webhook_url=${OPTARG};; # Discord Webhook URL
|
w) webhook_url=${OPTARG};; # Discord Webhook URL
|
||||||
@ -8,6 +8,7 @@ do
|
|||||||
r) RAM="True";; # RAM
|
r) RAM="True";; # RAM
|
||||||
d) DISK_IO="True";; # DISK I/O
|
d) DISK_IO="True";; # DISK I/O
|
||||||
n) NETWORK="True";; # Network
|
n) NETWORK="True";; # Network
|
||||||
|
t) MESSAGE_TEXT=${OPTARG};; # Add some text to your webhook message!
|
||||||
f) datafile=${OPTARG};; # where your data belongs!
|
f) datafile=${OPTARG};; # where your data belongs!
|
||||||
o) SYSSTAT_OPTIONS=${OPTARG};; # Sysstat options
|
o) SYSSTAT_OPTIONS=${OPTARG};; # Sysstat options
|
||||||
esac
|
esac
|
||||||
@ -51,7 +52,7 @@ function svg_to_png {
|
|||||||
}
|
}
|
||||||
function Discord_hooks {
|
function Discord_hooks {
|
||||||
curl \
|
curl \
|
||||||
-F 'payload_json={"content": "'$DATETIME'"}' \
|
-F 'payload_json={"content": "'$MESSAGE_TEXT'"}' \
|
||||||
-F "file1=@$POSTFILE" \
|
-F "file1=@$POSTFILE" \
|
||||||
$webhook_url
|
$webhook_url
|
||||||
}
|
}
|
||||||
@ -61,6 +62,10 @@ if [ ! -n "${webhook_url}" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! "$MESSAGE_TEXT" == "" ]; then
|
||||||
|
MESSAGE_TEXT=$DATETIME
|
||||||
|
fi
|
||||||
|
|
||||||
EXPANSION=()
|
EXPANSION=()
|
||||||
if [ ! "$SYSSTAT_OPTIONS" == "" ]; then
|
if [ ! "$SYSSTAT_OPTIONS" == "" ]; then
|
||||||
EXPANSION+=("$SYSSTAT_OPTIONS")
|
EXPANSION+=("$SYSSTAT_OPTIONS")
|
||||||
|
Loading…
Reference in New Issue
Block a user