Skip to content

Commit

Permalink
fix: pass an argument to the awk script as a variable
Browse files Browse the repository at this point in the history
MonitorIO: Add an argument check and a hint to the user
  • Loading branch information
The-going committed Jan 20, 2023
1 parent fc417f5 commit 4fe4e21
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/bsp/common/usr/bin/armbianmonitor
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,21 @@ ProcessStats() {
} # ProcessStats

MonitorIO() {
LastPagesOut=$(awk -F" " '/pgpgout/ {print $2}' </proc/vmstat)
LastWrite=$(awk -F" " "/ $1 / {print \$8}" </proc/diskstats)
LastPagesOut=$(awk '/pgpgout/ {print $2}' </proc/vmstat)
if grep -q "$1" /proc/diskstats; then
LastWrite=$(awk -v d="$1" '{if($3 == d) print $8}' </proc/diskstats)
else
echo "Bud argument: [$1]"
echo "Disks valid for monitoring: $(
awk '{if($8 != 0) printf "%s ", $3}' /proc/diskstats
)"
exit 1
fi
LastTimeChecked=$(date "+%s")
while true ; do
CurrentWrite=$(awk -F" " "/ $1 / {print \$8}" </proc/diskstats)
CurrentWrite=$(awk -v d="$1" '{if($3 == d) print $8}' </proc/diskstats)
if [ ${CurrentWrite} -gt ${LastWrite} ]; then
PagesOut=$(awk -F" " '/pgpgout/ {print $2}' </proc/vmstat)
PagesOut=$(awk '/pgpgout/ {print $2}' </proc/vmstat)
TimeNow=$(date "+%s")
PagesWritten=$((CurrentWrite - LastWrite))
PageOuts=$((PagesOut - LastPagesOut))
Expand Down

0 comments on commit 4fe4e21

Please sign in to comment.