245 lines
10 KiB
Go
245 lines
10 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type SystemResources struct {
|
|
Timestamp time.Time `json:"@timestamp"`
|
|
Type string `json:"type"`
|
|
Host string `json:"host"`
|
|
CPUPercent float64 `json:"cpu_percent,omitempty"`
|
|
MemoryUsed uint64 `json:"memory_used,omitempty"`
|
|
MemoryTotal uint64 `json:"memory_total,omitempty"`
|
|
MemoryPercent float64 `json:"memory_percent,omitempty"`
|
|
DiskUsage map[string]DiskUsage `json:"disk_usage,omitempty"`
|
|
NetworkStats map[string]NetworkStat `json:"network_stats,omitempty"`
|
|
LoadAverage []float64 `json:"load_average,omitempty"`
|
|
Uptime uint64 `json:"uptime,omitempty"`
|
|
TopProcesses []ProcessInfo `json:"top_processes"`
|
|
OpenFileDescriptors int32 `json:"open_file_descriptors"`
|
|
DiskIOStats map[string]DiskIOStat `json:"disk_io_stats,omitempty"`
|
|
NetworkLatency map[string]LatencyInfo `json:"network_latency,omitempty"`
|
|
BandwidthUtilization map[string]BandwidthInfo `json:"bandwidth_utilization,omitempty"`
|
|
NetworkConnections ConnectionStats `json:"network_connections"`
|
|
TCPStats TCPStatistics `json:"tcp_stats"`
|
|
SystemLimits SystemLimitInfo `json:"system_limits"`
|
|
}
|
|
|
|
type DiskIOStat struct {
|
|
ReadBytes uint64 `json:"read_bytes"`
|
|
WriteBytes uint64 `json:"write_bytes"`
|
|
ReadOps uint64 `json:"read_ops"`
|
|
WriteOps uint64 `json:"write_ops"`
|
|
ReadTime uint64 `json:"read_time"`
|
|
WriteTime uint64 `json:"write_time"`
|
|
IOUtilization float64 `json:"io_utilization"`
|
|
AvgReadLatency float64 `json:"avg_read_latency"`
|
|
AvgWriteLatency float64 `json:"avg_write_latency"`
|
|
}
|
|
|
|
type LatencyInfo struct {
|
|
Host string `json:"host"`
|
|
MinLatency time.Duration `json:"min_latency"`
|
|
MaxLatency time.Duration `json:"max_latency"`
|
|
AvgLatency time.Duration `json:"avg_latency"`
|
|
PacketLoss float64 `json:"packet_loss"`
|
|
Jitter time.Duration `json:"jitter"`
|
|
}
|
|
|
|
type BandwidthInfo struct {
|
|
Interface string `json:"interface"`
|
|
CurrentThroughputIn float64 `json:"current_throughput_in_mbps"`
|
|
CurrentThroughputOut float64 `json:"current_throughput_out_mbps"`
|
|
PeakThroughputIn float64 `json:"peak_throughput_in_mbps"`
|
|
PeakThroughputOut float64 `json:"peak_throughput_out_mbps"`
|
|
UtilizationPercent float64 `json:"utilization_percent"`
|
|
}
|
|
|
|
type ConnectionStats struct {
|
|
TotalConnections int32 `json:"total_connections"`
|
|
EstablishedTCP int32 `json:"established_tcp"`
|
|
ListeningTCP int32 `json:"listening_tcp"`
|
|
TimeWaitTCP int32 `json:"time_wait_tcp"`
|
|
TransferConnections int32 `json:"transfer_connections"`
|
|
ConnectionsByState map[string]int32 `json:"connections_by_state"`
|
|
}
|
|
|
|
type LoadAverageInfo struct {
|
|
Load1 float64 `json:"load_1min"`
|
|
Load5 float64 `json:"load_5min"`
|
|
Load15 float64 `json:"load_15min"`
|
|
}
|
|
|
|
type TCPStatistics struct {
|
|
RetransmitRate float64 `json:"retransmit_rate"`
|
|
OutOfOrderPackets uint64 `json:"out_of_order_packets"`
|
|
LostPackets uint64 `json:"lost_packets"`
|
|
CongestionWindow uint64 `json:"congestion_window"`
|
|
TCPMemoryUsage uint64 `json:"tcp_memory_usage"`
|
|
}
|
|
|
|
type SystemLimitInfo struct {
|
|
MaxOpenFiles uint64 `json:"max_open_files"`
|
|
CurrentOpenFiles uint64 `json:"current_open_files"`
|
|
MaxProcesses uint64 `json:"max_processes"`
|
|
CurrentProcesses uint64 `json:"current_processes"`
|
|
MaxTCPConnections uint64 `json:"max_tcp_connections"`
|
|
CurrentTCPConnections uint64 `json:"current_tcp_connections"`
|
|
FileDescriptorUsage float64 `json:"file_descriptor_usage_percent"`
|
|
}
|
|
|
|
type DiskUsage struct {
|
|
Used uint64 `json:"used"`
|
|
Total uint64 `json:"total"`
|
|
UsedPercent float64 `json:"used_percent"`
|
|
Free uint64 `json:"free"`
|
|
}
|
|
|
|
type ProcessInfo struct {
|
|
PID int32 `json:"pid"`
|
|
Name string `json:"name"`
|
|
CPUPercent float64 `json:"cpu_percent"`
|
|
MemoryMB float32 `json:"memory_mb"`
|
|
Status string `json:"status"`
|
|
CreateTime int64 `json:"create_time"`
|
|
}
|
|
|
|
type NetworkStat struct {
|
|
BytesSent uint64 `json:"bytes_sent"`
|
|
BytesRecv uint64 `json:"bytes_recv"`
|
|
PacketsSent uint64 `json:"packets_sent"`
|
|
PacketsRecv uint64 `json:"packets_recv"`
|
|
}
|
|
|
|
type LogEntry struct {
|
|
Service string `json:"service,omitempty"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Type string `json:"type"`
|
|
Host string `json:"host"`
|
|
Tool string `json:"tool,omitempty"`
|
|
LogLevel string `json:"log_level"`
|
|
LogMessage string `json:"log_message,omitempty"`
|
|
SyslogInfo SyslogFields `json:"syslog_information,omitempty"`
|
|
ServiceInformation any `json:"service_info,omitempty"`
|
|
SystemMetrics any `json:"system-metrics,omitempty"`
|
|
ToolInformation any `json:"tool_info,omitempty"`
|
|
Raw string `json:"raw,omitempty"`
|
|
Priority string `json:"priority,omitempty"`
|
|
PriorityName string `json:"priority_name,omitempty"`
|
|
Unit string `json:"unit,omitempty"`
|
|
PID int `json:"pid,omitempty"`
|
|
BootID string `json:"boot_id,omitempty"`
|
|
MachineID string `json:"machine_id,omitempty"`
|
|
Fields map[string]any `json:"fields,omitempty"`
|
|
}
|
|
|
|
type SyslogFields struct {
|
|
SysLogTimestamp time.Time `json:"syslog_timestamp,omitempty"`
|
|
Hostname string `json:"hostname,omitempty"`
|
|
ProcessInfo string `json:"process_info"`
|
|
Raw string `json:"raw,omitempty"`
|
|
Priority string `json:"priority,omitempty"`
|
|
Unit string `json:"unit,omitempty"`
|
|
PID int `json:"pid,omitempty"`
|
|
BootID string `json:"boot_id,omitempty"`
|
|
MachineID string `json:"machine_id,omitempty"`
|
|
Fields map[string]any `json:"fields"`
|
|
}
|
|
|
|
func NewLogEntry(entryType string) LogEntry {
|
|
return LogEntry{
|
|
Timestamp: time.Now(),
|
|
Type: entryType,
|
|
Host: hostname,
|
|
}
|
|
}
|
|
|
|
func NewSystemResources() SystemResources {
|
|
return SystemResources{
|
|
Timestamp: time.Now(),
|
|
Type: "system_metrics",
|
|
Host: hostname,
|
|
DiskUsage: make(map[string]DiskUsage),
|
|
DiskIOStats: make(map[string]DiskIOStat),
|
|
NetworkStats: make(map[string]NetworkStat),
|
|
NetworkLatency: make(map[string]LatencyInfo),
|
|
BandwidthUtilization: make(map[string]BandwidthInfo),
|
|
}
|
|
}
|
|
|
|
type AMBaseInfo struct {
|
|
ProcessID string `json:"process_id"`
|
|
ThreadID string `json:"thread_id"`
|
|
LoggerName string `json:"logger_name"`
|
|
}
|
|
|
|
type TCCBaseInfo struct {
|
|
ProcessID string `json:"process_id"`
|
|
ThreadID string `json:"thread_id"`
|
|
LoggerName string `json:"logger_name"`
|
|
}
|
|
|
|
type NGinXBaseInfo struct {
|
|
ClientIP string `json:"client_ip"`
|
|
RemoteUser string `json:"remote_user"`
|
|
Request string `json:"request"`
|
|
StatusCode int `json:"status_code"`
|
|
BytesSend int `json:"bytes_sent"`
|
|
Referer string `json:"referer"`
|
|
UserAgent string `json:"user_agent"`
|
|
HTTPMethod string `json:"http_method"`
|
|
RequestURI string `json:"request_uri"`
|
|
HTTPVersion string `json:"http_version"`
|
|
Route string `json:"route"`
|
|
}
|
|
|
|
type TSTransferInfo struct {
|
|
TransferID string `json:"transfer_identifier,omitempty"`
|
|
Lane int `json:"lane,omitempty"`
|
|
StartTime time.Time `json:"start_time,omitempty"`
|
|
EndTime time.Time `json:"end_time,omitempty"`
|
|
Buffers int `json:"buffers,omitempty"`
|
|
Streams int `json:"streams,omitempty"`
|
|
ChunkSize int `json:"chunksize,omitempty"`
|
|
TransferLane string `json:"transfer_lane,omitempty"`
|
|
FileCount int `json:"file_count,omitempty"`
|
|
FileSizeMB float64 `json:"file_size_mb,omitempty"`
|
|
DataRateMBs float64 `json:"datarate_mbs,omitempty"`
|
|
TargetDatarate float64 `json:"target_datarate,omitempty"`
|
|
Protocoll string `json:"protocoll,omitempty"`
|
|
Target string `json:"transfer_target,omitempty"`
|
|
Dest string `json:"destination,omitempty"`
|
|
Src string `json:"source,omitempty"`
|
|
SenderID string `json:"sender_id,omitempty"`
|
|
Receiver string `json:"receiver,omitempty"`
|
|
BytesProcessed int64 `json:"bytes_processed,omitempty"`
|
|
Direction string `json:"direction,omitempty"`
|
|
Duration time.Duration `json:"duration_seconds,omitempty"`
|
|
TheoreticalRate float64 `json:"theoretical_rate_mbs,omitempty"`
|
|
Efficiency float64 `json:"efficiency_percent,omitempty"`
|
|
Status string `json:"status,omitempty"`
|
|
}
|
|
|
|
type TJMTransferInfo struct {
|
|
TransferID string `json:"transfer_identifier,omitempty"`
|
|
TransferName string `json:"transfer_name,omitempty"`
|
|
ProcessID string `json:"process_id,omitempty"`
|
|
Username string `json:"username,omitempty"`
|
|
CorrelationID string `json:"correlation_id,omitempty"`
|
|
ThreadID string `json:"thread_id,omitempty"`
|
|
JavaClass string `json:"java_class,omitempty"`
|
|
StartTime time.Time `json:"start_time,omitempty"`
|
|
EndTime time.Time `json:"end_time,omitempty"`
|
|
TransferLane string `json:"transfer_lane,omitempty"`
|
|
Dest string `json:"destination,omitempty"`
|
|
Src string `json:"source,omitempty"`
|
|
SenderID string `json:"sender_id,omitempty"`
|
|
Receiver string `json:"receiver,omitempty"`
|
|
Direction string `json:"direction,omitempty"`
|
|
Worker string `json:"worker,omitempty"`
|
|
Duration time.Duration `json:"duration,omitempty"`
|
|
DataRateMBs float64 `json:"datarate_mbs,omitempty"`
|
|
BytesProcessed int64 `json:"bytes_processed,omitempty"`
|
|
FileSizeMB float64 `json:"file_size_mb,omitempty"`
|
|
}
|