sysstat_webhook : accept custom message_text

This commit is contained in:
minoplhy 2023-11-02 13:48:16 +07:00
parent 08f0e4dd93
commit ad32f07d5b
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF

View File

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