Intento coger la información especifica de una VM a través de la API (zzantares) de proxmox.
Con este código $allNodes = $proxmox->get('/nodes/proxmox/qemu/101/status/current');print_r($allNodes);
y obtengo esto:
Array ( [data] => Array ( [template] => [diskread] => 277896704 [cpus] => 6 [disk] => 0 [diskwrite] => 72438272 [qmpstatus] => running [maxdisk] => 34359738368 [maxmem] => 1073741824 [blockstat] => Array ( [ide0] => Array ( [failed_rd_operations] => 0 [wr_highest_offset] => 11847032832 [rd_total_time_ns] => 106474497023 [timed_stats] => Array ( ) [invalid_wr_operations] => 0 [account_failed] => 1 [wr_total_time_ns] => 4990608743 [invalid_rd_operations] => 0 [idle_time_ns] => 33529812443 [wr_operations] => 12135 [rd_bytes] => 277822976 [rd_merged] => 0 [rd_operations] => 74939 [wr_merged] => 0 [flush_total_time_ns] => 43044472 [wr_bytes] => 72438272 [failed_flush_operations] => 0 [failed_wr_operations] => 0 [flush_operations] => 121 [invalid_flush_operations] => 0 [account_invalid] => 1 ) [ide2] => Array ( [rd_bytes] => 73728 [wr_operations] => 0 [rd_merged] => 0 [wr_bytes] => 0 [rd_operations] => 34 [wr_merged] => 0 [flush_total_time_ns] => 0 [failed_rd_operations] => 0 [rd_total_time_ns] => 3555632 [wr_highest_offset] => 0 [invalid_wr_operations] => 0 [timed_stats] => Array ( ) [account_failed] => 1 [invalid_rd_operations] => 0 [idle_time_ns] => 4409539381307 [wr_total_time_ns] => 0 [failed_wr_operations] => 0 [flush_operations] => 0 [invalid_flush_operations] => 0 [account_invalid] => 1 [failed_flush_operations] => 0 ) ) [uptime] => 4502 [nics] => Array ( [tap101i0] => Array ( [netout] => 27684 [netin] => 371054 ) ) [balloon] => 1073741824 [vmid] => 101 [mem] => 615320148 [cpu] => 0.0092101210672603 [name] => holo [netout] => 27684 [ballooninfo] => Array ( [max_mem] => 1073741824 [actual] => 1073741824 ) [netin] => 371054 [pid] => 815184 [status] => running [ha] => Array ( [managed] => 0 ) ) )
¿Cómo podría por ejemplo obtener de todo ese array únicamente la información de cpus? (a mostrar sería el 6) thanks
var_dump($allNodes);
. La salida que muestras impide ver la estructura real del objeto. Por ejemplo, hay dos claves seguidas:[template] => [diskread]
que son muy confusas. Pulsa en editar para agregarlo. Gracias.