From anonymous, 5 Years ago, written in Python.
Embed
  1. import sys, os
  2. import socket
  3. import datetime
  4.  
  5. today = datetime.datetime.now()
  6.  
  7. servers = [ "megusta.iotairc.net", "rawr.iotairc.net",
  8.             "mbilker.iotairc.net", "alexg.iotairc.net",
  9.             "raptor.iotairc.net", "toaster.iotairc.net",
  10.             "bitchplease.iotairc.net", "mudkip.iotairc.net",
  11.             "haddaway.iotairc.net" ]
  12.  
  13. with open("/var/www/status.html", "w") as f:
  14.     f.write('<li style="text-align: right;"><i>Last update: %s</i></font>\n' % today.strftime("%Y-%m-%d %H:%M"))
  15.     for server in servers:
  16.         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  17.         sock.settimeout(1)
  18.         try:
  19.             sock.connect((server, 6667))
  20.             ircd = "(leaf)"
  21.             if "megusta.iotairc.net" in server:
  22.               ircd = "(main hub)"
  23.             elif "bitchplease.iotairc.net" in server:
  24.               ircd = "(EU hub)"
  25.             elif "raptor.iotairc.net" in server:
  26.               ircd = "(USA hub)"
  27.         except socket.gaierror:
  28.             f.write('<li style="text-align: right;">%s %s <font color="red">offline</font></li>\n' % (server, ircd))
  29.         else:  
  30.             f.write('<li style="text-align: right;">%s %s <font color="green">online</font></li>\n' % (server, ircd))    
  31.         finally:
  32.             sock.close()
  33.  
  34.