Your descriptive commit message
This commit is contained in:
23
test_rrd51.php
Normal file
23
test_rrd51.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$s = Paymenter\Extensions\Servers\Proxmox\Models\Server::find(51);
|
||||
echo 'VM: ' . $s->vm_id . PHP_EOL;
|
||||
$node = $s->node->name;
|
||||
echo 'Node: ' . $node . PHP_EOL;
|
||||
$p = new Paymenter\Extensions\Servers\Proxmox\Proxmox;
|
||||
$status = $p->request('/nodes/' . $node . '/qemu/' . $s->vm_id . '/status/current');
|
||||
$sd = $status->json()['data'] ?? [];
|
||||
echo 'Status: ' . ($sd['status'] ?? 'unknown') . PHP_EOL;
|
||||
$resp = $p->request('/nodes/' . $node . '/qemu/' . $s->vm_id . '/rrddata', data: ['timeframe' => 'hour', 'cf' => 'AVERAGE']);
|
||||
echo 'HTTP: ' . $resp->status() . PHP_EOL;
|
||||
$data = $resp->json()['data'] ?? [];
|
||||
echo 'Points: ' . count($data) . PHP_EOL;
|
||||
if (!empty($data)) {
|
||||
$last = end($data);
|
||||
echo 'Keys: ' . implode(', ', array_keys($last)) . PHP_EOL;
|
||||
foreach(['cpu','mem','maxmem','netin','netout','diskread','diskwrite','time'] as $k) {
|
||||
echo $k . '=' . ($last[$k] ?? 'NULL') . PHP_EOL;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user