Tag Archives: VPS

Ubuntu VPS Performance Monitoring

I run several PHP websites in Jooma and WordPress on Ubuntu VPS using Nginx as the web server with PHP-FPM for processing PHP. In most cases all the sites work fast enough, but sometimes (probably once a couple days) I got a message from Yandex (Russian search engine like Google) telling that one of my websites did not respond within 5 seconds. I set up Nginx slowlog and detected that sometimes HTTP requests are processed for more than 5 seconds:


Monitoring CPU Steal Time with command line in Ubuntu

Bash command that writes CPU Steal Time along with other CPU usage statistics from top command header once in a second to MySQL database:

top -b -d 1 | ts ‘%Y-%m-%d %H:%M:%S’ | sed -rn “s/(.{19} )Cpu\(s\):\s+([0-9]+\.[0-9]+)%us,\s+([0-9]+\.[0-9]+)%sy,\s+([0-9]+\.[0-9]+)%ni,\s+([0-9]+\.[0-9]+)%id,\s+([0-9]+\.[0-9]+)%wa,\s+([0-9]+\.[0-9]+)%hi,\s+([0-9]+\.[0-9]+)%si,\s+([0-9]+\.[0-9]+)%st(.*)/INSERT INTO m_perf_stat (CDate, cpu_us,  cpu_sy,  cpu_ni, cpu_id,  cpu_wa,  cpu_hi,  cpu_si,  cpu_st) VALUES (‘\1′, \2, \3, \4, \5, \6, \7, \8, \9);/p” | mysql -u <username> -p<password> <database>

that’s the longest bash command I ever written in my life Улыбка