Documentation ¶
Index ¶
- Constants
- func CollectRaucInventory(ctx context.Context) (*image.RaucStatus, error)
- func HasDocker() bool
- func HasPodman() bool
- type DockerContainer
- type DockerContainers
- type DockerImage
- type DockerImages
- type DockerNetwork
- type DockerNetworks
- type DockerVolume
- type DockerVolumes
- type PodmanContainer
- type PodmanContainers
- type PodmanImage
- type PodmanImages
- type PodmanNetwork
- type PodmanNetworks
- type PodmanVolume
- type PodmanVolumes
- type Port
- type Ports
- type Process
- type Processes
- type Service
- type Software
- type System
- type SystemInfo
- type Type
- type User
- type Users
Constants ¶
const ( PasswdFilePath = "/etc/passwd" ShadowFilePath = "/etc/shadow" )
Paths to standard passwd and shadow files.
const ( PasswordAlgorithmMD5 = 1 PasswordAlgorithmBcrypt = 2 PasswordAlgorithmSHA1 = 4 PasswordAlgorithmSHA256 = 5 PasswordAlgorithmSHA512 = 6 PasswordAlgorithmYesCrypt = 7 )
Password algorithms recognized by Qbee.
Variables ¶
This section is empty.
Functions ¶
func CollectRaucInventory ¶
func CollectRaucInventory(ctx context.Context) (*image.RaucStatus, error)
CollectRaucInventory collects the RAUC inventory.
Types ¶
type DockerContainer ¶
type DockerContainer struct { // ID - container ID. ID string `json:"id"` // Names - container names. Names string `json:"names"` // Image - image used to start the container. Image string `json:"image"` // Command - command running inside the container. Command string `json:"command"` // CreatedAt - container creation date/time (e.g. "2022-11-14 12:12:10 +0100 CET"). CreatedAt string `json:"created_at"` // Status - container status (e.g. "Up 30 minutes"). Status string `json:"status"` // Ports - network ports exposed by the container. // Examples: // - single port: 80/tcp // - range of ports: 80-81/tcp // - discontiguous ports: 80-81/tcp, 83/tcp Ports string `json:"ports"` // Size - container disk size. Size string `json:"size"` // Mounts - names of the volumes mounted in this container. Mounts string `json:"mounts"` // Networks - names of the networks attached to this container. Networks string `json:"networks"` }
DockerContainer represents a single Docker container.
type DockerContainers ¶
type DockerContainers struct {
Containers []DockerContainer `json:"items"`
}
DockerContainers represents a list of Docker containers.
func CollectDockerContainersInventory ¶
func CollectDockerContainersInventory(ctx context.Context) (*DockerContainers, error)
CollectDockerContainersInventory returns populated DockerContainers inventory based on current system status.
type DockerImage ¶
type DockerImage struct { // ID - image ID. ID string `json:"id"` // Repository - image repository. Repository string `json:"repository"` // Tag - image tag. Tag string `json:"tag"` // CreatedAt - when the image was created (e.g. "2022-11-12 07:27:47 +0100 CET"). CreatedAt string `json:"created_at"` // Size - image disk size. Size string `json:"size"` }
DockerImage represents a single Docker image.
type DockerImages ¶
type DockerImages struct {
Images []DockerImage `json:"items"`
}
DockerImages represents a list of Docker images.
func CollectDockerImagesInventory ¶
func CollectDockerImagesInventory(ctx context.Context) (*DockerImages, error)
CollectDockerImagesInventory returns populated DockerImages inventory based on current system status.
type DockerNetwork ¶
type DockerNetwork struct { // ID - network ID. ID string `json:"id"` // Name - network name. Name string `json:"name"` // Driver - network driver (e.g. "bridge"). Driver string `json:"driver"` // CreatedAt - time when the network was created (e.g. "2022-11-14 12:11:16.974857017 +0100 CET"). CreatedAt string `json:"created_at"` // Internal - 'true' if the network is internal, 'false' if not. Internal string `json:"internal"` }
DockerNetwork represents a single Docker network.
type DockerNetworks ¶
type DockerNetworks struct {
Networks []DockerNetwork `json:"items"`
}
DockerNetworks represents a list of Docker networks.
func CollectDockerNetworksInventory ¶
func CollectDockerNetworksInventory(ctx context.Context) (*DockerNetworks, error)
CollectDockerNetworksInventory returns populated DockerNetworks inventory based on current system status.
type DockerVolume ¶
type DockerVolume struct { // Name - volume name. Name string `json:"name"` // Driver - volume driver (e.g. "local"). Driver string `json:"driver"` }
DockerVolume represents a single Docker volume.
type DockerVolumes ¶
type DockerVolumes struct {
Volumes []DockerVolume `json:"items"`
}
DockerVolumes represents a list of Docker volumes.
func CollectDockerVolumesInventory ¶
func CollectDockerVolumesInventory(ctx context.Context) (*DockerVolumes, error)
CollectDockerVolumesInventory returns populated DockerVolumes inventory based on current system status.
type PodmanContainer ¶
type PodmanContainer struct { // ID - container ID. ID string `json:"id"` // Names - container names. Names string `json:"names"` // Image - image used to start the container. Image string `json:"image"` // Command - command running inside the container. Command string `json:"command"` // CreatedAt - container creation date/time (e.g. "2022-11-14 12:12:10 +0100 CET"). CreatedAt string `json:"created_at"` // Status - container status (e.g. "Up 30 minutes"). Status string `json:"status"` // Ports - network ports exposed by the container. // Examples: // - single port: 80/tcp // - range of ports: 80-81/tcp // - discontiguous ports: 80-81/tcp, 83/tcp Ports string `json:"ports"` // Size - container disk size. Size string `json:"size"` // Mounts - names of the volumes mounted in this container. Mounts string `json:"mounts"` // Networks - names of the networks attached to this container. Networks string `json:"networks"` }
PodmanContainer represents a single Podman container.
type PodmanContainers ¶
type PodmanContainers struct {
Containers []PodmanContainer `json:"items"`
}
PodmanContainers represents a list of Podman containers.
func CollectPodmanContainersInventory ¶
func CollectPodmanContainersInventory(ctx context.Context) (*PodmanContainers, error)
CollectPodmanContainersInventory returns populated PodmanContainers inventory based on current system status.
type PodmanImage ¶
type PodmanImage struct { // ID - image ID. ID string `json:"id"` // Repository - image repository. Repository string `json:"repository"` // Tag - image tag. Tag string `json:"tag"` // CreatedAt - when the image was created (e.g. "2022-11-12 07:27:47 +0100 CET"). CreatedAt string `json:"created_at"` // Size - image disk size. Size string `json:"size"` }
PodmanImage represents a single Podman image.
type PodmanImages ¶
type PodmanImages struct {
Images []PodmanImage `json:"items"`
}
PodmanImages represents a list of Podman images.
func CollectPodmanImagesInventory ¶
func CollectPodmanImagesInventory(ctx context.Context) (*PodmanImages, error)
CollectPodmanImagesInventory returns populated DockerImages inventory based on current system status.
type PodmanNetwork ¶
type PodmanNetwork struct { // ID - network ID. ID string `json:"id"` // Name - network name. Name string `json:"name"` }
PodmanNetwork represents a single Podman network.
type PodmanNetworks ¶
type PodmanNetworks struct {
Networks []PodmanNetwork `json:"items"`
}
PodmanNetworks represents a list of Podman networks.
func CollectPodmanNetworksInventory ¶
func CollectPodmanNetworksInventory(ctx context.Context) (*PodmanNetworks, error)
CollectPodmanNetworksInventory returns populated PodmanNetworks inventory based on current system status.
type PodmanVolume ¶
type PodmanVolume struct { // Name - volume name. Name string `json:"name"` // Driver - volume driver (e.g. "local"). Driver string `json:"driver"` }
PodmanVolume represents a single Podman volume.
type PodmanVolumes ¶
type PodmanVolumes struct {
Volumes []PodmanVolume `json:"items"`
}
PodmanVolumes represents a list of Podman volumes.
func CollectPodmanVolumesInventory ¶
func CollectPodmanVolumesInventory(ctx context.Context) (*PodmanVolumes, error)
CollectPodmanVolumesInventory returns populated PodmanVolumes inventory based on current system status.
type Port ¶
type Port struct { // Protocol - network protocol used (e.g. "tcp", "tcp6", "udp" or "udp6"). Protocol string `json:"proto"` // Socket - which socket is listening (e.g. "0.0.0.0:69"). Socket string `json:"socket"` // Process - which process is controlling the socket (e.g. "/usr/sbin/in.tftpd ..."). Process string `json:"proc_info"` }
Port contains information about a listening network port.
type Ports ¶
type Ports struct {
Ports []Port `json:"items"`
}
Ports contains information about currently listening network ports.
func CollectPortsInventory ¶
CollectPortsInventory returns populated Ports inventory based on current system status.
type Process ¶
type Process struct { // PID - process ID. PID int `json:"pid"` // User - owner of the process. User string `json:"user"` // Memory - memory usage in percent. Memory float64 `json:"mem"` // CPU - CPU usage in percent. CPU float64 `json:"cpu"` // Command - program command. Command string `json:"cmdline"` }
Process contains information about a running process.
type Processes ¶
type Processes struct {
Processes []Process `json:"items"`
}
Processes contains information about processes running on the system.
func CollectProcessesInventory ¶
CollectProcessesInventory returns populated Processes inventory based on current system status. Based on https://www.kernel.org/doc/html/latest/filesystems/proc.html#id10
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides methods for collecting and delivering inventory data.
type Software ¶
type Software struct { // PackageManager - type of package manager generating the report PackageManager software.PackageManagerType `json:"pkg_manager"` // Items - list of installed software Items []software.Package `json:"items"` }
Software contains software package information for a supported package manager.
type System ¶
type System struct {
System SystemInfo `json:"system"`
}
System contains system information.
func CollectSystemInventory ¶
CollectSystemInventory returns populated System inventory based on current system status.
type SystemInfo ¶
type SystemInfo struct { // Class - This variable contains the name of the hard-class category for this host, // (i.e. its top level operating system type classification, e.g. "linux"). Class string `json:"class"` // OS - The name of the operating system according to the kernel (e.g. "linux"). OS string `json:"os"` // OSType - Another name for the operating system (e.g. "linux_x86_64"). OSType string `json:"ostype"` // Version - The version of the running kernel. On Linux, this corresponds to the output of uname -v. // Example: "#58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022". Version string `json:"version"` // Architecture - The variable gives the kernel's short architecture description (e.g. "x86_64"). Architecture string `json:"arch"` // LongArchitecture - The long architecture name for this system kernel. // This name is sometimes quite unwieldy but can be useful for logging purposes. // Example: "linux_x86_64_5_15_0_52_generic__58_Ubuntu_SMP_Thu_Oct_13_08_03_55_UTC_2022" LongArchitecture string `json:"long_arch"` // Release - The kernel release of the operating system (e.g. "5.15.0-52-generic"). Release string `json:"release"` // Flavor - A variable containing an operating system identification string that is used to determine // the current release of the operating system in a form that can be used as a label in naming. // This is used, for instance, to detect which package name to choose when updating software binaries for CFEngine. // Example: "ubuntu_22" Flavor string `json:"flavor"` // OSVersion - The full version of the operating system (e.g. "Ubuntu 22.04.3 LTS (Jammy Jellyfish)"). OSVersion string `json:"os_version"` // BootTime represents system boot time (as Unix timestamp string, e.g. "1586144402") BootTime string `json:"boot_time"` // CPUs - A variable containing the number of CPU cores detected. On systems which provide virtual cores, // it is set to the total number of virtual, not physical, cores. // In addition, on a single-core system the class 1_cpu is set, and on multicore systems the class n_cpus is set, // where n is the number of cores identified (e.g. "4"). CPUs string `json:"cpus"` // CpuSerialNumber - the serial number of the CPU (e.g. "0000000000000000"). CPUSerialNumber string `json:"cpu_sn"` // CPURevision - the revision of the CPU (e.g. "10") CPURevision string `json:"cpu_rev"` // CPUHardware - the CPU hardware description (e.g. "Freescale i.MX6 Quad/DualLite (Device Tree)"). CPUHardware string `json:"cpu_hw"` // Host - The name of the current host, according to the kernel. // It is undefined whether this is qualified or unqualified with a domain name. Host string `json:"host"` // FQHost - The fully qualified name of the host (e.g. "device1.example.com"). FQHost string `json:"fqhost"` // UQHost - The unqualified name of the host (e.g. "device1"). UQHost string `json:"uqhost"` // Interface - The assumed (default) name of the main system interface on this host. Interface string `json:"interface"` // HardwareMAC - This contains the MAC address of the named interface map[interface]macAddress. // Note: The keys in this array are canonified. // For example, the entry for wlan0.1 would be found under the wlan0_1 key. // // Example: // { // "ens1": "52:54:00:4a:db:ee", // "qbee0": "00:00:00:00:00:00" // } HardwareMAC map[string]string `json:"hardware_mac"` // InterfaceFlags - Contains a space separated list of the flags of the named interfaces. // The following device flags are supported: // up // broadcast // debug // loopback // pointopoint // notrailers // running // noarp // promisc // allmulti // multicast // // Example: // { // "ens1": "up broadcast running multicast", // "qbee0": "up pointopoint running noarp multicast" // } InterfaceFlags map[string]string `json:"interface_flags"` // IPAddresses - A system list of IP addresses currently in use by the system (e.g: "100.64.39.78"). IPAddresses string `json:"ip_addresses"` // IPv4First - All four octets of the IPv4 address of the first system interface. // Note: If the system has a single ethernet interface, this variable will contain the IPv4 address. // However, if the system has multiple interfaces, then this variable will simply be the IPv4 address of the first // interface in the list that has an assigned address. // Use IPv4[interface_name] for details on obtaining the IPv4 addresses of all interfaces on a system. IPv4First string `json:"ipv4_first"` // IPv4 - All IPv4 addresses of the system mapped by interface name. // Example: // { // "ens1": "192.168.122.239", // "qbee0": "100.64.39.78" // } IPv4 map[string]string `json:"ipv4"` // IPv6 - All IPv6 addresses of the system mapped by interface name. // Example: // { // "ens1": "192.168.122.239", // "qbee0": "100.64.39.78" // } IPv6 map[string]string `json:"ipv6"` // RemoteAddress - remote client address from which the inventory was reported (e.g. "1.2.3.4"). // Note: this is detected server side when inventory is pushed through our API. RemoteAddress string `json:"remoteaddr"` // LastPolicyUpdate - latest applied policy update timestamp (e.g. "1668156545") // This date is set to the timestamp of most recently downloaded config. LastPolicyUpdate string `json:"last_policy_update"` // LastConfigUpdate LastConfigUpdate string `json:"last_config_update"` // LastConfigCommitID - last applied config commit // (e.g. "6c07b6d021a015329b1815ec954cca6d8c4973c3b574202401dad448e8cdd0f5"). LastConfigCommitID string `json:"last_config_commit_id"` // PolicyVersion - which policy version was in use for collecting inventory (e.g. "0.0.45"). PolicyVersion string `json:"policy_version"` // AgentVersion used to collect the inventory. AgentVersion string `json:"cf_version"` // TPMEnabled indicates if the agent uses TPM to seal its private key. TPMEnabled bool `json:"tpm_enabled"` // RebootScheduled RebootScheduled bool `json:"reboot_scheduled"` // VPNIndex - defines numeric ID of the VPN server to which the device is connected. // For now all devices are connected to the same VPN server, so this value is always 1. VPNIndex string `json:"vpn_idx" bson:"vpn_idx"` }
SystemInfo contains system information.
type Type ¶
type Type string
Type is the type of the inventory item.
const TypeDockerContainers Type = "docker_containers"
TypeDockerContainers is the inventory type for Docker containers.
const TypeDockerImages Type = "docker_images"
TypeDockerImages is the inventory type for Docker images.
const TypeDockerNetworks Type = "docker_networks"
TypeDockerNetworks is the inventory type for Docker networks.
const TypeDockerVolumes Type = "docker_volumes"
TypeDockerVolumes is the inventory type for Docker volumes.
const TypePodmanContainers Type = "podman_containers"
TypePodmanContainers is the inventory type for Podman containers.
const TypePodmanImages Type = "podman_images"
TypePodmanImages is the inventory type for Podman images.
const TypePodmanNetworks Type = "podman_networks"
TypePodmanNetworks is the inventory type for Podman networks.
const TypePodmanVolumes Type = "podman_volumes"
TypePodmanVolumes is the inventory type for Podman volumes.
const TypePorts Type = "ports"
TypePorts is the inventory type for listening network ports.
const TypeProcesses Type = "processes"
TypeProcesses is the inventory type for process information.
const TypeRauc Type = "rauc"
TypeRauc is the inventory type of the RAUC inventory.
const TypeSoftware Type = "software"
TypeSoftware is the inventory type for software information.
const TypeSystem Type = "system"
TypeSystem is the inventory type for system information.
const TypeUsers Type = "users"
TypeUsers is the type of the inventory item.
type User ¶
type User struct { // Name - the string a user would type in when logging into the operating system. Name string `json:"user"` // UID - user identifier number. UID int `json:"uid"` // GID - group identifier number, which identifies the primary group of the user. GID int `json:"gid"` // GECOS - general information about the user, such as their real name and phone number. GECOS string `json:"gecos"` // HomeDirectory - path to the user's home directory. HomeDirectory string `json:"home"` // Shell - program that is started every time the user logs into the system. Shell string `json:"shell"` // HasPassword - "yes" if user has password set. HasPassword string `json:"has_pwd"` // PasswordAlgorithm // Probably should be fixed to return one of the following: // $1$ – MD5 // $2$, $2a$, $2b$ – bcrypt // $5$ – SHA-256 // $6$ – SHA-512 // $y$ – yescrypt // Example from /etc/shadow: // vm:$y$j9T$zlG11k7j50csbROp/ZF430$.xYApDc/8FH2T9qvGntFS9IxmzK2F4gBYFe/8EgUba6:19305:0:99999:7::: // ^^ is using yescrypt PasswordAlgorithm int `json:"pwd_alg"` // PasswordAge - days since epoch of last password change. PasswordAge int `json:"pwd_age"` }
User represents a user on the system.
func GetUsersFromPasswd ¶
GetUsersFromPasswd returns users based on passwd file.
type Users ¶
type Users struct {
Users []User `json:"items"`
}
Users contains information about users on the system.
func CollectUsersInventory ¶
CollectUsersInventory returns populated Users inventory based on current system status.
Source Files ¶
- api.go
- docker.go
- docker_containers.go
- docker_images.go
- docker_networks.go
- docker_volumes.go
- podman.go
- podman_containers.go
- podman_images.go
- podman_networks.go
- podman_volumes.go
- ports.go
- ports_linux.go
- processes.go
- processes_linux.go
- rauc.go
- service.go
- software.go
- system.go
- system_linux.go
- type.go
- uname_linux.go
- users.go
- users_linux.go