Skip to content

performance & monitoring

monitoring

I monitor this server using https://ping.gl

It is simple to setup and sends me emails if the site goes down or comes back up.

glances

glances is what I use to monitor this linux server it provides a handy dashboard

https://nicolargo.github.io/glances/

you also use it to save reports

glances -export csv -export-csv-file "~/folder/file.csv"

pipelines

gitlab emails me if the pipeline fails

saving top reports

https://unix.stackexchange.com/questions/343911/adding-timestamp-to-top-command-output

top -b1 -n1 | awk -vtime="$(date +%m-%d-%Y-%T)" 'NR<7{print;next}NR==7{printf("Time\t\t\t\t%s\n",$0)}NR>8{printf("%s\t%s\n",time,$0)}' > cpu.txt

explanation

top -b1 -n1 -- gives the top output and come back to terminal
-vtime="$(date +"%m-%d-%Y-%T)"  -- store the current time to variable called time
NR<7{print;next} -- read the lines from 1 to 6 and print it.
NR==7{printf("Time\t\t\t\t%s\n",$0)}  -- if it is 7th line, then add Time as first column
NR>8{printf("%s\t%s\n",time,$0)}'  -- add the calculated time in first field
top -n 1 -b | grep -Ev "Tasks:|Swap:|Cpu|Mem:" > top_file
grep "PID" top_file > top_test
sed -i '/PID/d;/top/d;/^$/d' top_file
awk '{print strftime("%m-%d-%Y-%H:%M:%S", systime())" " $0}' top_file > top_final
sed -i "s/./timestamp /1" top_test
cat top_final >> top_test
sed -i 's/( )*/\1/g;s/ /,/g' top_test