The Problem
After changing the hostname from geeklab_old to geeklab_new, the sar report still shows the old hostname.
# sar -f /var/log/sa/sa09 Linux 5.4.17-2102.200.13.el8uek.x86_64 (geeklab_old) 04/09/2021 _x86_64_ (4 CPU) ...
The hostname change is reflected in /var/log/messages:
Apr 9 14:32:33 geeklab_old systemd[1]: Starting Hostname Service... Apr 9 14:32:33 geeklab_old dbus-daemon[1117]: [system] Successfully activated service 'org.freedesktop.geeklab_old' Apr 9 14:32:33 geeklab_old systemd[1]: Started Hostname Service. Apr 9 14:32:33 geeklab_old systemd-hostnamed[6551]: Changed host name to 'geeklab_old' Apr 9 14:32:44 geeklab_old systemd[1]: NetworkManager-dispatcher.service: Succeeded. Apr 9 14:33:03 geeklab_old systemd[1]: systemd-hostnamed.service: Succeeded. Apr 9 14:35:00 geeklab_old systemd[1]: Starting system activity accounting tool... Apr 9 14:35:00 geeklab_old systemd[1]: sysstat-collect.service: Succeeded. Apr 9 14:35:00 geeklab_old systemd[1]: Started system activity accounting tool. Apr 9 14:40:00 geeklab_old systemd[1]: Starting system activity accounting tool... Apr 9 14:40:00 geeklab_old systemd[1]: sysstat-collect.service: Succeeded. Apr 9 14:40:00 geeklab_old systemd[1]: Started system activity accounting tool. Apr 9 14:41:43 geeklab_old kernel: Command line: BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.4.17-2102.200.13.el8uek.x86_64 root=/dev/mapper/ol-root ro crashkernel=auto n et.ifnames=0 biosdevname=0 resume=/dev/mapper/ol-swap rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rd.lvm.lv=ol/usr rhgb quiet numa=off transparent_hugepage=never Apr 9 14:41:43 geeklab_old kernel: Disabled fast string operations Apr 9 14:41:43 geeklab_old kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
The Solution
When you change the hostname, these changes will get reflected only in the newly created /var/log/sa/saXX logs. The new hostname will get updated from the next day’s /var/log/sa/saXX file.
If the current day’s log needs to be updated with the new hostname, follow the below steps:
1. Stop sysstat service:
# systemctl stop sysstat
2. Remove or take backup of current /var/log/sa/saXX file:
# mv /var/log/sa/sa09 /backup/
3. Start sysstat service:
# systemctl start sysstat
4. Confirm the hostname change:
# sar -f /var/log/sa/sa09
Linux 5.4.17-2102.200.13.el8uek.x86_64 (geeklab_new) 04/09/2021 _x86_64_ (4 CPU)
...