diff --git a/src/db-edit.go b/src/db-edit.go index b7f811e..7bc7c7b 100644 --- a/src/db-edit.go +++ b/src/db-edit.go @@ -47,7 +47,15 @@ func db_update(oneHost Host) { db_exec(sqlStatement) } +func db_delete(hostId int) { + sqlStatement := `DELETE FROM "now" WHERE ID = '%d';` + sqlStatement = fmt.Sprintf(sqlStatement, hostId) + //fmt.Println("Delete statement:", sqlStatement) + db_exec(sqlStatement) +} + + func db_setnow() { sqlStatement := `UPDATE "now" set NOW = '0';` db_exec(sqlStatement) -} \ No newline at end of file +} diff --git a/src/main.go b/src/main.go index e64c974..8441584 100644 --- a/src/main.go +++ b/src/main.go @@ -37,11 +37,15 @@ func scan_and_compare() { db_setnow() // Mark hosts in DB as offline hosts_compare(foundHosts, dbHosts) // Compare hosts online and in DB // and add them to DB - AllHosts = db_select() + update_all_hosts() time.Sleep(time.Duration(AppConfig.Timeout) * time.Second) // Timeout } } +func update_all_hosts(){ + AllHosts = db_select() +} + func main() { AllHosts = []Host{} AppConfig = get_config() // Get config from Defaults, Config file, Env @@ -51,4 +55,4 @@ func main() { go scan_and_compare() webgui() // Start web GUI -} \ No newline at end of file +} diff --git a/src/templates/index.html b/src/templates/index.html index 43d5abc..6a48255 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -45,6 +45,7 @@