优化Z轴
This commit is contained in:
@@ -626,8 +626,8 @@ async function recordTrafficStats() {
|
||||
const [rxBytesRes, txBytesRes, rxBWRes, txBWRes] = await Promise.all([
|
||||
prometheusService.query(source.url, 'sum(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"})'),
|
||||
prometheusService.query(source.url, 'sum(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"})'),
|
||||
prometheusService.query(source.url, 'sum(rate(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[5m]))'),
|
||||
prometheusService.query(source.url, 'sum(rate(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[5m]))')
|
||||
prometheusService.query(source.url, 'sum(rate(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[1m]))'),
|
||||
prometheusService.query(source.url, 'sum(rate(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[1m]))')
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -648,15 +648,15 @@ async function recordTrafficStats() {
|
||||
totalTxBandwidth += r.txBW;
|
||||
}
|
||||
|
||||
if (totalRxBytes > 0 || totalTxBytes > 0) {
|
||||
await db.query('INSERT INTO traffic_stats (rx_bytes, tx_bytes, rx_bandwidth, tx_bandwidth) VALUES (?, ?, ?, ?)', [
|
||||
Math.round(totalRxBytes),
|
||||
Math.round(totalTxBytes),
|
||||
totalRxBandwidth,
|
||||
totalTxBandwidth
|
||||
]);
|
||||
console.log(`[Traffic Recorder] Saved stats: BW_RX=${totalRxBandwidth}, BW_TX=${totalTxBandwidth}`);
|
||||
}
|
||||
// Always insert a record if we have sources, so the timeline advances
|
||||
// Even if traffic is 0, we want to see 0 on the chart
|
||||
await db.query('INSERT INTO traffic_stats (rx_bytes, tx_bytes, rx_bandwidth, tx_bandwidth) VALUES (?, ?, ?, ?)', [
|
||||
Math.round(totalRxBytes),
|
||||
Math.round(totalTxBytes),
|
||||
totalRxBandwidth,
|
||||
totalTxBandwidth
|
||||
]);
|
||||
console.log(`[Traffic Recorder] Saved stats: BW_RX=${totalRxBandwidth.toFixed(2)}, BW_TX=${totalTxBandwidth.toFixed(2)}`);
|
||||
} catch (err) {
|
||||
console.error('[Traffic Recorder] Error recording stats:', err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user