Monitoring with sysstat

This is a fast way to monitor a system using the sysstats utilities that are very lightweight and installed by default on almost every linux distribution.

This will generate a tiny svg image that can be uploaded with a cron job on a website.

#!/bin/bash - 
#===============================================================================
#
#          FILE: sadf.sh
# 
#         USAGE: ./sadf.sh 
# 
#   DESCRIPTION: 
# 
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR:  Max , 
#  ORGANIZATION: Max @ MRS
#       CREATED: 24/02/18 13:15:33
#      REVISION:  ---
#===============================================================================

set -o nounset                              # Treat unset variables as an error
sadf -g  /var/log/sysstat/sa`date +%d` -O showinfo,skipempty -T  -- -r -w - -q   -dp --dev=sda -S -n DEV -n EDEV -P all -m CPU,FREQ,TEMP,IN |sed  -e s/"text x"/"text font-family='Noto Sans' x"/ -e s/"2: coretemp-isa-0000"/AVG/ -e s/"3: coretemp-isa-0000"/"CPU 1"/  -e s/"4: coretemp-isa-0000"/"CPU 2"/  -e s/"5: coretemp-isa-0000"/"CPU 3"/ -e s/"6: coretemp-isa-0000"/"CPU 4"/ -e s/'x= "0"'/'x="250"'/ -e s/'stroke="brown"'/'style="fill: darkorange; stroke: none; font-weight: bold;"'/  > /media/sda2/monitoring/zbox_`date +%y%m%d`.svg

cat /media/sda2/monitoring/index.html | sed -e s/XXX/"`date +%y%m%d`"/ > /media/sda2/monitoring/index.htm
sync

curl --key ~/.ssh/id_ecdsa -k  -T "/media/sda2/monitoring/index.htm"  sftp://xxxx  -u user:passwd 

It will looks like this:

monitoring