Re: [PATCH 1/3] tools/kvm_stat: add command line switch '-z' to skip zero records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 31/03/20 22:00, Stefan Raspl wrote:
> @@ -1523,14 +1535,20 @@ def log(stats, opts, frmt, keys):
>      """Prints statistics as reiterating key block, multiple value blocks."""
>      line = 0
>      banner_repeat = 20
> +    banner_printed = False
> +
>      while True:
>          try:
>              time.sleep(opts.set_delay)
> -            if line % banner_repeat == 0:
> +            if line % banner_repeat == 0 and not banner_printed:
>                  print(frmt.get_banner())
> -            print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") +
> -                  frmt.get_statline(keys, stats.get()))
> +                banner_printed = True

Can't skip_zero_records be handled here instead?

    values = stats.get()
    if not opts.skip_zero_records or \
        any((values[k].delta != 0 for k in keys):
       statline = frmt.get_statline(keys, values)
       print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + statline)

Paolo

> +            print(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + statline)
>              line += 1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux