Author Topic: Linux: list servers with >= 1 humans connected, except your own  (Read 668 times)

tomreyn

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
I came across the XFCE4 GenMon plugin and wanted to use it to list gameservers which are good candidates to play on. That's the gameservers which
  • are in waiting for players state (only)
  • have at least one human connected
  • are not hosted by myself
Of course online games cannot work if nobody starts hosting or connecting to dedicated servers in the first place. So keep in mind you also need to do this.

That said, I wrote this little quick + dirty script to list the gameservers which match the criteria above (be sure to modify myplayername or filter by IP address instead):
Code: [Select]
#!/bin/sh

myplayername=tomreyn

# add this to the awk script to filter out own ip address:  && $5 != "'$(wget -qO- http://whatismyip.org/)'"
for ipport in ` wget -qO- http://master.megaglest.org/showServersForGlest.php | grep -Ev '^$' | awk -F'|' '$14 == 0 && $4 !~ /^(headless\(|'$myplayername')/ { print $5":"$12 }' `
do
  ip=`echo $ipport | cut -d: -f1`
  isp=`dig -x $ip +short | awk -F. '{print $(NF-2)"."$(NF-1) }'`
  printf '%s\n' "$ipport ($isp)"
done

Generally when accessing the master server, please don't hammer it, i.e. please no more requests than one every two minutes. So far we don't have caching there and I'd like to keep providing real time info, but if people hammer we'll have to either cache or block IPs. Thank you.
« Last Edit: 2 March 2012, 21:58:17 by tomreyn »
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·