Simple Host Monitoring with SSH
There are many complex host and service monitoring solutions available for Unix systems. But sometimes you just need something very simple to monitor a server or an application on a temporary basis. A basic ping monitor is fine, but it will only tell you if a server is responding on the network. It will not tell you if there is some other problem on the system. The script below relies on passwordless SSH setup to periodically log into the monitored nodes and check on their health by executing a local or remote script.
There are two pre-requisites to make this method work. First, you need to configure passwordless SSH from the monitoring host to the monitored client. Instructions are available here. Second, for notification this script uses “mailx”, so you need sendmail configured on the monitoring host to enable it to send you emails. Test both passwordless SSH and email (example: echo “text” | mailx -s “test email from `hostname`” your.email@domain.com
Save the script below as hostmon.ksh; chmod 755; and run as “nohup /full/path/to/hostmon.ksh /dev/null 2>&1 &”. The script will loop through a list of monitored clients. If a problem is detected, it will send you an email. At this point, the script will stop monitoring this particular client, so you will not receive duplicate emails.
#!/bin/ksh # # Simple remote host monitor using SSH. Requires passwordless SSH setup. # configure() { remotehosts="client1 client2 client3" interval=300 email="your.email@domain.com" } sshmon() { for i in ${remotehosts} do status=1 ssh ${i} "uptime" ; status=$(echo $?) if [ ${status} -ne 0 ] then echo "`date` - Can't communicate with ${i}!" echo "`date` - Can't communicate with ${i}!" | mailx -s "hostmon error on ${i}" "${email}" remotehosts=$(echo "${remotehosts}" | sed "s/${i}//g" | sed 's/ //g') if [ `echo ${remotehosts} | wc -m | awk '{print $1}'` -lt 3 ] then exit fi fi done } configure while [ 1 ] do sshmon sleep ${interval} done
I’m a comp. sci. major. This is my first time remotely accessing stuff I do at school (on Linux computers that have terminals that can run gvim in its own window) on my home computer (Windows using PuTTY to get to my files). Is there a way to get some kind of text editor like gvim to open in its own window?
I get this when doing something like gvim Compress.java
E233: cannot open display
Press ENTER or type command to continue
And pressing enter just loads the file in the terminal window, which I’m not used to editing files in.
If you know how to get a nice visual text editor to open up for me and can explain it in pretty simple terms, I’d be forever grateful :D
any ports and commands would be great
I’m looking at running SSH on my school laptop because pretty much everything useful has been blocked, but I don’t want to run my home internet cap over by doing this. If i use an SSH tunnel to get past the proxy will I use up my home internet cap?
:D
I have a JB iPhone 3G and I want to improve it’s ram memory but in order to follow the tutorials I have to SSH via WiFi. I don’t have Internet at home nether a router. I’m using MyWi for teetering.
I have a jailbroken iPhone 3G. How do I download/get SSH on my iPhone so I can use Cyder and install apps from my computer. I need this because my wifi feature died and doing it from the computer is the only way I have left.