Use GKrellM over SSH for remote monitoring
One of my all-time favorite programs is GKrellM. I love it. I'm a sucker for monitoring apps, and this one is the best there is (for free, anway). I typically use it to monitor a machine I'm logged into, but with version 2, you can connect a local client piece to a remote server process and monitor that machine from a distance. Even better, you can make this connection very secure so that eavesdroppers can't get intimate details of your machine. If you want to use GKrellM to remotely monitor a server over an ssh tunnel, here's how you do it:
- Download and install the GKrellM daemon on the machine to be monitored. If you have Red Hat 9, you might try the gkrellm-server package at freshrpms.net. (They have version for other Red Hat releases, as well as for Fedora.) You don't need the development stuff, or any of the client or plugin packages.
- Create a gkrellmd user. This is the user account that the gkrellmd process will run under. It shouldn't have a valid login (no home directory, etc).
- Add a line to /etc/rc.d/rc.local which looks like this:
nohup su gkrellmd -c '/bin/nice /usr/bin/gkrellmd -u 3 -m 2 -P 19150 -a 127.0.0.1 -a ip_address >/tmp/gkrellmd.out 2>&1' &
All that says "Ignoring hang-ups and with no output to a tty, run gkrellmd as the gkrellmd user; provide updates every three seconds, allow a maximum of two connections, listen on port 19150, and allow connectsion only from the IP address 127.0.0.1 and ip_address". (You want to change ip_address to match the IP address of the machine that is being monitored, of course.) You should be able to just add that right there at the bottom of rc.local and it'll start very last when the machine reboots. For this first time, however, run that command as root once so that gkrellmd starts. If you get any errors, you want to see them now. And there's no point in rebooting just to start gkrellmd (although if you want to test to make sure that it comes up, now is the time to try it).
- Install GKrellM on the client machine (if it isn't already). The best way is via freshrpms.net. Install all the packages, and make sure to get the various plugin packages, too.
- Once GKrellM is installed, you need to set up a secure tunnel to the server you want to monitor. This will connect a port on your local machine to a port on the remote machine, and the traffic in between them will be encrypted. I like doing this sort of thing in a shell script. Create one (in your home directory or where ever) and add this:
ssh -2 -C -N -f -L 19151:ip_address:19150 ip_address.
That says "Connect to ip_address using the SSH2 protocol, enable compression, don't execute any remote commands, fork into the background after connecting, and forward port 19150 on ip_address to port 19151 on the local machine".
- Now you need to start the GKrellM monitor on the client machine. You start it like so:
gkrellm -f -s 127.0.0.1 -P 19151 &
That says "Start GKrellM and force a host config for this specific server, connecting to port 19151 on host 127.0.0.1, and go into the background".
You can add this to your shell script above if you want to just use it to start the remore GKrellM monitor. If you do that, you might want to embellish it a little to look for PIDs, kill old running monitors, etc.
After you run that, you should see GKrellM start up. It's connected to the remote server via your encrypted tunnel, so it's plenty safe. Right click onthe top part and configure it however you like. By using the '-f' flag, any changes you make to this monitor's configuration won't affect any locally running instances of GKrellM. You can even skin it differently.
It sounds way harder than it is (it should only take about 15 minutes to set all this up), but it's really worth it.
BTW, I borrowed the above pretty heavily from a very nice doc at http://www.stearns.org/doc/network-monitoring.v0.1.1.html. If you wnt to know more, ehad over there. That doc was a little verbose for me, and I wanted everything in one place where I could search for it, hence the entry above. The ssh port forward also needing a little tweaking, and I'm eventually going to add some shell script fixes.