Difference between revisions of "Ministat"

From James Dooley's Wiki
Jump to: navigation, search
(Overview)
(Script)
Line 11: Line 11:
  
 
<code>[bash,n]
 
<code>[bash,n]
#!/bin/bash
 
cmdtop=`top -c -b -n 1 | grep "PID" -A999`
 
 
cmdmysql=`mysqladmin proc stat | grep "|" | grep -v "Id" | awk 'BEGIN{FS="|"};{print $7,$6,$9}' | sort -n`
 
cmdmysql=`mysqladmin proc stat | grep "|" | grep -v "Id" | awk 'BEGIN{FS="|"};{print $7,$6,$9}' | sort -n`
  
wctop=`echo $cmdtop | wc -l`
 
 
wcmysql=`echo $cmdmysql | wc -l`
 
wcmysql=`echo $cmdmysql | wc -l`
  
Line 27: Line 24:
 
cat /proc/loadavg
 
cat /proc/loadavg
 
printf "%$(tput cols)s\n"|tr ' ' '='
 
printf "%$(tput cols)s\n"|tr ' ' '='
top -c -b -n 1 | grep "PID" -A999 | head -$nline
+
top -c -b -n 1 | grep -v "grep" | grep "PID" -A $nline
 
printf "%$(tput cols)s\n"|tr ' ' '='
 
printf "%$(tput cols)s\n"|tr ' ' '='
 
echo $cmdmysql | head -$nline
 
echo $cmdmysql | head -$nline
Line 34: Line 31:
 
printf "%$(tput cols)s\n"|tr ' ' '='
 
printf "%$(tput cols)s\n"|tr ' ' '='
 
httpd status | grep "requests/sec" -A6
 
httpd status | grep "requests/sec" -A6
 +
 
</code>
 
</code>
  

Revision as of 18:39, 17 May 2011

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] cmdmysql=`mysqladmin proc stat | grep "|" | grep -v "Id" | awk 'BEGIN{FS="|"};{print $7,$6,$9}' | sort -n`

wcmysql=`echo $cmdmysql | wc -l`

nline=`tput lines | awk '{print int(($1 - 18) / 2)}'` if [ $nline -gt $wcmysql ] then

 nline=`echo $nline $wcmysql | awk '{print $1 * 2 - $2}'`

fi

  1. Display Junk

cat /proc/loadavg printf "%$(tput cols)s\n"|tr ' ' '=' top -c -b -n 1 | grep -v "grep" | grep "PID" -A $nline printf "%$(tput cols)s\n"|tr ' ' '=' echo $cmdmysql | head -$nline printf "%$(tput cols)s\n"|tr ' ' '=' free | grep -v "cache:" printf "%$(tput cols)s\n"|tr ' ' '=' httpd status | grep "requests/sec" -A6

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

What to change