I want to have output output of iostat printed periodically and logged. Executing the command in the shell prints out the normal fields as expected:

# iostat 
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          50.11    0.00    0.09    0.05    0.00   49.75

Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
mmcblk0           0.83         8.74         5.94      60203      40924

however converting that into a systemd service makes it lose some digits when being plotted:

[ 6985.525825] iostat[1238]: Linux 4.14.0 (02c0008119356e06)    07/17/18    _armv7l_    (4 CPU)
[ 6985.530177] iostat[1238]: avg-cpu:  %user   %nice %system %iowait  %steal   %idle
[ 6985.531455] iostat[1238]:           50.11   ###   NO DIGITS? WHY NOT? ###
[ 6985.532203] iostat[1238]: Device             tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
[ 6985.534054] iostat[1238]: mmcblk0           0.83         8.62         5.93      60203      41403

There isn't anything special about the unit file, I use it as a template and has worked so far:

~# cat /lib/systemd/system/iostat.service




The version where the issue is manifesting itself is systemd 234. Trying the same recipe on a newer version systemd 237 isn't showing issues. Could be a resolved bug in systemd.

  • You just needed ExecStart in service field and multi-user.target in install field. It would work on systemd. You need to create shell script for iostat command. So you can get a good result from shell script. – supriady Jul 17 '18 at 12:39
  • This appears to be a fixed bug in systemd. – Mark Stosberg Jul 17 '18 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.