checker: Add new level of verbosity

This commit is contained in:
nemunaire 2021-10-31 17:42:07 +01:00
parent 805b654170
commit a241aebcb4
2 changed files with 18 additions and 0 deletions

View File

@ -25,6 +25,7 @@ const (
var ( var (
verbose = false verbose = false
verbose2 = false
domainsHostingMap = map[string]string{} domainsHostingMap = map[string]string{}
) )
@ -34,6 +35,9 @@ func check_ping(ip string, cb func(pkt *ping.Packet)) (err error) {
var pinger *ping.Pinger var pinger *ping.Pinger
pinger, err = ping.NewPinger(ip) pinger, err = ping.NewPinger(ip)
if err != nil { if err != nil {
if verbose {
log.Printf("check_ping: %s: %s", ip, err.Error())
}
return return
} }
defer pinger.Stop() defer pinger.Stop()
@ -571,11 +575,20 @@ func studentsChecker() {
std := s std := s
tuns, err := std.GetActivesTunnels() tuns, err := std.GetActivesTunnels()
if err != nil { if err != nil {
if verbose2 {
log.Printf("SKip %s due to error when getting active tunnels: %s", std.Login, err.Error())
}
continue continue
} }
if verbose2 && len(tuns) == 0 {
log.Printf("%s has no active tunnels: %s", std.Login, err.Error())
}
for _, tun := range tuns { for _, tun := range tuns {
stdIP := tun.GetStudentIP() stdIP := tun.GetStudentIP()
if verbose2 {
log.Printf("Tests %s on %s...", std.Login, stdIP)
}
go check_ping(stdIP, func(pkt *ping.Packet) { go check_ping(stdIP, func(pkt *ping.Packet) {
tunnel_version, err := minTunnelVersion(std, tun.SuffixIP) tunnel_version, err := minTunnelVersion(std, tun.SuffixIP)
if verbose { if verbose {

View File

@ -14,8 +14,13 @@ import (
func main() { func main() {
var dsn = flag.String("dsn", adlin.DSNGenerator(), "DSN to connect to the MySQL server") var dsn = flag.String("dsn", adlin.DSNGenerator(), "DSN to connect to the MySQL server")
flag.BoolVar(&verbose, "verbose", verbose, "Enable verbose mode") flag.BoolVar(&verbose, "verbose", verbose, "Enable verbose mode")
flag.BoolVar(&verbose2, "verbose2", verbose2, "Enable more verbose mode")
flag.Parse() flag.Parse()
if verbose2 && !verbose {
verbose = verbose2
}
// Initialize contents // Initialize contents
log.Println("Opening database...") log.Println("Opening database...")
if err := adlin.DBInit(*dsn); err != nil { if err := adlin.DBInit(*dsn); err != nil {