Clean up armbian-hardware-monitor

systemd-analyze blame: prior 4.506s, after 174ms
This commit is contained in:
ThomasKaiser
2018-09-27 23:54:30 +02:00
parent b283ddb7f9
commit 624132790f

View File

@@ -8,7 +8,6 @@
# Functions:
#
# collect_information
# prepare_temp_monitoring
# log_hardware_info
# get_flash_information
@@ -20,16 +19,6 @@
# and script configuration
. /usr/lib/armbian/armbian-common
collect_information() {
ifconfig | grep -q eth0 || (ifconfig eth0 up ; sleep 2)
TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX)
trap "sleep 1 ; rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15
CPU_ARCH=$(lscpu | awk '/Architecture/ {print $2}')
DISTRO_ARCH=$(dpkg --print-architecture)
KERNELID=$(uname -r)
dmesg >"${TMPFILE}"
} # collect_information
prepare_temp_monitoring() {
# still an ugly hack but better do it just once at startup instead of every login
[ -d /etc/armbianmonitor/datasources ] || mkdir -p -m775 /etc/armbianmonitor/datasources
@@ -65,10 +54,13 @@ log_hardware_info() {
[ -f "/etc/logrotate.d/${0##*/}" ] || \
echo -e "${Log} {\n rotate 12\n weekly\n compress\n missingok\n notifempty\n}" \
> "/etc/logrotate.d/${0##*/}" ; chmod 644 "/etc/logrotate.d/${0##*/}"
CPU_ARCH=$(lscpu | awk '/Architecture/ {print $2}')
DISTRO_ARCH=$(dpkg --print-architecture)
KERNELID=$(uname -r)
echo -e "\n$(date) | ${BOARD_NAME} | ${VERSION} | ${DISTRO_ARCH} | ${CPU_ARCH} | ${KERNELID}" >>${Log}
chmod 644 ${Log}
echo -e "\n### dmesg:\n" >>${Log}
cat "${TMPFILE}" >>${Log}
dmesg >>${Log}
echo -e "\n### armbian-release:\n" >>${Log}
cat /etc/armbian-release >>${Log}
echo -e "\n### boot environment:\n" >>${Log}
@@ -81,7 +73,7 @@ log_hardware_info() {
cat /proc/cpuinfo >>${Log}
echo -e "\n### meminfo:\n" >>${Log}
cat /proc/meminfo >>${Log}
echo -e "\n###virtual memory:\n" >>${Log}
echo -e "\n### virtual memory:\n" >>${Log}
for sysfsnode in /proc/sys/vm/* ; do sysctl $(echo ${sysfsnode} | sed 's|/proc/sys/vm/|vm.|'); done >>${Log}
if [ -x /sbin/ip ]; then
echo -e "\n### ip addr:\n" >>${Log}
@@ -103,7 +95,8 @@ log_hardware_info() {
egrep '^/dev/|\ zfs\ ' /etc/mtab | egrep -v "log2ram|folder2ram" | sort >>${Log}
[[ -e /boot/script.bin ]] && echo -e "\n### /boot/script.bin --> $(readlink /boot/script.bin)" >>${Log}
get_flash_information >>${Log}
(echo -e "\n### Boot system health:\n" >>${Log} ; armbianmonitor -s | egrep "^Time|^[0-9]" >>${Log}) &
echo -e "\n### Boot system health:\n" >>${Log}
armbianmonitor -s | egrep "^Time|^[0-9]" >>${Log}
} # log_hardware_info
get_flash_information() {
@@ -147,11 +140,7 @@ case $1 in
# prepare correct temperature readouts
prepare_temp_monitoring &
# get hardware information and rely on contents of /etc/armbian-release
collect_information
# display message, log hardware id to file, write log
# echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: ${BOARD_NAME} (${VERSION})"
# log hardware id to file, write log
echo $BOARD_NAME >/var/run/machine.id # we should leave this, maybe users depend on it
if [ $? -ne 0 ]; then
# most probably readonly fs. We'll try to warn the user.
@@ -160,7 +149,7 @@ case $1 in
# check whether auto detection override exists and if true use this for machine.id
[ -f /root/.machine.id ] && cat /root/.machine.id >/var/run/machine.id
log_hardware_info
log_hardware_info &
;;
*stop*)