2

I'm looking for a way to get sadf (from sysstat package) to generate me the csv version of the collected data by sar of the current day.

I know that sar keeps it's configuration in /etc/sysstat/sysstat where it has it's SA_DIR specified. In my case (Ubuntu 16.04 LTS) it shows:

SA_DIR=/var/log/sysstat

I would like to get this value and use it for the sadf command like:

# instead of the hard coded path...
sadf -d /var/log/sysstat/sa$(date +%d -d yesterday)
# ... I would like something like this with a SA_DIR variable
sadf -d $SA_DIR/sa$(date +%d -d today)

How can I get the SA_DIR form the sar configuration file?


With @steve 's solution I ended up using sadf like this:

# Generate CSV's
. /etc/sysstat/sysstat
sadf -d $SA_DIR/sa$(date +%d -d today) -- -r     > memory_`date +%Y-%m-%d_%H-%M-%S`.csv  # Memory statistics
sadf -d $SA_DIR/sa$(date +%d -d today) -- -n DEV > network_`date +%Y-%m-%d_%H-%M-%S`.csv # Network statistics
sadf -d $SA_DIR/sa$(date +%d -d today) -- -u     > cpu_`date +%Y-%m-%d_%H-%M-%S`.csv     # CPU statistics
Bruno Bieri
  • 145
  • 9

1 Answers1

1

Run . /etc/sysstat/sysstat within your script. That will result in environment variable $SA_DIR being set appropriately.

steve
  • 21,582
  • 5
  • 48
  • 75