module

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBasicBootTime

func GetBasicBootTime() string

GetBasicBootTime Get system boot time

func GetBasicDateTime

func GetBasicDateTime() string

GetBasicDateTime Get the current time of the system

func GetBasicDeviceModel

func GetBasicDeviceModel() string

GetBasicDeviceModel Get the system device model

func GetBasicTimestamp

func GetBasicTimestamp() string

func GetBasicUpTime

func GetBasicUpTime() string

GetBasicUpTime 30 days, 14 hours, 3 mins - [linux - Bash format uptime to show days, hours, minutes - Stack Overflow](https://stackoverflow.com/questions/28353409/bash-format-uptime-to-show-days-hours-minutes)

func GetBasicUpTimeDHM

func GetBasicUpTimeDHM(uptime string) (day, hour, min string)

GetBasicUpTimeDHM 30 days, 14 hours, 3 mins ==> 30 14 3

func GetCPUArch

func GetCPUArch() (arch, archModel string)

GetCPUArch

➜ /usr/bin/lscpu | /bin/egrep -i 'architecture|vendor|model'
Architecture:        armv7l
Vendor ID:           ARM
Model:               4
Model name:          Cortex-A53

func GetCPUInfo

func GetCPUInfo() (hardware, modelName, model, rev, serial string, cores int)

GetCPUInfo

➜ cat /proc/cpuinfo | /bin/egrep -i 'processor|model|hardware|revision|serial' | sort | uniq
CPU revision    : 4
Hardware        : BCM2835
model name      : ARMv7 Processor rev 4 (v7l)
Model           : Raspberry Pi 3 Model B Plus Rev 1.3
processor       : 0
processor       : 1
processor       : 2
processor       : 3
Revision        : a020d3
Serial          : 000000007a867fb6

func GetCPULoadAvg

func GetCPULoadAvg(cores int) (load1, load5, load15 string)

GetCPULoadAvg percent

func GetCPUSysTemp

func GetCPUSysTemp() string

GetCPUSysTemp

func GetCPUTemperatureC

func GetCPUTemperatureC() float64

GetCPUTemperatureC eg: 59.1 ℃

func GetCPUTemperatureF

func GetCPUTemperatureF() float64

GetCPUTemperatureF eg: 136.4 ℉

func GetDrivesFileSystem

func GetDrivesFileSystem() (total, used, free, usedPercent string)

GetDrivesFileSystem

➜ df -h / | tail -n 1 | awk '{print $2,$3,$4,$5}'
15G 5.7G 8.1G 42%

func GetMemoryInfo

func GetMemoryInfo() (memTotal, memFree, memAvail, buff, cache, swapTotal, swapFree string)

GetMemoryInfo

➜ /bin/cat /proc/meminfo | /bin/egrep -i "mem[tfa]|swap[tf]|buffers|cached"
MemTotal:         946392 kB
MemFree:           96268 kB
MemAvailable:     407268 kB
Buffers:           53128 kB
Cached:           288424 kB
SwapCached:         4264 kB
SwapTotal:        102396 kB
SwapFree:           2612 kB

func GetMemorySimple

func GetMemorySimple() (memTotal, memAvail, swapTotal, swapFree string)

GetMemorySimple

➜ /bin/cat /proc/meminfo | /bin/egrep -i "mem[ta]|swap[tf]"
MemTotal:         946392 kB
MemAvailable:     366148 kB
SwapTotal:        102396 kB
SwapFree:             56 kB

func GetNetworkIFDetails

func GetNetworkIFDetails(ipCmd, interfaceName string) []string

GetNetworkIFDetails

➜ ip addr show eth0 | egrep "Link|flags|inet |ether | eth0" | /bin/egrep -v -i "lo:|loopback|inet6|\:\:1|127\.0\.0\.1"
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether b8:27:eb:86:7f:b6 brd ff:ff:ff:ff:ff:ff

func GetNetworkIFNames

func GetNetworkIFNames(ipCmd string) []string

GetNetworkIFNames

➜ ip link show | /bin/egrep -v 'link' | /bin/egrep ' eth| wlan'
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT group default qlen 1000

returns [eht0 wlan0]

func GetNetworkIPs

func GetNetworkIPs() []model.NetworkInfo

GetNetworkIPs

func GetOSCodeName

func GetOSCodeName() string

GetOSCodeName eg: buster

func GetOSDistro

func GetOSDistro() string

GetOSDistro eg: Raspbian GNU/Linux 10 (buster)

func GetOSHostName

func GetOSHostName(defDomain string) (hostName, fqdn string)

GetOSHostName Get hostname and FQDN, support for custom domain name

func GetOSKernel

func GetOSKernel() string

GetOSKernel Get kernel version eg: Linux 5.10.17-v7+

func LoadNetworkIFDetailLines

func LoadNetworkIFDetailLines(detailLines []string) (ipAddr, macAddr string)

LoadNetworkIFDetailLines

Types

This section is empty.

Jump to

Keyboard shortcuts

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