Use WebInject/Cygwin For Web Monitoring

Install Cygwin

See this post for details.
In addition
* Install all Perl packages.
* Install “devel/make” and all its dependencies.
* Install “devel/gcc-core” and “devel/gcc-g++” packages.
* Install “openssl” and “openssl-devel” packages.
* Install “mail/ssmtp” package.

ssmtp-config

Install from CPAN

* Install “XML::Simple”

shell> perl -MCPAN -e shell
cpan> install XML::Simple
 
OR
cd .cpan/build/XML-Simple-2.18-ICtnsp
make test
make install

* Install “Crypt::SSLeay”

shell> perl -MCPAN -e shell
cpan> install Crypt::SSLeay
 
OR
cd .cpan/build/Crypt-SSLeay-0.57-MJnTGM
perl Makefile.PL
make test
make install

* Install “Error” pacakge

shell> perl -MCPAN -e shell
cpan> install Error
 
* Create a new ParserDetails.ini file in the /usr/lib/perl5/vendor_perl/5.10/XML/SAX directory
<pre>
[XML::SAX::PurePerl]
http://xml.org/sax/features/namespaces = 1
 
[XML::LibXML::SAX::Parser]
http://xml.org/sax/features/namespaces = 1
 
[XML::LibXML::SAX]
http://xml.org/sax/features/namespaces = 1

Install WebInject

* Download WebInject from its download page. I downloaded the source version webinject-1.41.src.tar.gz.
* Unzip webinject-1.41.src.tar.gz into a local directory.

Run WebInject

./webinject.pl

Configure External Email Module

* Create an external email module named “Plugin.pm”:

 
if ($casefailedcount > 0) {
open(MAIL, '| /usr/sbin/ssmtp.exe me\@my.com') or "die";
print MAIL <<EOF;
To:me\@my.com
From:me\@my.com
Subject:Passed: $casepassedcount,  Failed: $casefailedcount
 
Start Time: $currentdatetime \n
Total Run Time: $totalruntime seconds \n
\n
Test Cases Run: $totalruncount \n
Test Cases Passed: $casepassedcount \n
Test Cases Failed: $casefailedcount \n
Verifications Passed: $passedcount \n
Verifications Failed: $failedcount \n
\n
Average Response Time: $avgresponse seconds \n
Max Response Time: $maxresponse seconds \n
Min Response Time: $minresponse seconds \n
EOF
}
 
1;

* Add to config.xml:

<reporttype>external:/path/to/Plugin.pm</reporttype>

Setup as cron job

* Setup Cygwin cron service as described in this post
* Setup crontab for webinject to run every 30 min:

crontab -e
*/30 * * * * /cygdrive/c/webinject/webinject.pl
This entry was posted in cygwin, perl. Bookmark the permalink.