(ctx context.Context, args []string)
| 880 | } |
| 881 | |
| 882 | func runDaemonMetrics(ctx context.Context, args []string) error { |
| 883 | last := map[string]int64{} |
| 884 | for { |
| 885 | out, err := localClient.DaemonMetrics(ctx) |
| 886 | if err != nil { |
| 887 | return err |
| 888 | } |
| 889 | if !metricsArgs.watch { |
| 890 | Stdout.Write(out) |
| 891 | return nil |
| 892 | } |
| 893 | bs := bufio.NewScanner(bytes.NewReader(out)) |
| 894 | type change struct { |
| 895 | name string |
| 896 | from, to int64 |
| 897 | } |
| 898 | var changes []change |
| 899 | var maxNameLen int |
| 900 | for bs.Scan() { |
| 901 | line := bytes.TrimSpace(bs.Bytes()) |
| 902 | if len(line) == 0 || line[0] == '#' { |
| 903 | continue |
| 904 | } |
| 905 | f := strings.Fields(string(line)) |
| 906 | if len(f) != 2 { |
| 907 | continue |
| 908 | } |
| 909 | name := f[0] |
| 910 | n, _ := strconv.ParseInt(f[1], 10, 64) |
| 911 | prev, ok := last[name] |
| 912 | if ok && prev == n { |
| 913 | continue |
| 914 | } |
| 915 | last[name] = n |
| 916 | if !ok { |
| 917 | continue |
| 918 | } |
| 919 | changes = append(changes, change{name, prev, n}) |
| 920 | if len(name) > maxNameLen { |
| 921 | maxNameLen = len(name) |
| 922 | } |
| 923 | } |
| 924 | if len(changes) > 0 { |
| 925 | format := fmt.Sprintf("%%-%ds %%+5d => %%v\n", maxNameLen) |
| 926 | for _, c := range changes { |
| 927 | fmt.Fprintf(Stdout, format, c.name, c.to-c.from, c.to) |
| 928 | } |
| 929 | io.WriteString(Stdout, "\n") |
| 930 | } |
| 931 | time.Sleep(time.Second) |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | func runVia(ctx context.Context, args []string) error { |
| 936 | switch len(args) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…