improve data model & add initial Makefile

This commit is contained in:
Mans Ziesel 2024-12-05 16:01:58 +01:00
parent ccaa2ce40b
commit 651a7ecac6
4 changed files with 49 additions and 11 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

17
Makefile Normal file
View File

@ -0,0 +1,17 @@
GO_FILES := $(shell find . -name '*.go' -not -path './build/*')
build: $(GO_FILES)
mkdir -p build
go build -o build/zadmin-server ./cmd/server/main.go
go build -o build/zadmin-client ./cmd/client/main.go
server: ./build/zadmin-server
./build/zadmin-server
client: ./build/zadmin-client
./build/zadmin-client
clean:
rm -r build
.PHONY: clean run-server run-client

View File

@ -61,3 +61,11 @@ Datapoints collected of hosts
Ideas???
- NATS.io as a transport layer?
- mTLS
- Identification by key-file, unique per machine
- Guaranteed at least once delivery with Jetstream persistence layer
- Bulk enrollment flow:
- Admin creates a (short-lived) credential to enroll new machines
- The admin runs a installer with this credential
- The installer enrolls the device in zadmin and generates a unique package for this machine
- The installer places this package on the machine

View File

@ -30,27 +30,36 @@ type MachineModel struct {
}
type MachineData struct {
MomentCollected time.Time `json:"moment_collected"`
FirstSeen time.Time `json:"first_seen"` // Time of first contact with zadmin
LastSeen time.Time `json:"last_seen"` // Time of last contact with zadmin
Hostname string `json:"hostname"` // Configured system hostname
PublicIPv4Address string `json:"public_ipv4_address"` // Public IPv4 address
PublicIPv6Address string `json:"public_ipv6_address"` // Public IPv6 address
Interfaces []MachineInterfaceDetails `json:"machine_interfaces"` // Interface details
AgentVersion string
AntivirusInfo AntivirusInfo
UsageStatistics UsageStatistics
NetworkInterfaces []MachineInterfaceDetails `json:"machine_interfaces"` // Interface details
AgentVersion string `json:"agent_version"` // installed zadmin agent version
AntivirusInfo AntivirusInfo `json:"antivirus_info"` // Antivirus info
UsageStatistics UsageStatistics `json:"usage_statistics"` // Usage statistics of machine
SoftwareCatalog []Software `json:"software_catalog"` // Software installed on machine
UptimeSeconds int `json:"uptime_seconds"` // Machine uptime in seconds
LoggedOnUsers []string `json:"logged_on_users"` // Currently logged on users
OSVersion string `json:"os_version"` // OS version
}
// Software installed on a Machine
type Software struct {
Name string
Publisher string
}
type AntivirusInfo struct {
AVType string `json:"av_type"`
OK bool `json:"ok"`
AVType string `json:"av_type"` // Antivirus type
AVState string `json:"av_state"` // Antivirus state
}
type UsageStatistics struct {
AvailCPU int `json:"avail_cpu"` // Available mCPU
UsedCPU int `json:"used_cpu"` // Used mCPU
AvailRAM int `json:"avail_ram"` // Avaiable RAM in MB
AvailRAM int `json:"avail_ram"` // Available RAM in MB
UsedRAM int `json:"used_ram"` // Used RAM in MB
}
@ -68,8 +77,11 @@ type MachineInterfaceDetails struct {
Addressess []string `json:"addressess"` // Interface IP addressess
}
// Configuration to be used by the agent on an machine
// Configuration to be used by the agent on a machine
type MachineAgentConfig struct {
ServerHostname string `json:"server_hostname"`
CheckinInterval int `json:"checkin_interval"`
RESTServerHostname string `json:"rest_server_hostname"` // Hostname used for REST requests
RESTServerPort int `json:"rest_server_port"` // Port used for REST requests
NATSServerHostname string `json:"nats_server_hostname"` // Hostname used to contact nats.io
NATSServerPort int `json:"nats_server_port"` // Port used for REST requests
HelloInterval int `json:"checkin_interval"` // interval of sending hello message, indicating host is online
}