Developers Club geek daily blog

1 year, 1 month ago
Today there is a set of applications and program complexes from different developers which we use for a solution of the general tasks. Data exchange and interaction between applications provide web services. For testing of their work, interaction debugging among themselves and client applications the set of tools is also released. The most popular of them – SoapUI: it supports SOAP/WSDL, REST, HTTP(S), JDBS, JMS and possesses a tool kit which allow to make testing simpler and more evident. SoapUI acts as test service and the test client and allows to test integration of subsystems. It is possible to get acquainted with the tool on the official site of the developer in more detail.

Zabbix + SoapUI = monitoring of web services

If for a solution of an objective one computer and a complex of applications is used, breakdown of the PC or failure of one of programs comes to light quickly. But what to do when in the organization there are a lot of technical means and software products? Physically difficult and very costly to monitor and each free minute to check, whether all as it should be. For a solution of this task specialized program systems which you will find much in the Internet come to the rescue: one of them – Zabbix.

This program complex is intended for tracking of different parameters of a network and operability of technical means. If any element of monitoring breaks, Zabbix will be able to notify interested persons through e-mail and the SMS. In more detail about Zabbix it is possible to read also on the official site of the developer.

Let's provide a situation. In the company many technical means which are monitored by Zabbix, and different applications not of own development, but other IT companies are used. The part or all these solutions are connected with each other and solve one problem. To provide timely identification of failures in this set of elements and to quickly find the place of emergence of a problem, we need to configure monitoring of web services.
What options are?

The first option — using functionality of Zabbix, to configure web monitoring

This guide not how to work with Zabbix therefore I will describe steps briefly.

We create the scenario.
Setup – Web to Create the scenario.

Zabbix + SoapUI = monitoring of web services

On the Scenario tab surely we fill the Group of Data Items and Name field (scenario).

Zabbix + SoapUI = monitoring of web services

We go to the Steps tab, we add a scenario step. We fill fields: name of a step, URL, response code.

We enter the address of the necessary web service in "URL": http://Host:port/Service_name.

We enter in "Response code" "200 OK ("well"). The list of all status codes of HTTP can be found here

Zabbix + SoapUI = monitoring of web services

Further we configure the trigger on the created scenario.

Zabbix + SoapUI = monitoring of web services

We fill obligatory fields: a name of the trigger and expression – as shown in drawing below.

Zabbix + SoapUI = monitoring of web services

What did we receive as a result? Created a web monitoring element – "Test" which polls the page to the address specified in the scenario, and the trigger which will work as soon as the web service is unavailable (i.e. the element of monitoring "Test" will receive a code, excellent from "200").

It will be enough if nothing is required except how to make sure that the web service is available. But, if it is necessary to trace not only availability, but also a work correctness, then such method will not approach.

The second option — to make friends" Zabbix and SoapUI

At once I will specify: The Zabbix-server is deployed by the machine under control of Linux.

We recognize from the fact that SoapUI is already set by the machine where the Zabbix-server turns. For an example we will take certain Soap web service with the only getScore method which at the request of the client returns a certain data structure: sections with the name of fields and sections with data.

Zabbix + SoapUI = monitoring of web services

To understand that the web service works correctly, it is necessary to set criteria:
A) the method returns the correct answer;
B) the method returns correct structure of fields in section of fields;
C) the method returns not an empty data set (sections of data are filled);
D) number of fields are equal in sections of fields and data;

The first that needs to be made – to create the test which we are going to check a correctness of work of web service. SoapUI allows to create test cases for full testing of web services.

Zabbix + SoapUI = monitoring of web services

Apparently on a screenshot above, checks by criteria And yes B are implemented by regular means of SoapUI. For implementation of checks by criteria of B and it is necessary "to practise shamanism" with the SoapUI "Groovy Scripts" element.

Zabbix + SoapUI = monitoring of web services

def groovyUtils = new context );
def holder = groovyUtils.getXmlHolder("#Response");
holder.declareNamespace("scor","") ;
holder.declareNamespace("rem","") ;

def columnNamesNode = holder.getDomNodes("//scor:columnNames/scor:name");
def rowValuesNode = holder.getDomNodes("//scor:rowValues");
def ValuesNode = holder.getDomNodes("//rem:getScoreResponse[1]/scor:scoreResult[1]/scor:rowValues[1]/scor:value");

int countNames = columnNamesNode.size();
int countRowValues = rowValuesNode.size();
int countValues = ValuesNode.size();

assert   countRowValues>0 : log.error("The Node with name \"rowValues\" is not found in the Response");
assert   countNames==countValues : log.error ("The count of elements of the node \"columnNames\" doesn't coincide with count of  elements  of the node \"rowValues\"!");

So, the test case for check of a correctness of work of web service is ready. It was necessary to force Zabbix and SoapUI to work in a sheaf.

The SoapUI tests can be started from the console. Why not to use this opportunity?

Listing of a script for monitoring of different services is included below.

## путь к SoapUIPro
## путь к папке Zabbix
## путь, где хранятся проекты SoapUI для тестирования веб-служб                      

## путь к папке, где будут лежать отчеты тестирования веб-служб

## Путь к папке хранения отчетов с разбиением по хостам. Чтобы не перепутать, где лежат отчеты в случае, если одна и та же служба развернута на нескольких хостах

## чтобы не создавать каждый раз необходимую структуру папок при включении в мониторинг новой веб-службы, создаем структуру папок и выдаем им необходимые права доступа.

if [ -d "$pathParentReportDir" ];
    chmod 666 "$pathParentReportDir"
mkdir "$pathParentReportDir"
chmod 666 "$pathParentReportDir"	
if [ -d "$pathReportsDirectory" ];
    chmod 666 "$pathReportsDirectory"
mkdir "$pathReportsDirectory"
chmod 666 "$pathReportsDirectory"	

## путь к файлу, в который SoapUI записывает все сценарии, которые не прошли проверки. Он пригодится чуть позднее

## host:port/service_name

## Путь к папке, где лежит источник тестовых данных (файл Excel), если необходимо

## имя листа в файле-источнике Excel

## наименование тестового набора в проекте

## наименование тестового сценария в проекте

## В зависимости от того, какие параметры были указаны при вызове скрипта, формируем команду запуска тестов SoapUI
commandString="sh $pathSoapUIDirectory/ -e $endPoint -s $testSuiteName" 
if [ -n "$testCaseName" ] 
commandString=${commandString}" -c $testCaseName"
commandString=${commandString}" -r -j -f $pathReportsDirectory"
if [ -n "$pathTestdataDirectory" ]
commandString=${commandString}" -P pathTestData=$pathTestdataDirectory -P varSpace=$workSpaceName"
commandString=${commandString}" -I $pathSoapUiProjectWithName"
$commandString > $pathReportsDirectory/"$1RunLogs.txt"

## Проверка  результатов запуска тестов SoapUI
###For Debug###
#errorString="### ErrorCode: 1 - error of start of the project, 2 - Error of assertions of the tests, 0 - All ok. The returned code:"
#echo "$errorString "$? >> /tmp/"$1RunLogs.txt"
if [ $? -ne 0 ];
echo "ErrorOfRunProject"  ### По какой либо причине SoapUI не смог выполнить тесты
    if [ ! -f "$searchfile" ]
        echo "FileNotFound"

if grep -w "Failure" "$searchfile" > /dev/null; then
echo "TestFailure" ### Tests error
echo "OK" ### All Ok

This script needs to be placed in folder/externalscripts that "Zabbix" saw it since, by default, external scripts have to lie in this folder. In our case the script of "" has to lie in "/etc/zabbix/externalscripts". It is necessary to issue to a script of right of access on start:

sudo chmod 755 /etc/zabbix/externalscripts/

It was necessary to configure Zabbix for work with this script. For this purpose it is necessary to create a data item with the External Check type.

Zabbix + SoapUI = monitoring of web services

As the script returns text values, it is necessary to specify in "Information type" – "Text".
"Key" looks so:["{HOSTNAME}","ScoringProcessTests","{$SCORING.ENDPOINT}","getScoreTestSuite","getScoreTestCase"]

"" — our script;
"{HOSTNAME}" — host name on which will deploy the service for separation of reports of one services on different hosts;
"ScoringProcessTests" — the name of the SoapUI project for testing of web service;
"{$ENDPOINT}" — URL of web service;
"getScoreTestSuite" — the name of a test set of scenarios in the SoapUI project;
"getScoreTestCase" — the name of a test case in the SoapUI project;

That Zabbix informed on the found failure of web service, it is necessary to configure the trigger.

Zabbix + SoapUI = monitoring of web services

The trigger will work if the data item receives the value other than OK, and "Zabbix" will display the fact of detection of failure in the interface and will notify interested persons by mail, the SMS or in a different way. The method of the notification depends on needs of users.

Thus, Zabbix and SoapUI everyone separately free of charge provide huge feature set. Separately or partially, these products cannot solve problems which it on force in a tandem. How still to implement this sheaf, everyone can think up.

This article is a translation of the original post at
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here:

We believe that the knowledge, which is available at the most popular Russian IT blog, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.
Best wishes.

comments powered by Disqus