bash - How to write a Shell Script to get min max and average value from sar reports -


e.g.

02:00:01 pm     cpu     %user     %nice   %system   %iowait    %steal     %idle 02:10:01 pm         28.78      0.00     12.62     11.21      0.64     46.75 02:20:01 pm         26.28      0.00      9.84     12.62      0.46     50.80 02:30:01 pm         28.26      0.00      8.45     11.06      0.46     51.77 02:40:01 pm         18.89      0.00      5.88      9.00      0.19     66.04 02:50:01 pm         27.32      0.00      7.65      8.72      0.33     55.98 03:00:01 pm         23.56      0.00      7.54     14.35      0.21     54.33 03:10:01 pm         26.38      0.00     11.59     12.18      0.95     48.90 

i want write shell script fetches min max , avg values day report memory , cpu utilization , schedule in crontab.

awk can this. example compute average of user column (fourth column):

tail -n +2 data.txt | awk '{n += 1; user += $4} end {printf("%lf\n", user / n)}' 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -