LiveZilla Live Chat Software

Simple Admin Tricks: Quick & Dirty Monitoring

Written by Yves Lacombe on . Posted in Best Practices

From time to time, you’ll need to monitor a port to see if there’s a problem brewing.  For smaller companies, it can be quite a chore to deploy some sort of commercial or open-source monitoring solution (e.g., NAGIOS-based stuff), when all you want to do is do some quick and dirty monitoring. Example: you just want to check if a port is up or down and be alerted immediately so you can troubleshoot without having to go through a complicated configuration process.

Well, there are a ton of command-line tools that let you do just that.

For our example, we need two tools:

portqry.exe:
this is basically a port pinger

Written by Microsoft
Description: http://support.microsoft.com/kb/310099
Download link:http://www.microsoft.com/downloads/details.aspx?familyid=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en

bmail.exe:
this is a simple command line tool to send an email using a batch file

Written by Craig Peacock from Beyond Logic
http://www.beyondlogic.org/solutions/cmdlinemail/cmdlinemail.htm

So, how does this work?

All you need is a simple batch file that you would call from Windows Task Scheduler, e.g. every 5 or 10 minutes:

<ip> = IP or Name of the machine you want to check
<port> = port you want to check

The default timeout is 30 seconds.

@echo off
portqry -n <ip> -e <port> -p TCP -q
if %ERRORLEVEL% == 0 goto allok
:somethingiswrong
bmail -s mail.yourmailrelay.com -p 25 -t 4135551212@phoneprovide.com -f alerter@yourdomain.com -h -a “port is down or saturated”
:allok

And there you go!

Every time the batch file runs, it checks to see if it can reach the port you specify: if it can’t, it’ll send an email through the relay server of your choice and send an alert to your cell phone.

Too easy smile

 

Trackback from your site.

Yves Lacombe

Yves Lacombe

Yves Lacombe has been working on Internet Infrastructure products for over 15 years. He is an Internet Security expert and one of his company's gurus. He has forgotten more things about Email Security than most people will ever know. He runs numerous heavily secured email servers and is constantly getting in trouble while trying to hack into his company's products. Yves has two mottos that he lives by: “The buck stops here” and “Lets just get the job done”.

Leave a comment

Whitepaper Downloads

  • Spam Industry terms
  • Antispam checklists
  • Tips and tricks
  • In depth research analysis

Download

Customer Quote

Vircom's support is Amazing. I called them on Friday evening and was helped until everything was completely installed, tested, and running correctly.

    Steve Arsenault
    Sherman Consulting Services