2026-03-27 23:49:25 +01:00
..
2026-03-27 23:49:25 +01:00
2026-03-27 23:49:25 +01:00
2026-03-27 23:49:25 +01:00
2026-03-27 23:49:25 +01:00
2026-03-27 22:16:11 +01:00
2026-03-27 22:16:11 +01:00

Process Monitor API (Java 11)

Small Java 11 application that exposes POST /hb/api using com.sun.net.httpserver.HttpServer and stores received heartbeat records into MariaDB. JSON parsing uses Gson and the app logs incoming requests plus insert results to stdout.

Request shape

Expected JSON body:

{
  "machine_name": "PC-01",
  "status": "running",
  "detected_at": "2026-03-27T21:00:00Z",
  "processes": ["chrome.exe", "discord.exe"]
}

If processes is omitted, the application still stores one row with process_name = NULL.

Table DDL

CREATE DATABASE IF NOT EXISTS process_monitor
  CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

USE process_monitor;

CREATE TABLE IF NOT EXISTS process_heartbeat (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    machine_name VARCHAR(128) NOT NULL,
    status VARCHAR(32) NOT NULL,
    detected_at DATETIME(3) NOT NULL,
    process_name VARCHAR(255) NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    KEY idx_process_heartbeat_machine_detected (machine_name, detected_at),
    KEY idx_process_heartbeat_process_detected (process_name, detected_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Configure

Edit src/main/resources/application.properties.

Run

mvn exec:java

Package

mvn package