|
| 1 | +# Advanced: API payload reference |
| 2 | + |
| 3 | +Endpoint: `POST /api/report.php` |
| 4 | + |
| 5 | +## Headers |
| 6 | +- `Content-Type: application/json` |
| 7 | +- Optional: `X-Agent-Token: <64-hex>` |
| 8 | + |
| 9 | +## Required fields |
| 10 | +- `hostname` |
| 11 | +- `metrics` |
| 12 | + |
| 13 | +## Units |
| 14 | +- RAM: MB |
| 15 | +- Disk: KB |
| 16 | +- Network counters: bytes |
| 17 | + |
| 18 | +## Token rules |
| 19 | +- Format: 64 hex chars. |
| 20 | +- Invalid tokens are ignored. |
| 21 | +- Token is accepted from header or `agent.token`. |
| 22 | + |
| 23 | +## CPU value |
| 24 | +`metrics.cpu` is agent-defined: |
| 25 | +- Windows agent sends a 0..1 fraction. |
| 26 | +- Linux agent currently sends load average (string). |
| 27 | + |
| 28 | +## JSON Schema (simplified) |
| 29 | +```json |
| 30 | +{ |
| 31 | + "$schema": "https://json-schema.org/draft/2020-12/schema", |
| 32 | + "type": "object", |
| 33 | + "required": ["hostname", "metrics"], |
| 34 | + "properties": { |
| 35 | + "hostname": { "type": "string" }, |
| 36 | + "agent": { |
| 37 | + "type": "object", |
| 38 | + "properties": { |
| 39 | + "token": { "type": "string", "pattern": "^[a-fA-F0-9]{64}$" } |
| 40 | + }, |
| 41 | + "additionalProperties": true |
| 42 | + }, |
| 43 | + "machine": { |
| 44 | + "type": "object", |
| 45 | + "properties": { |
| 46 | + "cpu_arch": { "type": "string" }, |
| 47 | + "cpu_model": { "type": "string" }, |
| 48 | + "cpu_vendor": { "type": "string" }, |
| 49 | + "cpu_cores": { "type": "integer" }, |
| 50 | + "cpu_max_mhz": { "type": ["number", "string"] }, |
| 51 | + "cpu_min_mhz": { "type": ["number", "string"] }, |
| 52 | + "virtualization": { "type": "string" }, |
| 53 | + "fs_root": { "type": "string" }, |
| 54 | + "machine_id": { "type": "string" }, |
| 55 | + "boot_id": { "type": "string" }, |
| 56 | + "dmi_uuid": { "type": "string" }, |
| 57 | + "dmi_serial": { "type": "string" }, |
| 58 | + "board_serial": { "type": "string" }, |
| 59 | + "macs": { "type": "string" }, |
| 60 | + "disks": { "type": "string" }, |
| 61 | + "disks_json": { "type": ["array", "string"] } |
| 62 | + }, |
| 63 | + "additionalProperties": true |
| 64 | + }, |
| 65 | + "metrics": { |
| 66 | + "type": "object", |
| 67 | + "required": ["cpu", "ram_used", "ram_total", "disk_used", "disk_total"], |
| 68 | + "properties": { |
| 69 | + "os": { "type": "string" }, |
| 70 | + "kernel": { "type": "string" }, |
| 71 | + "cpu": { "type": ["number", "string"] }, |
| 72 | + "cpu_load_5": { "type": ["number", "string"] }, |
| 73 | + "cpu_load_15": { "type": ["number", "string"] }, |
| 74 | + "public_ip": { "type": "string" }, |
| 75 | + "ram_used": { "type": "integer" }, |
| 76 | + "ram_total": { "type": "integer" }, |
| 77 | + "swap_used": { "type": "integer" }, |
| 78 | + "swap_total": { "type": "integer" }, |
| 79 | + "disk_used": { "type": "integer" }, |
| 80 | + "disk_total": { "type": "integer" }, |
| 81 | + "rx_bytes": { "type": "integer" }, |
| 82 | + "tx_bytes": { "type": "integer" }, |
| 83 | + "processes": { "type": "integer" }, |
| 84 | + "zombies": { "type": "integer" }, |
| 85 | + "failed_services": { "type": "integer" }, |
| 86 | + "open_ports": { "type": "integer" }, |
| 87 | + "uptime": { "type": "string" }, |
| 88 | + "filesystems_json": { "type": ["array", "string"] } |
| 89 | + }, |
| 90 | + "additionalProperties": true |
| 91 | + }, |
| 92 | + "service_issues": { |
| 93 | + "type": "array", |
| 94 | + "items": { |
| 95 | + "type": "object", |
| 96 | + "required": ["service", "new_unique_logs"], |
| 97 | + "properties": { |
| 98 | + "service": { "type": "string" }, |
| 99 | + "new_unique_logs": { "type": "string" }, |
| 100 | + "priority": { "type": "string" }, |
| 101 | + "active_state": { "type": "string" }, |
| 102 | + "sub_state": { "type": "string" }, |
| 103 | + "exec_status": { "type": "string" }, |
| 104 | + "restarts": { "type": ["string", "integer"] } |
| 105 | + }, |
| 106 | + "additionalProperties": true |
| 107 | + } |
| 108 | + } |
| 109 | + }, |
| 110 | + "additionalProperties": true |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +## Minimal payload example |
| 115 | +```json |
| 116 | +{ |
| 117 | + "hostname": "srv-1", |
| 118 | + "metrics": { |
| 119 | + "cpu": 0.12, |
| 120 | + "ram_used": 512, |
| 121 | + "ram_total": 2048, |
| 122 | + "disk_used": 1048576, |
| 123 | + "disk_total": 8388608, |
| 124 | + "rx_bytes": 12000, |
| 125 | + "tx_bytes": 9000 |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Full payload example (Linux-style) |
| 131 | +```json |
| 132 | +{ |
| 133 | + "hostname": "srv-1", |
| 134 | + "agent": { "token": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" }, |
| 135 | + "machine": { |
| 136 | + "cpu_model": "Intel(R) Xeon(R)", |
| 137 | + "cpu_vendor": "GenuineIntel", |
| 138 | + "cpu_cores": 4, |
| 139 | + "cpu_arch": "x86_64", |
| 140 | + "cpu_max_mhz": "3600.0000", |
| 141 | + "cpu_min_mhz": "800.0000", |
| 142 | + "virtualization": "kvm", |
| 143 | + "fs_root": "ext4", |
| 144 | + "machine_id": "abcdef", |
| 145 | + "boot_id": "123456", |
| 146 | + "dmi_uuid": "uuid-here", |
| 147 | + "dmi_serial": "serial-here", |
| 148 | + "board_serial": "board-serial", |
| 149 | + "macs": "00:11:22:33:44:55", |
| 150 | + "disks": "sda:disk:ssd:Samsung", |
| 151 | + "disks_json": [ |
| 152 | + { "name": "sda", "size": "100G", "media": "ssd", "model": "Samsung" } |
| 153 | + ] |
| 154 | + }, |
| 155 | + "metrics": { |
| 156 | + "os": "Ubuntu 22.04", |
| 157 | + "kernel": "5.15.0", |
| 158 | + "cpu": "0.35", |
| 159 | + "cpu_load_5": "0.20", |
| 160 | + "cpu_load_15": "0.10", |
| 161 | + "ram_used": 1024, |
| 162 | + "ram_total": 4096, |
| 163 | + "swap_used": 0, |
| 164 | + "swap_total": 0, |
| 165 | + "disk_used": 2097152, |
| 166 | + "disk_total": 8388608, |
| 167 | + "rx_bytes": 1234567, |
| 168 | + "tx_bytes": 7654321, |
| 169 | + "processes": 132, |
| 170 | + "zombies": 0, |
| 171 | + "failed_services": 0, |
| 172 | + "open_ports": 12, |
| 173 | + "uptime": "up 2 days, 3 hours", |
| 174 | + "public_ip": "203.0.113.10", |
| 175 | + "filesystems_json": [ |
| 176 | + { "filesystem": "/dev/sda1", "fstype": "ext4", "total_kb": 8388608, "used_kb": 2097152, "used_percent": 25, "mount": "/" } |
| 177 | + ] |
| 178 | + }, |
| 179 | + "service_issues": [ |
| 180 | + { |
| 181 | + "service": "nginx", |
| 182 | + "new_unique_logs": "failed to start\\nport already in use", |
| 183 | + "priority": "high", |
| 184 | + "active_state": "failed", |
| 185 | + "sub_state": "dead", |
| 186 | + "exec_status": "1", |
| 187 | + "restarts": "3" |
| 188 | + } |
| 189 | + ] |
| 190 | +} |
| 191 | +``` |
0 commit comments