PERL   41

echoping

Guest on 25th January 2023 02:00:50 AM


  1. #!/usr/bin/perl -w
  2. #
  3. # It is my first (dirty) perl script. GPL2.
  4. # It use echoping to test responce time of servers for http, https, smtp and echo protocols
  5. #  version 0.2
  6. # Please e-mail me optimisations...
  7. # S�bastien Desse : sdesse@euresys.fr
  8. #
  9. # sysntax : echoping.pl <number of tests> <protocol> <URL>
  10. #       number of tests         > 1
  11. #       protocol                = http | ssl | smtp | echo
  12. #       URL                     = @IP | FQDN
  13. #
  14. #
  15. #
  16.  
  17. @ARGV == 3 or die "Syntax : echoping.pl <number of tests> <protocol> <URL>\n";
  18.  
  19.  
  20. if (($ARGV[0] =~ ^\d+$/) ) and ($ARGV[0] > 1) and  ($ARGV[0] < 11)) {
  21.         $NumberOfTests = "-n $ARGV[0]";
  22. } else {
  23.         $NumberOfTests = "-n 5";
  24. }
  25.  
  26. if ($ARGV[1] =~ http/i) ) {
  27.         $Protocol = "-h /"# Need echoping compiled with SSL support
  28. #} elsif ($ARGV[1] =~ m/ssl/i) {
  29. #       $Protocol = "-C -h /";
  30. ;
  31. } elsif ($ARGV[1] =~ smtp/i) ) {
  32.         $Protocol = "-S";
  33. } elsif ($ARGV[1] =~ echo/i) ) {
  34.         $Protocol = "";
  35. } else {
  36.         $Protocol = "-h /";
  37. }      
  38.  
  39. $Url = $ARGV[2];
  40.  
  41. ($Min,$Max,$Average) = (`echoping $NumberOfTests $Protocol $Url` =~ Min.*(\d+\.\d+).*\nMax.*(\d+\.\d+).*\nAverage.*(\d+\.\d+)/););
  42.  
  43. print "$Min $Max $Average

Raw Paste


Login or Register to edit or fork this paste. It's free.

">