laryakan / valheim-server-status

Simpliest server monitoring for a Linux Valheim dedicated server. Compat. 100% Ubuntu Server 18.04 LTS.
MIT License
5 stars 0 forks source link

Don't get Serverstatus #1

Closed Kweck closed 3 years ago

Kweck commented 3 years ago

Hi, first of all: Great work. This is exactly what I was looking for. but the main feature - Status of the Server, isn't working for me.

I tried to set it up for my launcher and it workod to get the log send to discord. But due to the fact the status wasn't sent I tried to setup for your launcher. So it is started using the launcher script and should pipe the log through the filter as far as I can see.

Until now I get the last (5 in my case) lines of the logfile send to discord but no Serverstatus message.

Any advice what I can do/check why the status isn't showing up?

Thanks in advance

laryakan commented 3 years ago

Hello,

On which version/branches you are atm ?

It's possible that one of the command used to get the server status isn't working. Do you want your server status on discord ? or over HTTP ? Can you please launch ./status/server-status --for-webhook to see what's going on ?

Kweck commented 3 years ago

I'm on the main branch.

laryakan commented 3 years ago

Good, can you launch ./status/server-status --for-webhook please ? :-)

(you can remove values you don't want to share, I just need stderr)

Kweck commented 3 years ago

That shows at least the two players online currently.

{"title":"Valheim server status","embeds":[{"title":"online","color":3066993,"url":"http://:8181/","fields":[{"name":"Last Check","value": "2021-04-03.15:38:32"},{"name":"CPU","value": "0%","inline":true},{"name":"RAM","value": "10,4%","inline":true},{"name":"Online","value": "Lupus, Kweck"},{"name":"Offline","value": "nobody"}]}]}

laryakan commented 3 years ago

the output seems ok to me. It's more like a bug in the sender or status message id, since you get last logs, your webhook token is ok.

can you try : ./status/server-status. --for-webhook | ./discord/webhook.json-sender --status please ?

this is the command used in ./discord/update to update your webhook message or send them if we dont have any message_id in .env)

and then if you still dont see any output on your discord, directly send the message to the discord api: curl -vvH "Content-Type: application/json" -X POST -d "$(./status/server-status --for-webhook)" "your_webhook_url_starting_with_https://discord.com/api/webhooks/" this will tell you the response of the discord API

Kweck commented 3 years ago

The status does not send an update to discord (there was a typo, I removed the dot after server-status) adn tghe response is only {"embeds": ["0"]}

That's the response of the curl

*   Trying 162.159.137.232:443...
* TCP_NODELAY set
* Connected to discord.com (162.159.137.232) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=CA; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
*  start date: Jan 19 00:00:00 2021 GMT
*  expire date: Jan 18 23:59:59 2022 GMT
*  subjectAltName: host "discord.com" matched cert's "discord.com"
*  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55911e607e70)
> POST /api/webhooks/121230147088048123/dK_qTD97JS-2WdeRkRRj0F3IzYRrRRzguJ9MWrCPNU0CGcHrS3ZHR-eyv-3rrINj0BuY HTTP/2
> Host: discord.com
> user-agent: curl/7.68.0
> accept: */*
> content-type: application/json
> content-length: 324
>
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 400
< date: Sat, 03 Apr 2021 15:03:14 GMT
< content-type: application/json
< content-length: 17
< set-cookie: __cfduid=df641234945ad7697fa887e6c7ad17a8f1612362194; expires=Mon, 03-May-21 15:03:14 GMT; path=/; domain=.discord.com; HttpOnly; SameSite=Lax; Secure
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< x-envoy-upstream-service-time: 9
< via: 1.1 google
< alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
< cf-cache-status: DYNAMIC
< cf-request-id: 0939db58af0550217540bbb000000001
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< report-to: {"group":"cf-nel","endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=iiu7jJMCy%2B9xFoVf3ar9JIEwp79t3jHov1rrrztPXDrLOPKLyoLISB%2FgwColMKprr76EuNDz2cOz65rkMgr2VJ8PgMPLZrHzfi0Htg%3D%3D"}],"max_age":604800}
< nel: {"report_to":"cf-nel","max_age":604800}
< x-content-type-options: nosniff
< server: cloudflare
< cf-ray: 63a32ebabe802175-DUS
<
* Connection #0 to host discord.com left intact
{"embeds": ["0"]}
laryakan commented 3 years ago

okay, that's because you didn't filled the url field. I didnt knew that could cause that kind of behavior from the Discord API.

In your .env, default : PUBLICIP=$(dig +short myip.opendns.com @resolver1.opendns.com) if dig failed, it's an empty string, so

Please, go in the ./setup, option 3 (VSS over HTTP menu), then option 1 (set a public URL), then enter a valid URL :-)

If you're not using VSS over HTTP, set any valid URL.

I'll do a fix to prevent this error.

laryakan commented 3 years ago

To confirm that dig is the problem, does it return a valid value for dig +short myip.opendns.com @resolver1.opendns.com

if not, or if dig isn't installed or if you doesn't want to use VSS HTTP, as said:

Please, go in the ./setup, option 3 (VSS over HTTP menu), then option 1 (set a public URL), then enter a valid URL (like https://www.valheimgame.com) :-)

I've done a fix, if for some reason dig return an empty string (error or else), I've setted up a default status URL on https://www.valheimgame.com:443/

Since your .env is already generated, the simplest way is to change STATUSURL as described above or if you don't want to reenter the ./setup, just use this command : cat "./.env"|grep "STATUSURL="|xargs -I {} -t -d'\n' sed -i "s[{}[STATUSURL=\"https://www.valheimgame.com/\"[ig" "./.env" this should do the trick.

Can you confirm that this solved your problem ?

laryakan commented 3 years ago

The status does not send an update to discord (there was a typo, I removed the dot after server-status) adn tghe response is only {"embeds": ["0"]}

yes the typo isn't in the code, be assured :-) sorry for that

Kweck commented 3 years ago

Yes, now I get the status message - adding the URL helped fpr this.

But.. The Player Status stucks and don't show the real status of the players. (CPU and RAM and Last Check seems to work though, Last Logs also)

and.. currently I'm trying to get the VSS HTTP running behind my reverse proxy.

laryakan commented 3 years ago

Connected players are monitored by the logfilter. For this you can use :

If a player connects and the logfilter miss the log > No connected player update

If a player disonnects and the logfilter miss the log > > No disconnected player update

:-)

The VSS HTTP is using NCAT. By default is listening 0.0.0.0:$STATUSPORT (STATUSPORT is set in .env) if your behind a reverse proxy doing some port routing, you can directly edit .env to suit your needs.

Kweck commented 3 years ago

Yes, I'm using the custom launcher. During all this testing something went wrong I think. The script wasn't able to read the online/offline-players files and the logfile (error when force update to discord showed something about binary format... it was to fast to read completely) I deleted them, restarted the server and it works.

I will keep an eye on it.

Thank you very much for your effort - I will get back to the vss https tomorrow I think. Shouldn't be a big deal.

But to get back to the topic - adding a valid URL worked to fix the missing status message.