NetAdminTools.com
 
SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler
Categories:
GNU/Linux | Homebrew designs | Perl | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS | Hail Support


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·REALbasic
·All Categories


Troubleshooting Slowness/Lockups Over a WAN or VPN
Topic: Monitoring   Posted:2005-05-11
Printer Friendly: Print

spacer
One problem with network monitoring is that latency and router performance do not tell the whole story. What you really want to know is if you can transfer data at the application level across the WAN/VPN. This is particularly useful if you are skimping on your connection to your remote offices by using DSL or cable modems. The service levels vary significantly, and it is difficult to track down sporadic slowdowns/lockups without some good data. One way to do this is to simply transfer a file via HTTP every 15 seconds and measure the time it takes. We created a simple perl script that outputs a web page that shows how much time it took for a transfer of a 1000 byte file. Colors vary based on the time, and red XXXs are printed if the time is more than a second. First, we need to create a 1000 byte file and put it on the server we want to test the transfer. We just went in to vi, inserted a character, hit escape and then entered "1000.". Well, 1002 bytes including EOF, but close enough:

[root@srv-2 html]# ls -l /var/www/html/test.html
-rw-r--r--    1 root     root         1002 May 27 00:57 test.html
[root@srv-2 html]#

To monitor the server, we just run the script:

[root@srv-1 httptest]# ./ht.pl

The output of the web page looks like this:



In this case the server was rebooted, and you can see the error. Note that you could easily test for lack of a timestamp if you wanted, and this would show that the web server was down, but that isn't really the purpose of the script. Normally the web server stays up, or at least, there are better tools to monitor the server that you are probably already using. Here is the script:

#!/usr/bin/perl
open (HTTPTESTOUT, "> /var/www/html/ht.html");
print HTTPTESTOUT "<html><head><title>HTTP Tester</title></head><body>\n";
close HTTPTESTOUT;
($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
$currday=$mday;
while (6 ne 9){ #i don't mind
($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
if ($currday ne $mday){
$currday=$mday;
open (HTTPTESTOUT, "> /var/www/html/ht.html");
print HTTPTESTOUT "<html><head><title>HTTP Tester</title>
</head><body>\n";
close HTTPTESTOUT;
}
open (HTTPTESTOUT, ">> /var/www/html/ht.html");
$starttime=time;
system("/usr/bin/wget -nv -o /root/httptest/ht.txt -O \\
/root/httptest/htp.html http://10.50.100.52/test.html ");
($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
printf HTTPTESTOUT "%4d-%02d-%02d ",
$year+1900,$mon+1,$mday;
open (HTTPTEST, "< /root/httptest/ht.txt");
while (<HTTPTEST>) {
s/(\d\d:\d\d:\d\d)//g;
print HTTPTESTOUT $1;
}
close HTTPTEST;
$endtime=time;
$difftime=$endtime-$starttime;
if ($difftime > 1){
print HTTPTESTOUT "<font color=red>XXXXXXXXX ";
}
elsif ($difftime > 0){
print HTTPTESTOUT "<font color=blue>";
}
else {
print HTTPTESTOUT "<font color=black>";
}
print HTTPTESTOUT " - ".$difftime."</font><br />";
close HTTPTESTOUT;
sleep 15;
}

The HTML really isn't proper, because we never close the tags. It works fine, though. The idea is that we create the HTML header and then tack on the results to the end of the file. We also truncate the file by seeing if mday changes. The app runs in a loop forever, well, until 6 equals 9. We use the -o option on wget to send the results to a file:

 
[root@srv-1 httptest]# cat ht.txt
05:01:47 URL:http://10.50.100.52/test.html [1,002/1,002] -> 
"/root/httptest/htp.html" [1]





Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com

Created by:
MCJ
MCJ CMS