diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-12-16 00:10:00 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-12-16 00:10:00 -0800 |
commit | 2c03006805e6973c371dd55e0adb7077bd503699 (patch) | |
tree | d6b661a0f106025d542328f03a69d1974a7e4af0 | |
parent | ef1c084c2c8c3833d7753d079a17d6cf4b998742 (diff) |
gobgp: fix rpki cli uptime
zero uptime means gobgpd never connected to roa server.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | gobgp/cmd/rpki.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gobgp/cmd/rpki.go b/gobgp/cmd/rpki.go index 099ac115..0dd2033d 100644 --- a/gobgp/cmd/rpki.go +++ b/gobgp/cmd/rpki.go @@ -45,10 +45,14 @@ func showRPKIServer(args []string) error { } else if err != nil { return err } - s := "Up" - uptime := int64(time.Now().Sub(time.Unix(r.State.Uptime, 0)).Seconds()) + s := "Down" + uptime := "never" + if r.State.Uptime != 0 { + s = "Up" + uptime = fmt.Sprint(formatTimedelta(int64(time.Now().Sub(time.Unix(r.State.Uptime, 0)).Seconds()))) + } - fmt.Printf(format, fmt.Sprintf(r.Conf.Address), s, fmt.Sprint(formatTimedelta(uptime)), fmt.Sprintf("%d/%d", r.State.ReceivedIpv4, r.State.ReceivedIpv6)) + fmt.Printf(format, fmt.Sprintf(r.Conf.Address), s, uptime, fmt.Sprintf("%d/%d", r.State.ReceivedIpv4, r.State.ReceivedIpv6)) } return nil } |