shared

package
v0.54.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigFileReadLimit int64 = 96 << 10

DefaultConfigFileReadLimit caps typical config file reads (web server snippets, logrotate, cron, etc.).

Variables

This section is empty.

Functions

func BoolPtr added in v0.5.0

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to b.

func CollectionNote

func CollectionNote(detail string) string

CollectionNote returns a stable human-readable reason (max ~512 chars for schema).

func EnvLocaleC

func EnvLocaleC() []string

EnvLocaleC forces C locale for deterministic CLI output parsing.

func FileExistsRegular added in v0.5.0

func FileExistsRegular(path string) bool

FileExistsRegular reports whether path exists and is not a directory.

func HostIsContainerized added in v0.5.0

func HostIsContainerized() *bool

HostIsContainerized reports dockerenv/cgroup hints (best-effort).

func IntPtr added in v0.5.0

func IntPtr(n int) *int

IntPtr returns a pointer to n.

func ProcessRunningState added in v0.54.1

func ProcessRunningState(ctx context.Context, processes []string) string

ProcessRunningState reports "running" when one of these processes is in the process table, and "" when none of them is.

It never answers "stopped". A name we do not find may be a service that is genuinely down, or the same service under a name this distribution chose differently — and reporting the second as "stopped" would be the very kind of confident wrong answer this function exists to replace. Saying "running" only when a process is really there adds knowledge without ever inventing any.

This is the last question asked, after the machine's own service list and after systemd, because those two also say when something is stopped.

func QueryDistroPackageVersion added in v0.28.0

func QueryDistroPackageVersion(packageNames []string) string

QueryDistroPackageVersion returns the full distro package version for the first matching package name (e.g., "2.4.57-2~deb12u2" for apache2 on Debian, "2:3.5.25-1.el9" for postfix on RHEL). Tries dpkg-query (Debian/Ubuntu) then rpm (RHEL/CentOS). Returns "" on failure.

func ReadFileBounded added in v0.4.0

func ReadFileBounded(path string, maxBytes int64) ([]byte, error)

ReadFileBounded reads at most maxBytes from path (regular file open).

func ScanContextError added in v0.4.0

func ScanContextError(ctx context.Context) error

ScanContextError returns ctx.Err() when ctx is non-nil and done.

func ServiceStateFromList added in v0.54.1

func ServiceStateFromList(services []payload.ServiceEntry, want []string) string

ServiceStateFromList reports what this machine's own service list already says about any of these units: "running", "stopped", or "" if it says nothing.

Every posture used to ask for the systemd spelling only. On a machine with no systemd the answer was sitting in the payload and nothing could read it: the services block said apache2 was running, while apache_httpd_posture reported no service state at all. Six postures were blind this way on one Ubuntu 14.04 host — apache, postfix, ftp, redis, mongodb and mysql.

func StringPtr added in v0.5.0

func StringPtr(s string) *string

StringPtr returns a pointer to a copy of s.

func TruncateRunes

func TruncateRunes(s string, max int) string

TruncateRunes truncates to at most max runes.

func UnitBaseName added in v0.54.1

func UnitBaseName(name string) string

UnitBaseName is a service's name without the ".service" systemd gives it.

The two init systems spell the same service differently: systemd lists "apache2.service", sysvinit and Upstart list "apache2". Comparing the spellings as they come makes every match miss on one kind of machine.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL