Update docs
This commit is contained in:
+26
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user