- Contents of local text files (using tail)
- Local or remote graphic
- Output of shell command
I have included screen shot of how I am using it.
- In the upper right corner, there is an icon that shows the system load
- The lower right corner shows the active network interfaces
- In the lower left corner, the current calendar
- Right above that is the current TiVo stock graph
#!/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.$UPTIME = `uptime`;
$UPTIME =~ s/.*averages: (S+),?.*/$1/g;
$TARGET=shift;
print $UPTIME;
if ($UPTIME > $TARGET)
{
exit 1;
}
else
{
exit 0;
}
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 minutesecho `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 }'
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.
I've managed to tail log files remote using the following:
ReplyDeletessh 'sudo tail -f /var/log/messages'
Regards,
Stig
This works but could probably be improved upon as it only will tail while you have a terminal running in the background.
ReplyDelete-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