001/*
002 * jPOS Project [http://jpos.org]
003 * Copyright (C) 2000-2026 jPOS Software SRL
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jpos.log.evt;
020
021import com.fasterxml.jackson.annotation.JsonProperty;
022import com.fasterxml.jackson.annotation.JsonPropertyOrder;
023import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
024import org.jpos.log.AuditLogEvent;
025import java.nio.charset.Charset;
026import java.time.Duration;
027import java.util.List;
028import java.util.UUID;
029
030/**
031 * Audit event capturing a snapshot of the running JVM and host: OS / JDK
032 * identity, runtime resources (memory, threads, GC), classpath fingerprint,
033 * the process configuration, and selected runtime tables (name registrar,
034 * threads, deployed scripts).
035 *
036 * @param osName             value of {@code os.name}
037 * @param osVersion          value of {@code os.version}
038 * @param javaVersion        running JDK version
039 * @param javaVendor         running JDK vendor
040 * @param aes                maximum supported AES key size (e.g. {@code "256"})
041 *                           or a diagnostic string when probing fails
042 * @param host               host name reported by the OS
043 * @param userName           value of {@code user.name}
044 * @param cwd                current working directory
045 * @param watchService       fully-qualified class name of the active
046 *                           {@code WatchService}, or a marker when polling is in use
047 * @param environment        active jPOS environment name
048 * @param args               original command-line arguments, joined into a single string
049 * @param encoding           default platform {@link Charset}
050 * @param zoneInfo           default time-zone identifier
051 * @param processName        JVM process name (typically {@code pid@host})
052 * @param freeSpace          deploy-directory free space, formatted human-readable
053 * @param usableSpace        deploy-directory usable space, formatted human-readable
054 * @param version            jPOS version string
055 * @param revision           jPOS source revision (branch / commit)
056 * @param classPath          effective classpath, expanded against the launcher
057 *                           manifest when applicable
058 * @param classPathHash      hex SHA-1 of {@code classPath} for change-tracking
059 * @param instance           per-process random instance identifier
060 * @param uptime             elapsed time since Q2 startup
061 * @param loadAverage        OS load average over the last minute
062 * @param processors         number of available logical processors
063 * @param drift              measured wall-clock drift in milliseconds
064 * @param maxMemory          {@code Runtime.maxMemory()} in bytes
065 * @param totalMemory        {@code Runtime.totalMemory()} in bytes
066 * @param freeMemory         {@code Runtime.freeMemory()} in bytes
067 * @param inUseMemory        {@code totalMemory - freeMemory} in bytes
068 * @param gcTotalCnt         total GC collection count across all collectors
069 * @param gcTotalTime        total GC time in milliseconds across all collectors
070 * @param threadCount        live thread count
071 * @param threadPeak         peak live thread count since JVM start
072 * @param nameRegistrarEntries snapshot of the {@code NameRegistrar}, key/value pairs
073 * @param threads            snapshot of running threads, key/value pairs
074 * @param scripts            output of deployed monitoring scripts
075 */
076@JsonPropertyOrder({
077  "osName", "osVersion", "javaVersion", "javaVendor", "aes", "host", "userName", "cwd", "watch-service", "environment",
078  "args", "encoding", "zone-info", "processName", "freeSpace", "usableSpace", "version", "revision", "class-path", "class-path-hash", "instance",
079  "uptime", "loadAverage", "processors", "drift", "maxMemory", "totalMemory", "freeMemory", "inUseMemory",
080  "gcTotalCnt", "gcTotalTime", "threadCount", "threadPeak", "nameRegistrar"
081})
082public record SysInfo (
083  @JsonProperty("os-name") String osName,
084  @JsonProperty("os-version") String osVersion,
085  @JsonProperty("java-version") String javaVersion,
086  @JsonProperty("java-vendor") String javaVendor,
087  @JsonProperty("AES") String aes,
088  String host,
089  @JsonProperty("user-name") String userName,
090  @JsonProperty("cwd") String cwd,
091  @JsonProperty("watch-service") String watchService,
092  String environment,
093  String args,
094  Charset encoding,
095  @JsonProperty("zone-info") String zoneInfo,
096  @JsonProperty("process-name") String processName,
097  @JsonProperty("free-space") String freeSpace,
098  @JsonProperty("usable-space") String usableSpace,
099  String version,
100  String revision,
101  @JsonProperty("class-path") String classPath,
102  @JsonProperty("class-path-hash") String classPathHash,
103  UUID instance,
104  Duration uptime,
105  @JsonProperty("load-average") double loadAverage,
106  int processors,
107  long drift,
108  @JsonProperty("max-memory") long maxMemory,
109  @JsonProperty("total-memory") long totalMemory,
110  @JsonProperty("free-memory") long freeMemory,
111  @JsonProperty("in-use-memory") long inUseMemory,
112  @JsonProperty("gc-total-cnt") long gcTotalCnt,
113  @JsonProperty("gc-total-time") long gcTotalTime,
114  @JsonProperty("thread-count") int threadCount,
115  @JsonProperty("thread-peak") int threadPeak,
116  @JsonProperty("name-registrar") @JacksonXmlProperty(localName = "name-registrar") List<KV> nameRegistrarEntries,
117  @JsonProperty("threads") @JacksonXmlProperty(localName = "threads") List<KV> threads,
118  @JsonProperty("scripts") @JacksonXmlProperty(localName = "scripts") List<ProcessOutput> scripts
119) implements AuditLogEvent { }