Can't check kernel version on arm64 systems
list Jaap Winius
Hi folks, My systems mostly run the Debian 11 xymon-client and hobbit-plugins packages for amd64 and armhf. However, I've now got a few arm64 systems (for the Odroid N2+) and have run into a problem. After installing a few missing dependencies for this architecture (libyaml-tiny-perl, libfile-slurp-perl and lsof), the libs check now says: Couldn't check for string '4.9.277-arm64' in /boot/vmlinuz-4.9.277-arm64. Can't check kernel version! Seeing as there's nothing wrong with my systems, how can I get Xymon to ignore this issue, or better yet, run the kernel version properly? Thanks, Jaap
list Christoph Zechner
Hi,
we had the same problems on our pi, my colleague came up with this patch for the libs [1] check:
--- libs.orig
+++ libs
@@ -73,6 +73,11 @@
if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /sparc/) {
$kernel_image_read_command = "zcat '$newest_kernel_image' | strings";
}
+ if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /armhf/) {
+ my $offset = `grep --only-matching --byte-offset --binary --text '\x1f\x8b' '$newest_kernel_image' 2>/dev/null| head -1 | cut -f 1 -d :`;
+ $offset =~ s/\n//g;
+ $kernel_image_read_command = "dd if='$newest_kernel_image' skip=1 bs=$offset 2>/dev/null | gunzip 2>/dev/null | strings";
+ }
$kernel_image_read_command .=
" | egrep '^$kernel_image_release|^Linux version '";
Hope it helps!
Cheers
Christoph
[1] /usr/lib/xymon/client/ext/libs
On 28/07/2022 11:46, Jaap Winius via Xymon wrote:list Jaap Winius
Hi Christoph, Thanks for your reply. I tried applying your patch to /usr/lib/xymon/client/ext/libs (and then changing 'armhf' to 'arm64'), but alas: the situation remains unchanged. Should something else be added as well? The current kernel image on this Debian 11 Odroid system is called /boot/vmlinuz-4.9.277-arm64 in case you're interested. Cheers, Jaap Quoting Christoph Zechner <user-249716582ccc@xymon.invalid>:
▸
Hi,
we had the same problems on our pi, my colleague came up with this patch for the libs [1] check:
--- libs.orig
+++ libs
@@ -73,6 +73,11 @@
if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /sparc/) {
$kernel_image_read_command = "zcat '$newest_kernel_image' | strings";
}
+ if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /armhf/) {
+ my $offset = `grep --only-matching --byte-offset --binary --text '\x1f\x8b' '$newest_kernel_image' 2>/dev/null| head -1 | cut -f 1 -d :`;
+ $offset =~ s/\n//g;
+ $kernel_image_read_command = "dd if='$newest_kernel_image' skip=1 bs=$offset 2>/dev/null | gunzip 2>/dev/null | strings";
+ }
$kernel_image_read_command .=
" | egrep '^$kernel_image_release|^Linux version '";
Hope it helps!
Cheers
Christoph
[1] /usr/lib/xymon/client/ext/libs
On 28/07/2022 11:46, Jaap Winius via Xymon wrote:list Christoph Zechner
▸
On 28/07/2022 13:10, Jaap Winius wrote:
Hi Christoph, Thanks for your reply. I tried applying your patch to /usr/lib/xymon/client/ext/libs (and then changing 'armhf' to 'arm64'), but alas: the situation remains unchanged. Should something else be added as well?
Hm, in our case (bananapi with armbian), this fixed the issue, maybe it needs a little refining with your architecture... :-/ Cheers Christoph
▸
The current kernel image on this Debian 11 Odroid system is called /boot/vmlinuz-4.9.277-arm64 in case you're interested. Cheers, Jaap Quoting Christoph Zechner <user-249716582ccc@xymon.invalid>:Hi, we had the same problems on our pi, my colleague came up with this patch for the libs [1] check: --- libs.orig +++ libs @@ -73,6 +73,11 @@ ???? if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /sparc/) { ???????? $kernel_image_read_command = "zcat '$newest_kernel_image' | strings"; ???? } +??? if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /armhf/) { +??????? my $offset = `grep --only-matching --byte-offset --binary --text '\x1f\x8b' '$newest_kernel_image' 2>/dev/null| head -1 | cut -f 1 -d :`; +??????? $offset =~ s/\n//g; +??????? $kernel_image_read_command = "dd if='$newest_kernel_image' skip=1 bs=$offset 2>/dev/null | gunzip 2>/dev/null | strings"; +??? } ???? $kernel_image_read_command .= ???????? " | egrep '^$kernel_image_release|^Linux version '"; Hope it helps! Cheers Christoph [1] /usr/lib/xymon/client/ext/libs On 28/07/2022 11:46, Jaap Winius via Xymon wrote:
list Adam Goryachev
▸
On 28/7/2022 19:46, Jaap Winius via Xymon wrote:
Hi folks, My systems mostly run the Debian 11 xymon-client and hobbit-plugins packages for amd64 and armhf. However, I've now got a few arm64 systems (for the Odroid N2+) and have run into a problem. After installing a few missing dependencies for this architecture (libyaml-tiny-perl, libfile-slurp-perl and lsof), the libs check now says: Couldn't check for string '4.9.277-arm64' in /boot/vmlinuz-4.9.277-arm64. Can't check kernel version! Seeing as there's nothing wrong with my systems, how can I get Xymon to ignore this issue, or better yet, run the kernel version properly? Thanks, Jaap
In my case, looks like I made two small changes:
???? my $kernel_image_release = $1;
???? my $kernel_image_read_command = "strings '$newest_kernel_image'";
-??? if (`dpkg --print-architecture` =~ /sparc/) {
+??? if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /(sparc|arm64)/) {
??????? $kernel_image_read_command = "zcat -f --stdout '$newest_kernel_image' | strings";
???? }
-??????????? if ($kernel_image_version =~ /^(Linux version )?\Q$running_kernel_release\E \(.*\) \Q$running_kernel_version\E$/) {
+??????????? if ($kernel_image_version =~ /^(Linux version )?\Q$running_kernel_release\E \(.*\) \Q$running_kernel_version\E/) {
In addition, you will need to create these two files:
$ cat /etc/kernel/postinst.d/statoverride
#!/bin/sh
version="$1"
# passing the kernel version is required
[ -z "${version}" ] && exit 0
echo "Checking /boot/vmlinuz-${version}"
dpkg-statoverride --list /boot/vmlinuz-${version}
if `dpkg-statoverride --list /boot/vmlinuz-${version} > /dev/null`
then
?? ?echo "Override found - skipping"
?? ?exit 0
else
?? ?dpkg-statoverride --update --add root adm 0640 /boot/vmlinuz-${version}
fi
exit 0
$ cat /etc/kernel/postrm.d/statoverride
#!/bin/bash
version="$1"
# passing the kernel version is required
[ -z "${version}" ] && exit 0
echo "Checking /boot/vmlinuz-${version}"
dpkg-statoverride --list /boot/vmlinuz-${version}
if `dpkg-statoverride --list /boot/vmlinuz-${version} > /dev/null`
then
?? ?echo "No override found - skipping"
?? ?exit 0
else
?? ?dpkg-statoverride --remove /boot/vmlinuz-${version}
fi
exit 0
Finally, since these will only run during kernel package installation/removal, you should run the postinst script manually for currently installed kernels.
I do also modify the default permissions for xymon to add it to the adm group, this provides access to /var/log files as well as the above kernel images which are group adm and permission 640, so you either need to do that as well or adjust the permissions assigned in the postinst so that xymon will have read access.
Hope that helps
list Jaap Winius
Hi Adam, Yes, that one appears to do the trick. All is green and I can once again relax. :-) Thank you very much! Cheers, Jaap Quoting Adam Goryachev via Xymon <xymon at xymon.com>:
▸
On 28/7/2022 19:46, Jaap Winius via Xymon wrote:Hi folks, My systems mostly run the Debian 11 xymon-client and hobbit-plugins packages for amd64 and armhf. However, I've now got a few arm64 systems (for the Odroid N2+) and have run into a problem. After installing a few missing dependencies for this architecture (libyaml-tiny-perl, libfile-slurp-perl and lsof), the libs check now says: Couldn't check for string '4.9.277-arm64' in /boot/vmlinuz-4.9.277-arm64. Can't check kernel version! Seeing as there's nothing wrong with my systems, how can I get Xymon to ignore this issue, or better yet, run the kernel version properly? Thanks, JaapIn my case, looks like I made two small changes: ???? my $kernel_image_release = $1; ???? my $kernel_image_read_command = "strings '$newest_kernel_image'"; -??? if (`dpkg --print-architecture` =~ /sparc/) { +??? if (-x '/usr/bin/dpkg' and `dpkg --print-architecture` =~ /(sparc|arm64)/) { ??????? $kernel_image_read_command = "zcat -f --stdout '$newest_kernel_image' | strings"; ???? } -??????????? if ($kernel_image_version =~ /^(Linux version )?\Q$running_kernel_release\E \(.*\) \Q$running_kernel_version\E$/) { +??????????? if ($kernel_image_version =~ /^(Linux version )?\Q$running_kernel_release\E \(.*\) \Q$running_kernel_version\E/) { In addition, you will need to create these two files: $ cat /etc/kernel/postinst.d/statoverride #!/bin/sh version="$1" # passing the kernel version is required [ -z "${version}" ] && exit 0 echo "Checking /boot/vmlinuz-${version}" dpkg-statoverride --list /boot/vmlinuz-${version} if `dpkg-statoverride --list /boot/vmlinuz-${version} > /dev/null` then ?? ?echo "Override found - skipping" ?? ?exit 0 else ?? ?dpkg-statoverride --update --add root adm 0640 /boot/vmlinuz-${version} fi exit 0 $ cat /etc/kernel/postrm.d/statoverride #!/bin/bash version="$1" # passing the kernel version is required [ -z "${version}" ] && exit 0 echo "Checking /boot/vmlinuz-${version}" dpkg-statoverride --list /boot/vmlinuz-${version} if `dpkg-statoverride --list /boot/vmlinuz-${version} > /dev/null` then ?? ?echo "No override found - skipping" ?? ?exit 0 else ?? ?dpkg-statoverride --remove /boot/vmlinuz-${version} fi exit 0 Finally, since these will only run during kernel package installation/removal, you should run the postinst script manually for currently installed kernels. I do also modify the default permissions for xymon to add it to the adm group, this provides access to /var/log files as well as the above kernel images which are group adm and permission 640, so you either need to do that as well or adjust the permissions assigned in the postinst so that xymon will have read access. Hope that helps