I have a table called server_connections
which adds a new record each time a ping is performed every ten minutes, the structure of the table can be found below.
I am looking to calculate the uptime percentage of each server as there is a OFFLINE
or ONLINE
string inserted depending on the server's reach-ability. Admittedly I'm not great at advanced SQL like this, my limit is pretty much joins!
+-------------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------------+------+-----+---------+----------------+
| id | bigint unsigned | NO | PRI | NULL | auto_increment |
| server_id | bigint unsigned | NO | | NULL | |
| status | varchar(255) | NO | | NULL | |
| map_name | varchar(255) | YES | | NULL | |
| num_players | int | YES | | NULL | |
| max_players | int | YES | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
+-------------+-----------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)
Any advice on how to do this would be fantastic, I've been racking my brains for a while over this.