Difference between revisions of "Ministat"
(→Script) |
(→Script) |
||
| Line 18: | Line 18: | ||
} | } | ||
function checkapache { | function checkapache { | ||
| − | httpd status 2>&1 | grep "requests/sec" - | + | if [ -d "/var/cpanel" ] |
| + | then | ||
| + | httpd status 2>&1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep "requests/sec" -A $aline | ||
| + | else | ||
| + | lynx --dump http://localhost/server-status 2>&1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep "requests/sec" -A $aline | ||
| + | fi | ||
return | return | ||
} | } | ||
function calclines { | function calclines { | ||
| − | nline=`tput lines | awk '{print int(($1 - | + | nline=`tput lines | awk '{print int(($1 - 14) / 3)}'` |
| + | aline=`echo $nline 3 | awk '{print $1 + $2}'` | ||
if [ $nline -gt $wcmysql ] | if [ $nline -gt $wcmysql ] | ||
then | then | ||
| Line 49: | Line 55: | ||
addseperator | addseperator | ||
| − | + | checkapache | |
| + | |||
</code> | </code> | ||
Revision as of 13:30, 18 May 2011
Contents
Overview
Down and dirty mini status viewer. Makes it easy to monitor several different sections of a server at the same time.
Useful for monitoring a server that is having problems.
The main concept is to minify the output of several sections in to a small terminal window, useful for monitoring a server when it is having problems or could at some point.
Auto adjusts output based on size of the terminal.
Script
[bash,n]
- !/bin/bash
function checkmysql { cmdmysql=`mysqladmin proc stat 2>&1 | grep "|" | grep -v "Id" | awk 'BEGIN{FS="|"};{print $7,$6,$9}' | sort -n` wcmysql=`echo $cmdmysql | wc -l` return } function checkapache { if [ -d "/var/cpanel" ] then httpd status 2>&1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep "requests/sec" -A $aline else lynx --dump http://localhost/server-status 2>&1 | sed -n '/requests\/sec/,/Scoreboard/p' | sed 'N;$!P;$!D;$d' | grep "requests/sec" -A $aline fi return } function calclines { nline=`tput lines | awk '{print int(($1 - 14) / 3)}'` aline=`echo $nline 3 | awk '{print $1 + $2}'` if [ $nline -gt $wcmysql ] then nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'` fi return } function addseperator { printf "%$(tput cols)s\n"|tr ' ' '=' return }
cat /proc/loadavg addseperator
checkmysql calclines
top -c -b -n 1 | grep -v "grep" | grep "PID" -A $nline addseperator
free | grep -v "cache:" addseperator
echo $cmdmysql | head -$nline addseperator
checkapache
Usage
Direct download and execution of script (auto mode)
[bash,n]wget http://wiki.jamesdooley.us/scripts/ministat -O ministat; watch -n 10 sh ministat; rm -f ministat