zeek/auxil/zeekjs/doc/examples/http-stats.js
Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

19 lines
460 B
JavaScript

'use strict';
const http = require('http');
// Render BigInt (count) types as strings in JSON.
BigInt.prototype.toJSON = function() {
return this.toString();
}
http.createServer((req, res) => {
let stats = {
net: zeek.invoke('get_net_stats'),
event: zeek.invoke('get_event_stats'),
zeek_version: zeek.invoke('zeek_version'),
};
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(stats));
}).listen(3000);