-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset_splayds.rb
executable file
·92 lines (78 loc) · 2.5 KB
/
reset_splayds.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ruby
## Splay Controller ### v1.1 ###
## Copyright 2006-2011
## http://www.splay-project.org
##
##
##
## This file is part of Splay.
##
## Splayd is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License,
## or (at your option) any later version.
##
## Splayd is distributed in the hope that it will be useful,but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Splayd. If not, see <http://www.gnu.org/licenses/>.
# GRANT ALL PRIVILEGES ON splay.* TO splay@localhost IDENTIFIED BY 'splay';
require File.expand_path(File.join(File.dirname(__FILE__), 'lib/all'))
def drop_db(db)
db.run("DROP TABLE IF EXISTS splayds")
db.run("DROP TABLE IF EXISTS splayd_availabilities")
end
def init_db(db)
db.run("CREATE TABLE IF NOT EXISTS splayds (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`key` VARCHAR(255) NOT NULL,
ip VARCHAR(255),
hostname VARCHAR(255),
session VARCHAR(255),
name VARCHAR(255),
country VARCHAR(2),
city VARCHAR(255),
latitude DECIMAL(10,6),
longitude DECIMAL(10,6),
version VARCHAR(255),
lua_version VARCHAR(255),
bits ENUM('32', '64') DEFAULT '32',
endianness ENUM('big', 'little') DEFAULT 'little',
os VARCHAR(255),
full_os VARCHAR(255),
start_time INT,
load_1 DECIMAL(5,2) DEFAULT '999.99',
load_5 DECIMAL(5,2) DEFAULT '999.99',
load_15 DECIMAL(5,2) DEFAULT '999.99',
max_number INT,
max_mem INT,
disk_max_size INT,
disk_max_files INT,
disk_max_file_descriptors INT,
network_max_send BIGINT(14),
network_max_receive BIGINT(14),
network_max_sockets INT,
network_max_ports INT,
network_send_speed INT,
network_receive_speed INT,
command ENUM('DELETE'),
status ENUM('REGISTERED','PREAVAILABLE','AVAILABLE','UNAVAILABLE','RESET','DELETED') DEFAULT 'REGISTERED',
last_contact_time INT,
INDEX ip (ip),
INDEX `key` (`key`)
) type=innodb")
db.run("CREATE TABLE IF NOT EXISTS splayd_availabilities (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
splayd_id INT NOT NULL,
ip VARCHAR(255),
status ENUM('AVAILABLE','UNAVAILABLE','RESET') DEFAULT 'AVAILABLE',
time INT NOT NULL
)")
end
db = DBUtils::get_new
drop_db(db)
init_db(db)
db.disconnect