#!/usr/bin/env bash # echo 'create table access(timestamp int, cpu float, vhost varchar(128), method varchar(4), url varchar(128));' | sqlite3 apache-access.db read -r cpu vhost method url <<< $(apachectl fullstatus | egrep '(GET|POST|HEAD)' | sort -k5 -nr | head -1 | awk '{print $5,$13,$14,$15}') echo "insert into access values(DATETIME('now'), $cpu, \"$vhost\", \"$method\", \"$url\");" | sqlite3 apache-access.db sqlite3 -header -column apache-access.db "select * from access where cpu > 20 order by timestamp desc limit 10;"