Thursday, July 8, 2004

GeekTool

GeekTool screenshotI just have started using a very cool, but probably not all of that necessary, tool. It is called GeekTool. It will create windows that will either always be on the desktop, or floating above other windows that will display three types of information.
  1. Contents of local text files (using tail)
  2. Local or remote graphic
  3. Output of shell command



I have included screen shot of how I am using it.
  1. In the upper right corner, there is an icon that shows the system load
  2. The lower right corner shows the active network interfaces
  3. In the lower left corner, the current calendar
  4. Right above that is the current TiVo stock graph
I run the following script once a second to get the current load

#!/usr/bin/perl

$UPTIME = `uptime`;
$UPTIME =~ s/.*averages: (S+),?.*/$1/g;
$TARGET=shift;
print $UPTIME;

if ($UPTIME > $TARGET)
{
exit 1;
}
else
{
exit 0;
}

When the script returns a non 0 result code, it displays a red icon, other wise it displays a green one.

Here is a sample of the script that I run to display the icons for the network interface. This script gets run every 10 seconds.

ifconfig en0 |grep " active"

When the script returns a 0 result code, it displays the icon for the network interface

Here is the script that I use for the calendar. I have this script run once an hour to update it correctly

#!/bin/bash

echo `date "+%d %B %Y"` | awk
'{ print substr(" ",1,(21-length($0))/2) $0; }';
cal | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" ");
a=$0; sub(" "fill int(cday)" ","*"fill int(cday)"*",a); print a }'

To get the graph for the TiVo stock, I entered this url, and then I have it updated every 5 minutes



I would love to use this to run a shell script to put up a couple of window so I can monitor a couple of servers that I maintain. What I would like to do is to write a script that ssh's into a server, does a sudo su -, and then tails some log files. The problem with doing this is that it will only show the output of a shell script when the shell command has finished. So I don't think that it will be possible to have it contstantly monitor a tail process on another machine.

2 comments:

  1. I've managed to tail log files remote using the following:
    ssh 'sudo tail -f /var/log/messages'
    Regards,
    Stig

    ReplyDelete
  2. This works but could probably be improved upon as it only will tail while you have a terminal running in the background.
    -Set up public_key authentication with remote server.
    -Create a bash script which tails remote log and writes contents to a local file.
    -Open a terminal and run the script
    -Display the local file in GeekTool
    Here's an example bash script
    #!/usr/bin/bash
    ssh user@192.168.1.46 tail -f /var/log/php-error.log > /Users/username/Documents/remote-php-log.log

    ReplyDelete

Empowering Family Legacy: How I Transitioned to Self-Hosting with Gramps Web

For several years now, I've been maintaining a genealogy website containing information from both my and my wife's family history. O...