formatUptime formats seconds into a human-readable duration string.
(seconds int64)
| 313 | |
| 314 | // formatUptime formats seconds into a human-readable duration string. |
| 315 | func formatUptime(seconds int64) string { |
| 316 | if seconds <= 0 { |
| 317 | return "0s" |
| 318 | } |
| 319 | |
| 320 | d := seconds / 86400 |
| 321 | h := (seconds % 86400) / 3600 |
| 322 | m := (seconds % 3600) / 60 |
| 323 | s := seconds % 60 |
| 324 | |
| 325 | switch { |
| 326 | case d > 0: |
| 327 | return fmt.Sprintf("%dd%dh%dm", d, h, m) |
| 328 | case h > 0: |
| 329 | return fmt.Sprintf("%dh%dm", h, m) |
| 330 | case m > 0: |
| 331 | return fmt.Sprintf("%dm%ds", m, s) |
| 332 | default: |
| 333 | return fmt.Sprintf("%ds", s) |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | // findNodeIP returns the IP address of the named node. |
| 338 | func (s *cliSession) findNodeIP(ctx context.Context, nodeName string) (string, error) { |
no outgoing calls