Apache uptime in seconds

I’m looking at some interesting anomalies on a cPanel VPS I administer, and wanted to add Apache uptime graphing. Building on this ServerFault solution, here is a way to get the number of seconds Apache has been up. Whitespace/line breaks added for clarity.

ps -eo comm,etime |
grep httpd |
ruby -ne 'sec, min, hour, day = $_.split(/ /).last.chomp.split(/[-:]/).reverse;
          p day.to_i*24*60*60 + hour.to_i*60*60 + min.to_i*60 + sec.to_i' |
sort -nr |
head -n1


And without the whitespace, for ease of copy/pasting:

ps -eo comm,etime | grep httpd | ruby -ne 'sec, min, hour, day = $_.split(/ /).last.chomp.split(/[-:]/).reverse; p day.to_i*24*60*60 + hour.to_i*60*60 + min.to_i*60 + sec.to_i' | sort -nr | head -n1