mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Rewrite system monitoring to use OSHI (#2255)
## Description [OSHI](https://github.com/oshi/oshi) is a free (MIT license) JNA-based library for accessing hardware and system performance information. This PR includes a re-write of the metrics monitoring code to be based on OSHI. The original intent was to gain access to data about network traffic for addition to the Settings tab. An additional benefit is that collecting the data is now around two orders of magnitude (or more) faster! ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [x] If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2 - [x] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --------- Co-authored-by: samfreund <samf.236@proton.me>
This commit is contained in:
@@ -33,6 +33,7 @@ import org.photonvision.common.hardware.HardwareManager;
|
||||
import org.photonvision.common.hardware.OsImageData;
|
||||
import org.photonvision.common.hardware.PiVersion;
|
||||
import org.photonvision.common.hardware.Platform;
|
||||
import org.photonvision.common.hardware.metrics.SystemMonitor;
|
||||
import org.photonvision.common.logging.KernelLogLogger;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.LogLevel;
|
||||
@@ -298,6 +299,10 @@ public class Main {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
logger.debug("Loading SystemMonitor...");
|
||||
SystemMonitor.getInstance().logSystemInformation();
|
||||
SystemMonitor.getInstance().startMonitor(500, 1000);
|
||||
|
||||
// todo - should test mode just add test mode sources, but still allow local usb cameras to be
|
||||
// added?
|
||||
if (!isTestMode) {
|
||||
|
||||
@@ -994,11 +994,6 @@ public class RequestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMetricsPublishRequest(Context ctx) {
|
||||
HardwareManager.getInstance().publishMetrics();
|
||||
ctx.status(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calibration JSON for a specific observation. Excludes camera image data
|
||||
*
|
||||
|
||||
@@ -135,7 +135,6 @@ public class Server {
|
||||
app.get("/api/utils/photonvision-journalctl.txt", RequestHandler::onLogExportRequest);
|
||||
app.post("/api/utils/restartProgram", RequestHandler::onProgramRestartRequest);
|
||||
app.post("/api/utils/restartDevice", RequestHandler::onDeviceRestartRequest);
|
||||
app.post("/api/utils/publishMetrics", RequestHandler::onMetricsPublishRequest);
|
||||
app.get("/api/utils/getImageSnapshots", RequestHandler::onImageSnapshotsRequest);
|
||||
app.get("/api/utils/getCalSnapshot", RequestHandler::onCalibrationSnapshotRequest);
|
||||
app.get("/api/utils/getCalibrationJSON", RequestHandler::onCalibrationExportRequest);
|
||||
|
||||
Reference in New Issue
Block a user