systeminfo

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// PackageLVM refers to logical volume management facilities on Linux
	PackageLVM = "lvm2"
)
View Source
const RedHat = "rhel"

RedHat identifies a RedHat Enterprise Linux system or one of its descent

Variables

This section is empty.

Functions

func GetSystemPackages

func GetSystemPackages(info OS) (packages []storage.SystemPackage)

GetSystemPackages queries the system for a set of installed packages

func HasInterface

func HasInterface(addr string) error

HasInterface returns nil if the machine the method executes on has the specified network interface

func NetworkInterfaces

func NetworkInterfaces() (result []storage.NetworkInterface, err error)

NetworkInterfaces returns the list of all network interfaces with IPv4 addresses on the host

func New

func New() (*storage.SystemV2, error)

New returns a new instance of system information

func ResolvFromFile

func ResolvFromFile(filename string) (*storage.ResolvConf, error)

ResolvFromFile reads the given resolv.conf file

func ResolvFromReader

func ResolvFromReader(rdr io.Reader) (*storage.ResolvConf, error)

ResolvFromReader reads the given resolv.conf as an io.Reader

Types

type FilesystemInfo

type FilesystemInfo struct {
	// Filesystem describes a filesystem on host
	Filesystem storage.Filesystem
	// Usage is a usage information (total, free bytes)
	Usage storage.FilesystemUsage
}

FilesystemInfo groups a filesystem and usage statistics

func FilesystemForDir

func FilesystemForDir(system storage.System, dirName string) (*FilesystemInfo, error)

FilesystemForDir returns information about the file system where the directory dirName is mounted. If dirName is not explicitly mounted, the function will return filesystem information about one of its parent directories.

func (FilesystemInfo) FreeBytes

func (r FilesystemInfo) FreeBytes() uint64

FreeBytes reports free disk space in KiB (kibibits or 1024 bits)

func (FilesystemInfo) TotalBytes

func (r FilesystemInfo) TotalBytes() uint64

TotalBytes reports usage in KiB (kibibits or 1024 bits)

type OS

type OS storage.OSInfo

OS aliases operating system info

func OSInfo

func OSInfo() (info *OS, err error)

OSInfo obtains identification information for the host operating system

func (OS) IsRedHat

func (r OS) IsRedHat() bool

IsRedHat determines if this info refers to a RedHat system or one of its descent

func (OS) Name

func (r OS) Name() string

Name returns a name/version for this OS info, e.g. "centos 7.1"

type User

type User struct {
	// Name is the user name
	Name string `json:"name"`
	// UID is user id
	UID int `json:"uid"`
	// GID is group id
	GID int `json:"gid"`
}

User describes a system user

func DefaultServiceUser

func DefaultServiceUser() *User

DefaultServiceUser returns the default service user

func GetRealUser

func GetRealUser() (*User, error)

GetRealUser returns a name of the current user

func LookupUserByName

func LookupUserByName(name string) (*User, error)

LookupUserByName finds a user by name

func LookupUserByUID

func LookupUserByUID(uid int) (*User, error)

LookupUserByUID finds a user by ID

func NewUser

func NewUser(name, group, uid, gid string) (*User, error)

NewUser creates a new user with the specified name and group.

If group ID has been specified, the group is created with the given ID. If user ID has been specified, the user is created with the given ID

func UserFromOSUser

func UserFromOSUser(user storage.OSUser) (*User, error)

UserFromOSUser returns a new user from the specified storage user

func (User) OSUser

func (r User) OSUser() storage.OSUser

OSUser returns a new storage user from this user

func (User) String

func (r User) String() string

String returns a textual representation of this user. Implements fmt.Stringer

Jump to

Keyboard shortcuts

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