disk device stats via api call / cmdline

RolandK

Renowned Member
Mar 5, 2019
963
191
88
51
hi,

i searched for quite a while how to get to more detailed VM stats via api/cmdline and was lead to multiple wrong paths/dead ends.

eventually, i found that default text-based output of "pvesh get" is severely crippled, but you get to all of the vm performance/statistics data when you use json based output instead. it looks this isn't documented anywhere!? i would add an RFE to proxmox bugzilla then.

here is an example to get the bytes read and written to/from scsi0 disk:

Code:
# pvesh get nodes/pve-node6/qemu/223/status/current --output-format=json | jq -jr '"scsi0.rd_bytes="
,.blockstat.scsi0.rd_bytes ,"," , "scsi0.wr_bytes=",.blockstat.scsi0.wr_bytes,"\n"'

scsi0.rd_bytes:190018602496,scsi0.wr_bytes:93583524352

Code:
# pvesh get nodes/pve-node6/qemu/223/status/current --output-format=text

Code:
┌─────────────────┬────────────────────┐
│ key             │ value              │
╞═════════════════╪════════════════════╡
│ agent           │ 1                  │
├─────────────────┼────────────────────┤
│ cpus            │ 4                  │
├─────────────────┼────────────────────┤
│ ha              │ {"managed":0}      │
├─────────────────┼────────────────────┤
│ lock            │ backup             │
├─────────────────┼────────────────────┤
│ maxdisk         │ 40.00 GiB          │
├─────────────────┼────────────────────┤
│ maxmem          │ 8.00 GiB           │
├─────────────────┼────────────────────┤
│ name            │ gitlab │
├─────────────────┼────────────────────┤
│ pid             │ 27590              │
├─────────────────┼────────────────────┤
│ qmpstatus       │ running            │
├─────────────────┼────────────────────┤
│ running-machine │ pc-i440fx-5.2+pve0 │
├─────────────────┼────────────────────┤
│ running-qemu    │ 5.2.0              │
├─────────────────┼────────────────────┤
│ status          │ running            │
├─────────────────┼────────────────────┤
│ uptime          │ 17w 1d 12h 51m     │
├─────────────────┼────────────────────┤
│ vmid            │ 223                │
└─────────────────┴────────────────────┘

Code:
# pvesh get nodes/pve-node6/qemu/223/status/current --output-format=json|jq "."|head -n30

Code:
{
  "agent": 1,
  "balloon": 8589934592,
  "ballooninfo": {
    "actual": 8589934592,
    "free_mem": 572932096,
    "last_update": 1677352844,
    "major_page_faults": 3596724,
    "max_mem": 8589934592,
    "mem_swapped_in": 457097216,
    "mem_swapped_out": 882458624,
    "minor_page_faults": 23990786471,
    "total_mem": 8200802304
  },
  "blockstat": {
    "ide2": {
      "account_failed": false,
      "account_invalid": false,
      "failed_flush_operations": 0,
      "failed_rd_operations": 0,
      "failed_unmap_operations": 0,
      "failed_wr_operations": 0,
      "flush_operations": 0,
      "flush_total_time_ns": 0,
      "idle_time_ns": 10414516232180416,
      "invalid_flush_operations": 0,
      "invalid_rd_operations": 0,
      "invalid_unmap_operations": 0,
      "invalid_wr_operations": 0,
      "rd_bytes": 152,
 
Last edited:
I would just put it in the "lesson learned" box. Text output is for humans, json - for automated tools. Always use json or some other structured output for processing.

As for documentation - "man pvesh" :
Code:
FORMAT_OPTIONS
       It is possible to specify the output format using the --output-format parameter. The default format text uses ASCII-art to draw nice borders around tables. It additionally transforms some values into human-readable
       text, for example:

Pretty ascii-art tables can fit so much data before they stop being pretty.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
yes, but following the unix paradigm, it's not obvious that output modifiers which switch appearance of the output also switch the contents of the output. that should at least be documented.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!