22#
33# armbianmonitor
44#
5- # This script serves different purposes based on how it is called:
5+ # System monitoring and debugging utility for Armbian.
6+ # Part of the Armbian project - https://www.armbian.com
67#
7- # - toggle boot verbosity (works)
8- # - monitoring mode: continually print monitoring info (WiP)
9- # - uploading /var/log/armbian-hardware-monitor.log to online pastebin service
8+ # Features:
9+ # - Live system monitoring (CPU, temp, voltage, etc.)
10+ # - Network monitoring
11+ # - Disk I/O monitoring
12+ # - Disk health/performance testing
13+ # - Package integrity verification
1014#
11- # Without arguments called it should present a simple user
12- # interface that guides through:
15+ # For support info collection and upload, use 'armbian-debug'.
1316#
14- # - installation of RPi-Monitor if not already installed by user
15- # - active basic or more verbose monitoring mode
16- # - provides monitoring parameters for connected disks
17+ # Disk Configuration Format:
18+ # When checking disks, proposals are generated for /etc/armbianmonitor/disks.conf:
1719#
18- # The second part is WiP and all the user interaction part
19- # still completely missing.
20+ # ${GUID}:${Name}:${smartctl_prefix}:${temp_call}:${CRC}:${LCC}
2021#
21- # This script is used to configure armbianmonitor behaviour.
22- # It will ask the user whether to activate monitoring or not,
23- # whether to enable debug monitoring and also how to deal with
24- # connected disks. In fact it walks through the list of available
25- # disks, checks them, tries to patch hddtemp.db if necessary
26- # and provides a proposal for /etc/armbianmonitor/disks.conf
27- # when a new disk is found.
22+ # Fields:
23+ # - GUID: Disk identifier from gdisk
24+ # - Name: Display name (defaults to device model)
25+ # - smartctl_prefix: USB disk type prefix (e.g., '-d sat', '-d usbjmicron')
26+ # - temp_call: Command to get temperature (omit to use hddtemp)
27+ # - CRC: S.M.A.R.T. attribute number for CRC errors
28+ # - LCC: S.M.A.R.T. attribute number for load cycle count
2829#
29- # In case monitoring should be activated the following file
30- # will be created: /etc/armbianmonitor/start-monitoring. If
31- # debug output has been chosen, then DEBUG will be written to
32- # the file.
33- #
34- # The script will install smartmontools/gdisk if not already
35- # installed and patches smartmontools' update-smart-drivedb
36- # script if necessary. For disks the 'device model' will be
37- # shown but internally we rely always on the GUID. This is the
38- # key for entry in /etc/armbianmonitor/disks.conf
39- #
40- # When the script exits and the user activated monitoring it
41- # recommends doing a restart since on the next reboot the
42- # setup-armbian-monitoring-environment script will configure
43- # monitoring sources and decides based on the existence and
44- # contents of /etc/armbianmonitor/start-monitoring whether
45- # rpimonitord should be started or not.
46- #
47- # The format of /etc/armbianmonitor/disks.conf is as follows:
48- #
49- # ${GUID}:${Name}:${smartctl prefix}:${temp call}:${CRC}:${LCC}
50- #
51- # Two examples:
52- #
53- # A57BF307-7D82-4783-BD1D-B346CA8C195B:WD Green::199:193 # WD HDD on SATA
54- # F8D372DC-63DB-494B-B802-87DC47FAD4E1:Samsung EVO:sat::199: # SSD in USB enclosure
55- #
56- # - GUID is the GUID as determined by gdisk
57- # - 'Name': The name as it will later be shown in RPi-Monitor, defaults to
58- # the 'device model' read out through smartctl but can be changed to
59- # be more significant (beware that this string must contain colons!)
60- # - "smartctl prefix" can be empty or should be the the necessary prefix for
61- # USB disks, eg. '-d sat' or '-d usbjmicron' and so on -- please have a
62- # look at https://www.smartmontools.org/wiki/Supported_USB-Devices
63- # - "temp call" when being omitted indicates that hddtemp should be used.
64- # Otherwise it should contain the complete command line ('DISK' will be
65- # dynamically replaced by the device node when the actual monitoring
66- # happens), for example:
67- # /sbin/hdparm -C DISK | grep -Eq "standby|sleeping" || \
68- # /usr/sbin/smartctl -d sat -a DISK | awk -F" " '/Temperature_Cel/ {printf $10}'
69- # - 'CRC attribute': The decimal value of the S.M.A.R.T. attribute that
70- # is used to store the count of checksum errors between disk and host
71- # controller (might be omitted if the drive doesn't support it)
72- # - 'LCC attribute': The decimal value of the S.M.A.R.T. attribute that
73- # should contain the load cycle counter value (might be omitted
74- # if the drive doesn't support it)
75- #
76- # TODO:
77- #
78- # - develop main functionality ;) asking the user regarding monitoring
79- # - deal with 'SMART overall-health self-assessment test result:'
80- # - write documentation
30+ # Example:
31+ # A57BF307-7D82-4783-BD1D-B346CA8C195B:WD Green::199:193
8132#
8233# ###########################################################################
8334
@@ -102,29 +53,10 @@ Main() {
10253 )
10354
10455 ParseOptions " $@ "
105-
106- exit 0
107- PreRequisits
108-
109- # check whether user runs rpimonitord on his own or we activated it
110- if [ -f /etc/armbianmonitor/start-monitoring ]; then
111- # we should already provide monitoring, check whether DEBUG
112- # is also set
113- ArmbianMonitoring=TRUE
114- read -r DebugMode < /etc/armbianmonitor/start-monitoring 2> /dev/null
115- fi
116-
117- # check whether rpimonitord is running and compare with ${ArmbianMonitoring}
118- # In case the user chose to run rpimonitord on his own, we skip the config
119- # part and only output disk info
120- :
121-
122- # check available disk devices
123- CheckDisks
12456} # Main
12557
12658ParseOptions () {
127- while getopts ' hHuUrRmMsnNd:Dc :C:pPvz ' c; do
59+ while getopts ' hHuUrRmMsnNd:c :C:pPv ' c; do
12860 case ${c} in
12961 H)
13062 # display full help test
173105 MonitorIO " ${OPTARG} "
174106 exit 0
175107 ;;
176- D)
177- fping ix.io 2> /dev/null | grep -q alive ||
178- (
179- echo " Network/firewall problem detected. Please fix this prior to installing RPi-Monitor." >&2
180- exit 1
181- )
182- DebugOutput=" $( mktemp /tmp/${0##*/ } .XXXXXX) "
183- trap " rm \" ${DebugOutput} \" ; exit 0" 0 1 2 3 15
184- set -x
185- exec 2> " ${DebugOutput} "
186- PreRequisits > /dev/null 2>&1
187- CheckDisks
188- which curl > /dev/null 2>&1 || apt-get -f -qq -y install curl
189- echo -e " \nDebug output has been collected at the following URL: \c"
190- (
191- cat " ${DebugOutput} "
192- echo -e " \n\n\ngdisk.txt contents:\n"
193- cat " ${MyTempDir} /gdisk.txt"
194- echo -e " \n\n\nsmartctl.txt contents:\n"
195- cat " ${MyTempDir} /smartctl.txt"
196- ) |
197- curl -F ' f:1=<-' ix.io
198- echo -e " Please post the URL in the Armbian forum where you've been asked for."
199- exit 0
200- ;;
201108 c | C)
202109 # check card mode
203110 CheckCard " ${OPTARG} "
209116 VerifyInstallation
210117 exit 0
211118 ;;
212- z)
213- # Do a quick 7-zip benchmark to estimate CPU performance
214- runs=$2
215- Run7ZipBenchmark 2> /dev/null
216- exit 0
217- ;;
218119 * )
219120 echo " Invalid flag: ${c} " >&2
220121 exit 7
@@ -231,18 +132,16 @@ DisplayUsage() {
231132 # grep "^#" "$0" | grep -v "^#\!/bin/bash" | sed 's/^#//'
232133 # fi
233134 echo
234- echo " Usage: $( basename $0 ) [-h] [-c \$ path] [-d \$ device] [-D] [- m] [-n] [-v] [-z ]"
135+ echo " Usage: $( basename $0 ) [-h] [-c \$ path] [-d \$ device] [-m] [-n] [-v]"
235136 echo
236137 echo " Options:"
237138 echo " -c /path/to/test Performs disk health/performance tests"
238139 echo " -d Monitors writes to \$ device"
239- echo " -D Tries to upload debug disk info to improve armbianmonitor"
240140 echo " -m Provides simple CLI monitoring - scrolling output"
241141 echo " -M Provides simple CLI monitoring - fixed-line output"
242142 echo " -n Provides simple CLI network monitoring - scrolling output"
243143 echo " -N Provides simple CLI network monitoring - fixed-line output"
244144 echo " -v Tries to verify installed package integrity"
245- echo " -z Runs a quick 7-zip benchmark to estimate CPU performance"
246145 echo
247146 echo " Note: The -u/-U options for support info upload are deprecated."
248147 echo " Use the 'armbian-debug' command instead."
@@ -932,32 +831,4 @@ kickAllStatsDown() {
932831 cnt=0
933832}
934833
935- Run7ZipBenchmark () {
936- echo -e " Preparing benchmark. Be patient please..."
937- # Do a quick 7-zip benchmark, check whether binary is there. If not install it
938- MyTool=$( which 7za || which 7zr)
939- [ -z " ${MyTool} " ] && apt-get -f -qq -y install p7zip && MyTool=/usr/bin/7zr
940- [ -z " ${MyTool} " ] && (
941- echo " No 7-zip binary found and could not be installed. Aborting" >&2
942- exit 1
943- )
944- # Send CLI monitoring to the background to be able to spot throttling and other problems
945- MonitoringOutput=" $( mktemp /tmp/${0##*/ } .XXXXXX) "
946- trap " rm \" ${MonitoringOutput} \" ; exit 0" 0 1 2 3 15
947- armbianmonitor -m > ${MonitoringOutput} &
948- MonitoringPID=$!
949- # run 7-zip benchmarks after waiting 10 seconds to spot whether the system was idle before.
950- # We run the benchmark a single time by default unless otherwise specified on the command line
951- RunHowManyTimes=${runs:- 1}
952- sleep 10
953- for (( i = 1 ; i <= RunHowManyTimes; i++ )) ; do
954- " ${MyTool} " b
955- done
956- # report CLI monitoring results as well
957- kill ${MonitoringPID}
958- echo -e " \nMonitoring output recorded while running the benchmark:\n"
959- sed -e ' /^\s*$/d' -e ' /^Stop/d' < ${MonitoringOutput}
960- echo -e " \n"
961- } # Run7ZipBenchmark
962-
963834Main " $@ "
0 commit comments