feat(logging): display host information in log file
Adds Information Distribution,Release,Kernel,Host model,Cpu Count, Total Ram and Diskusage to log, if not set to log_level: quiet Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
parent
5b8c072db3
commit
687be54de1
@ -33,6 +33,7 @@ function init_logging {
|
||||
log_msg "crowsnest - A webcam Service for multiple Cams and Stream Services."
|
||||
log_msg "Version: $(self_version)"
|
||||
log_msg "Prepare Startup ..."
|
||||
print_host
|
||||
}
|
||||
|
||||
function log_level {
|
||||
@ -116,6 +117,44 @@ function print_cams {
|
||||
fi
|
||||
}
|
||||
|
||||
function print_host {
|
||||
local disksize generic_model memtotal sbc_model
|
||||
generic_model="$(grep "model name" /proc/cpuinfo | cut -d':' -f2)"
|
||||
sbc_model="$(grep "Model" /proc/cpuinfo | cut -d':' -f2)"
|
||||
memtotal="$(grep "MemTotal:" /proc/meminfo | awk '{print $2" "$3}')"
|
||||
disksize="$(LC_ALL=C df -h / | awk 'NR==2 {print $4" / "$2}')"
|
||||
## print only if not log_level: quiet
|
||||
if [ "$(log_level)" != "quiet" ]; then
|
||||
log_msg "INFO: Host information:"
|
||||
## OS Infos
|
||||
## OS Version
|
||||
if [ -f /etc/os-release ]; then
|
||||
log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | \
|
||||
cut -d '=' -f2 | sed 's/^"//;s/"$//')"
|
||||
fi
|
||||
## Release Version of MainsailOS (if file present)
|
||||
if [ -f /etc/mainsailos-release ]; then
|
||||
log_msg "Host Info: Release: $(cat /etc/mainsailos-release)"
|
||||
fi
|
||||
## Kernel version
|
||||
log_msg "Host Info: Kernel: $(uname -s) $(uname -rm)"
|
||||
## Host Machine Infos
|
||||
## Host model
|
||||
if [ -n "${sbc_model}" ]; then
|
||||
log_msg "Host Info: Model: ${sbc_model}"
|
||||
fi
|
||||
if [ -n "${generic_model}" ]; then
|
||||
log_msg "Host Info: Model: ${generic_model}"
|
||||
fi
|
||||
## CPU count
|
||||
log_msg "Host Info: Available CPU Cores: $(nproc)"
|
||||
## Avail mem
|
||||
log_msg "Host Info: Available Memory: ${memtotal}"
|
||||
## Avail disk size
|
||||
log_msg "Host Info: Diskspace (used / total): ${disksize}"
|
||||
fi
|
||||
}
|
||||
|
||||
function debug_msg {
|
||||
local prefix
|
||||
prefix="Develop -- DEBUG:"
|
||||
|
Loading…
x
Reference in New Issue
Block a user