GnuPlot in your toolset
06 Jul 2017 in gnuplot
Recently I was asked to investigate a web server issue not responding in regural intervals.
After spending some time digging around in logs and configs, I developed a solution to log the server load at small time intervals in order to have a better view of what's happening.
To do this, create a very simple shell script to store the time and server load:
#!/bin/bash echo date +%Y%m%d-%H%M%S >> report/uptime.log uptime >> uptime.log
Then run this script at an interval of 5 secs:
while true; do echo -en . ; bash report.sh ; sleep 5; done
When enough data has gathered, prepare for use with gnuplot:
cat uptime.log \ | sed 'N;s/\n/ /' \ | cut -d' ' -f1,15 \ | sed -s 's/,//g' > uptime.plot
And plot it:
gnuplot -p -e ' set xdata time; set timefmt "%Y%m%d-%H%M%S"; plot "uptime.plot" using 1:2; '