...
1 package main
2
3 import (
4 "fmt"
5 "golang.conradwood.net/go-easyops/linux"
6 "strings"
7 "time"
8 )
9
10 func check_with_duration(dur time.Duration, com []string) {
11 coms := strings.Join(com, " ")
12 fmt.Printf("executing \"%s\", max runtime %0.2fs\n", coms, dur.Seconds())
13 started := time.Now()
14 l := linux.New()
15 l.SetMaxRuntime(dur)
16 out, err := l.SafelyExecute(com, nil)
17 if err != nil {
18 fmt.Printf("\"%s\" failed (%s)\n", coms, err)
19 fmt.Println(out)
20 }
21 exectime := time.Since(started)
22 fmt.Printf("Execution time: %0.2fs\n", exectime.Seconds())
23 }
24
View as plain text