checker: Add new level of verbosity
This commit is contained in:
parent
805b654170
commit
a241aebcb4
@ -25,6 +25,7 @@ const (
|
||||
|
||||
var (
|
||||
verbose = false
|
||||
verbose2 = false
|
||||
domainsHostingMap = map[string]string{}
|
||||
)
|
||||
|
||||
@ -34,6 +35,9 @@ func check_ping(ip string, cb func(pkt *ping.Packet)) (err error) {
|
||||
var pinger *ping.Pinger
|
||||
pinger, err = ping.NewPinger(ip)
|
||||
if err != nil {
|
||||
if verbose {
|
||||
log.Printf("check_ping: %s: %s", ip, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
defer pinger.Stop()
|
||||
@ -571,11 +575,20 @@ func studentsChecker() {
|
||||
std := s
|
||||
tuns, err := std.GetActivesTunnels()
|
||||
if err != nil {
|
||||
if verbose2 {
|
||||
log.Printf("SKip %s due to error when getting active tunnels: %s", std.Login, err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
if verbose2 && len(tuns) == 0 {
|
||||
log.Printf("%s has no active tunnels: %s", std.Login, err.Error())
|
||||
}
|
||||
|
||||
for _, tun := range tuns {
|
||||
stdIP := tun.GetStudentIP()
|
||||
if verbose2 {
|
||||
log.Printf("Tests %s on %s...", std.Login, stdIP)
|
||||
}
|
||||
go check_ping(stdIP, func(pkt *ping.Packet) {
|
||||
tunnel_version, err := minTunnelVersion(std, tun.SuffixIP)
|
||||
if verbose {
|
||||
|
@ -14,8 +14,13 @@ import (
|
||||
func main() {
|
||||
var dsn = flag.String("dsn", adlin.DSNGenerator(), "DSN to connect to the MySQL server")
|
||||
flag.BoolVar(&verbose, "verbose", verbose, "Enable verbose mode")
|
||||
flag.BoolVar(&verbose2, "verbose2", verbose2, "Enable more verbose mode")
|
||||
flag.Parse()
|
||||
|
||||
if verbose2 && !verbose {
|
||||
verbose = verbose2
|
||||
}
|
||||
|
||||
// Initialize contents
|
||||
log.Println("Opening database...")
|
||||
if err := adlin.DBInit(*dsn); err != nil {
|
||||
|
Reference in New Issue
Block a user