LinuxGSM icon indicating copy to clipboard operation
LinuxGSM copied to clipboard

[BUG] Discord webhook test alert not working for Valheim and Ark Slackware64-15.0 multilib

Open kingbeowulf opened this issue 1 year ago • 3 comments

I recently switched to using Discord due to "popular demand" ( I was happy with Steam chat and Mumble) and decided to try Discord webhooks for server notifications to avoid "is it up" emails and texts (freakin' millennial kids these days, but that's another story).

I followed the the instructions here: Create a Discord Webhook and Alert Settings

The error is a bit weird since "command not found" when alert_discord.sh runs is a bit odd.

For system versions refer to: valheim postdetails Ark is running on the same server. common.cfg is (valheim shown)

steam@aragorn:~/lgsm/config-lgsm/vhserver$ cat common.cfg 
#
## LinuxGSM Stats
# Send useful stats to LinuxGSM developers.
# https://docs.linuxgsm.com/configuration/linuxgsm-stats
# (on|off)
stats="on"

# Display IP | https://docs.linuxgsm.com/alerts#display-ip
displayip=""

# More info | https://docs.linuxgsm.com/alerts#more-info
postalert="on"

# Discord Alerts | https://docs.linuxgsm.com/alerts/discord
discordalert="on"
discordwebhook="https://discord.com/api/webhooks/<redacted>"
steam@aragorn:~$ ./vhserver-2 restart
[  OK  ] Stopping vhserver-2: Graceful: CTRL+c: 6: OK
[  OK  ] Starting vhserver-2: Svartalheim
steam@aragorn:~$ ./vhserver-2 ta
[  OK  ] Posting details vhserver-2: termbin.com for 30D
[ .... ] Sending Alert vhserver-2: Sending Discord alert/home/steam/lgsm/functions/alert_discord.sh: line 50: jq: command not found
[ FAIL ] Sending Alert vhserver-2: Sending Discord alert: {"code": 50109, "message": "The request body contains invalid JSON."}
[ WARN ] Sending Alert vhserver-2: Email alerts not enabled
[ WARN ] Sending Alert vhserver-2: Gotify alerts not enabled
[ WARN ] Sending Alert vhserver-2: IFTTT alerts not enabled
[ WARN ] Sending Alert vhserver-2: Mailgun alerts not enabled
[ WARN ] Sending Alert vhserver-2: Pushbullet alerts not enabled
[ WARN ] Sending Alert vhserver-2: Pushover alerts not enabled
[ WARN ] Sending Alert vhserver-2: Telegram Messages not enabled
[ WARN ] Sending Alert vhserver-2: Rocketchat alerts not enabled
[ WARN ] Sending Alert vhserver-2: Slack alerts not enabled

Looking at 'alert_discord.sh' I see that line 50 is

discordsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}")

I tested the webhook and it works with this script from the server (Discord is running an game box and not on the server):

!/bin/bash
WEBHOOK_URL="https://discord.com/api/webhooks/<redacted>"

curl -X POST \
  -H "Accept: application/json" \
  -H "Content-Type:application/json; charset=utf-8" \
  -d '{"content": ":test_alert: Server is yelling at you."}' \
  ${WEBHOOK_URL}

Running 'arkserver ta' generates the same error. I know next to nothing about webhooks or JSON, and rarely use curl, so hopefully I am not missing the obvious. When I set up the Discord webhook, each had a different name and icon. Your example used LinxGSM with a blank/default icon

To Reproduce

Run test alert option after configuration and server restart as above for either valheim-2 or arkserver

Expected behavior

LinuxGSM server test message expected to appear in configured Discord chat channel.

kingbeowulf avatar Aug 10 '22 02:08 kingbeowulf

it does say there that jq was not found:

line 50: jq: command not found

please install it and try again.

h3o66 avatar Aug 10 '22 17:08 h3o66

well, d'oh. I really need to get new reading glasses. I didn't recognze jq as anything other an error code, not an actual program. It is working as expected now. Thanks.

Is there a table of external programs somewhere that LinuxGSM uses for those of us dinosaurs that do not use dependency resolving linux distros, or ( shudder ) global sudo previledge escalation?

kingbeowulf avatar Aug 10 '22 21:08 kingbeowulf

Currently we only have the dependencys for debian/ubuntu/rhel based distros in the csv files in lgsm/data/

Maybe someone could add a doc for other executeables needed for not supported distros.

h3o66 avatar Aug 10 '22 21:08 h3o66

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Aug 28 '23 00:08 github-actions[bot]