Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysstat service under systemd #328

Open
sorrynothanksbye opened this issue Jun 27, 2022 · 12 comments
Open

sysstat service under systemd #328

sorrynothanksbye opened this issue Jun 27, 2022 · 12 comments

Comments

@sorrynothanksbye
Copy link

hi sysstat team!
is there a way to run sysstat on an embedded device with systemd only? the apt env is not available to me currently
`[Unit]
Description=Testing Sysstat For now

[Service]
Type=oneshot
RemainAfterExit=yes
User=myuserid
ExecStart=/usr/bin/sar -A -D 1 1 --boot

[Install]
WantedBy=multi-user.target
`
much appreciate any assistance... and if this is the wrong forum, i can take this to another forum... thank you! :)

@stevekay
Copy link
Contributor

Hi, what distro is the embedded device using, and what issue / error message are you encountering ?

@sorrynothanksbye
Copy link
Author

hi :)
the distro is from yocto open embedded
the ExecStart=/usr/bin/sar -A -D 1 1 --boot error is (code=exited, status=1/FAILURE)

removing the --boot sends the logs to journal logs, and would prefer to use the output log directory that was defined in /etc/sysconfig/sysstat under SA_DIR to collect the logs

the hope is to use the output logs and run the above sysstat as a service with an implemented timer that has enabled status, so the log may be incremented.

@sysstat
Copy link
Owner

sysstat commented Jun 28, 2022

Hi
ExectStart command is wrong (e.g. --boot is not an option recognized by sar).
On my machine the contents of the /usr/lib/systemd/system/sysstat-collect.service unit is:

# /usr/lib/systemd/system/sysstat-collect.service
# (C) 2014 Tomasz Torcz <[email protected]>
#
# sysstat-12.5.6 systemd unit file:
#        Collects system activity data
#        Activated by sysstat-collect.timer unit

[Unit]
Description=system activity accounting tool
Documentation=man:sa1(8)
After=sysstat.service

[Service]
Type=oneshot
User=root
ExecStart=/usr/lib64/sa/sa1 1 1

And the contents of the /usr/lib/systemd/system/sysstat.service unit is:

# /usr/lib/systemd/system/sysstat.service
# (C) 2012 Peter Schiffer (pschiffe <at> redhat.com)
#
# sysstat-12.5.6 systemd unit file:
#	 Insert a dummy record in current daily data file.
#	 This indicates that the counters have restarted from 0.

[Unit]
Description=Resets System Activity Logs

[Service]
Type=oneshot
RemainAfterExit=yes
User=root
ExecStart=/usr/lib64/sa/sa1 --boot

[Install]
WantedBy=multi-user.target
Also=sysstat-collect.timer
Also=sysstat-summary.timer

@sorrynothanksbye
Copy link
Author

sorrynothanksbye commented Jun 29, 2022

Thank you for the above clarification. :)

I modified to the above ExecStart and the output is a oneshot like the service states, though my hope is to also have the data occur everyone X time based on a timer. The timer is below, and the status of sysstat.timer is enabled and sysstat.service is disabled and present: enabled.

However, the data outputs to /var/log/sa/ with the right timestamp info, though I'm hoping to have the output use SA_DIR=/path/to/custom/dir.

[Unit]
Description=sysstat timer

[Timer]
OnCalendar=*:00/10
Persistent=true

[Install]
WantedBy=timers.target
[Unit]
Description=Testing Sysstat For now

[Service]
Type=oneshot
RemainAfterExit=yes
User=myuserid
ExecStart=/usr/lib/sa/sa1

[Install]
WantedBy=multi-user.target

@sorrynothanksbye
Copy link
Author

are we able to log to a specific directory with the systemd timer?
maybe my above config still has issues?

@sysstat
Copy link
Owner

sysstat commented Jul 1, 2022

In fact I don't understand why you don't let sysstat do all the work for you (creating the systemd units, etc.)...?
Install the sources. Configure sysstat with a command like:

$ ./configure sa_dir=/my/log/directory --enable-install-cron cron_interval=5

In the example above, sadc will run once every 5 minutes and log its data to /my/log/directory. Other options are available (you can use the interactive configuration script if necessary: $ ./iconfig instead of $ ./configure (...))
Then compile and install sysstat as usual:

$ make
(...)
$ sudo make install
(...)

The directory where logs will be saved can also be specified in the /etc/sysconfig/sysstat configuration file with the SA_DIR variable (see sysstat(5) manual page).

@sorrynothanksbye
Copy link
Author

Cron does not appear to be an option for me to use with this setup and only systemd is available... is cron recommended or needed with custom directories, or in general?

The sysstat environment is being configured from Yocto and the configuration file has the line SA_DIR=/my/log/dir for the build environment to customize the log path, but we are not using cron.

@sysstat
Copy link
Owner

sysstat commented Jul 2, 2022

sysstat uses systemd by default when available. systemd is the preferred way over crond to start sadc periodically, and as a consequence, crond is not needed for sysstat to work.

@ViggoC
Copy link

ViggoC commented Dec 8, 2023

sysstat uses systemd by default when available. systemd is the preferred way over crond to start sadc periodically, and as a consequence, crond is not needed for sysstat to work.

Hi @sysstat Since sysstat uses systemd by default, I think it would be better to change the install from ubuntu part in readme. I higher version of debian and ubuntu, modify /etc/default/sysstat do not work. FYI, https://serverfault.com/questions/1094466/sar-service-has-stopped-collecting-data/1115810

@sysstat
Copy link
Owner

sysstat commented Dec 9, 2023

@ViggoC So if I understand well, one should enter

$ sudo systemctl enable sysstat
$ sudo systemctl start sysstat

on a Debian machine running systemd instead of editing /etc/default/sysstat?

@ViggoC
Copy link

ViggoC commented Dec 9, 2023

@sysstat My release version is Ubuntu 22.04.3 LTS, for me the simplest way is running sudo dpkg-reconfigure sysstat and select yes.

sysstat added a commit that referenced this issue Dec 14, 2023
Editing "/etc/default/sysstat" doesn't work on Debian-based machines
using systemd.
See #328

Signed-off-by: Sebastien GODARD <[email protected]>
@sysstat
Copy link
Owner

sysstat commented Dec 14, 2023

README file has been updated (see commit a254dbf).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants