Comments
This commit is contained in:
parent
442d35c5ba
commit
3503cb775f
1 changed files with 3 additions and 6 deletions
|
|
@ -5,7 +5,7 @@ import (
|
|||
"log"
|
||||
)
|
||||
|
||||
func host_in_db(host Host, dbHosts []Host) bool {
|
||||
func host_in_db(host Host, dbHosts []Host) bool { // Check if host is already in DB
|
||||
for _, oneHost := range dbHosts {
|
||||
if host.Ip == oneHost.Ip && host.Mac == oneHost.Mac && host.Hw == oneHost.Hw {
|
||||
oneHost.Date = host.Date
|
||||
|
|
@ -18,15 +18,12 @@ func host_in_db(host Host, dbHosts []Host) bool {
|
|||
}
|
||||
|
||||
func hosts_compare(foundHosts []Host, dbHosts []Host) {
|
||||
// fmt.Println("Found hosts:", foundHosts)
|
||||
// fmt.Println("DB hosts:", dbHosts)
|
||||
|
||||
for _, oneHost := range foundHosts {
|
||||
if !(host_in_db(oneHost, dbHosts)) {
|
||||
oneHost.Now = 1
|
||||
oneHost.Now = 1 // Mark host online
|
||||
msg := fmt.Sprintf("UNKNOWN HOST IP: '%s', MAC: '%s', Hw: '%s'", oneHost.Ip, oneHost.Mac, oneHost.Hw)
|
||||
log.Println("WARN:", msg)
|
||||
shoutr_notify(msg)
|
||||
shoutr_notify(msg) // Notify through Shoutrrr
|
||||
db_insert(oneHost)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue