Update docs

This commit is contained in:
Raven Scott
2026-05-28 12:39:38 -04:00
parent 564029af44
commit 343102d4b5
15 changed files with 289 additions and 561 deletions
+26 -10
View File
@@ -513,19 +513,35 @@ curl -k "https://p2ns.admin/api/stats/historical?minutes=1440"
### JavaScript Stats Monitoring
```javascript
async function getStats() {
// One-shot HTTP load (admin UI uses this once on tab open)
async function getStatsOnce() {
const response = await fetch('https://p2ns.admin/api/stats');
const stats = await response.json();
console.log('Total requests:', stats.requests?.total);
console.log('Success rate:', stats.requests?.successRate);
console.log('Holesail connections:', stats.holesailChildren?.length);
return stats;
return response.json();
}
// Get stats every 10 seconds
setInterval(getStats, 10000);
// Live updates via WebSocket (preferred)
const ws = new WebSocket('wss://p2ns.admin/ws');
ws.onopen = () => ws.send(JSON.stringify({ type: 'subscribe-stats' }));
ws.onmessage = (ev) => {
const msg = JSON.parse(ev.data);
if (msg.type === 'stats-snapshot') {
console.log('Core RPC:', msg.stats?.core?.summary);
console.log('Plugin RPC protocols:', msg.stats?.pluginRpc?.totalProtocols);
}
};
```
### Tail logs over WebSocket
```javascript
const ws = new WebSocket('wss://p2ns.admin/ws');
ws.onopen = () => {
ws.send(JSON.stringify({ type: 'subscribe-log', channel: 'dns', lines: 500 }));
};
ws.onmessage = (ev) => {
const msg = JSON.parse(ev.data);
if (msg.type === 'file-log' && msg.channel === 'dns') console.log(msg.message);
};
```
## Consensus Examples