forked from neverno/OpenStatus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-db.py
executable file
·20 lines (17 loc) · 1.36 KB
/
update-db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python
# This script updates the database to handle version 0.4.0 stuff.
# Since this is the first change to the database schema, we don't really have to check anything
import sqlite3
db = sqlite3.connect('/etc/openstatus/openstatus.db', check_same_thread = False, isolation_level=None)
db.row_factory=sqlite3.Row
sql = db.cursor()
try:
sql.execute('CREATE TABLE IF NOT EXISTS "history" ( "uid" INTEGER, "time" INTEGER, "mtotal" TEXT, "mused" TEXT, "mfree" TEXT, "mbuffers" TEXT, "disktotal" TEXT, "diskused" TEXT, "diskfree" TEXT, "load1" TEXT, "load5" TEXT, "load15" TEXT, "rx" TEXT, "tx" TEXT)')
sql.execute('CREATE TABLE IF NOT EXISTS "history5" ( "uid" INTEGER, "time" INTEGER, "mtotal" TEXT, "mused" TEXT, "mfree" TEXT, "mbuffers" TEXT, "disktotal" TEXT, "diskused" TEXT, "diskfree" TEXT, "load1" TEXT, "load5" TEXT, "load15" TEXT, "rx" TEXT, "tx" TEXT)')
sql.execute('CREATE TABLE IF NOT EXISTS "history10" ( "uid" INTEGER, "time" INTEGER, "mtotal" TEXT, "mused" TEXT, "mfree" TEXT, "mbuffers" TEXT, "disktotal" TEXT, "diskused" TEXT, "diskfree" TEXT, "load1" TEXT, "load5" TEXT, "load15" TEXT, "rx" TEXT, "tx" TEXT)')
sql.execute('ALTER TABLE servers ADD COLUMN "provider" TEXT;')
sql.execute('ALTER TABLE servers ADD COLUMN "node" TEXT;')
sql.execute('ALTER TABLE servers ADD COLUMN "tx" TEXT;')
sql.execute('ALTER TABLE servers ADD COLUMN "rx" TEXT;')
except:
pass