]> git.proxmox.com Git - ksm-control-daemon.git/commitdiff
ksmtuned: fix formatting when summing up large numbers
authorStefan Lendl <s.lendl@proxmox.com>
Mon, 8 Apr 2024 12:17:43 +0000 (14:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 8 Apr 2024 12:39:13 +0000 (14:39 +0200)
awk internally uses float for every calculation, printing a large float
with awk results in 1.233e+09 format which causes the script to fail afterwards.
Instead I am printing the float without decimals.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
debian/patches/awk-printf.diff [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/awk-printf.diff b/debian/patches/awk-printf.diff
new file mode 100644 (file)
index 0000000..8502068
--- /dev/null
@@ -0,0 +1,16 @@
+--- ksm-control-scripts/ksmtuned       2024-01-25 11:33:03.485039813 +0100
++++ ksm-control-scripts.new/ksmtuned   2024-01-25 11:37:40.544751316 +0100
+@@ -72,11 +72,11 @@
+     # calculate how much memory is committed to running qemu processes
+     local progname
+     progname=${1:-kvm}
+-    ps -C "$progname" -o rsz | awk '{ sum += $1 }; END { print sum }'
++    ps -C "$progname" -o rsz | awk '{ sum += $1 }; END { printf ("%.0f", sum) }'
+ }
+ free_memory () {
+-    awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END {print free}' \
++    awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END { printf ("%.0f", free) }' \
+                 /proc/meminfo
+ }
index 32d3a355fbc5c8b294fc71a38456f9c56d92fce5..24e86782786f30c8af1a53c108f90daf5860ca5f 100644 (file)
@@ -1,3 +1,4 @@
 init-script.diff
 ksmtuned.diff
 adjust-ksm-slepp.diff
+awk-printf.diff