WEB User Experience Monitoring (WUX)
Introduction to WUX with Pandora FMS
WEB User Experience Monitoring (User Experience Monitoring, UX Monitoring or simply WUX in Pandora FMS terminology) is the process of collecting, analyzing, and evaluating data on how users interact with a website or a web application in real time. Its goal is to detect performance, usability, and accessibility issues to improve user experience.
Pandora FMS WUX performs synthetic monitoring (Synthetic Monitoring) using a specialized backend for this purpose (Selenium®). This means that Pandora FMS uses a real browser to interact with remote websites (Google Chrome®, Mozilla Firefox®, etc.).
- It allows detecting problems before real users experience them. It collects navigation data from real users in real time (web scraping).
- It measures metrics such as load time, interactions, errors, and user behavior (web analytics).
- Examples: Measuring page load, response times, screenshots (of the web), testing on different devices, complex application tests that require registration, JavaScript® interaction, text inputs, passing data from one field to another as a user would, mouse clicks, waiting times, etc.
What is the difference between WUX and the other WEB monitoring performed by Pandora FMS with the WEB Server?
The WEB Server uses basic HTTP requests, and although it can simulate sessions, it is not a real browser, so it cannot execute JavaScript or emulate a modern browser. Standard WEB tests are fine for simple WEB tests, WUX is much more powerful.
What different versions of WUX does Pandora FMS have?
- Agent-based WUX (Selenium version 2), up to version 740.
- Centralized WUX on the WUX Server (Selenium 3), up to version 780.
- Centralized WUX as a Discovery PFMS plugin (Selenium 4), from version 780.
In versions prior to 780, WUX ran as part of the Pandora FMS server (WUX Server). Although it is still possible, the setup is more complex than using WUX in centralized mode with Discovery PFMS.
Centralized WUX in Discovery PFMS is also based on Selenium 4 and can be used (optionally) from an agent as a plugin. Transactional files (.side) that worked on a WUX Server will work on WUX Discovery PFMS.
You can find information on how to use WUX Server (Selenium 3) in the technical annex WUX Monitoring.
WUX / Discovery Architecture
The operation of this plugin for Selenium 4 is carried out thanks to the Pandora FMS Discovery server. As mentioned, a dedicated server known as WUX Server was previously used exclusively, and it is also possible to make use of Discovery PFMS for this.
Now it is capable of performing executions using Selenium 4, hence its name, and it is also compatible with Selenium 3 transactions (which might have been previously running in an environment thanks to a WUX Server).
Regarding transaction executions, there are 4 different connection methods with Selenium, which will be seen in more detail below, along with the requirements that must be met to ensure proper operation.
Prerequisites
The main requirement is that the server where the plugin is executed is able to connect to the Selenium 4 stack, and this in turn has communication with the URLs of the websites it will monitor.
This WUX plugin has four different Selenium connection methods to be executed in each transaction, so you will have to adjust the requirements to the desired execution mode for each case.
Local driver
The plugin will use the drivers for Google Chrome or Mozilla Firefox found on the computer where it is executed. By default, these components will be looked for in the following paths, although different paths can be specified if necessary.
Google Chrome binary:
/usr/share/pandora_server/util/selenium_headless_drivers/chrome/google-chrome
Chromedriver:
/usr/share/pandora_server/util/selenium_headless_drivers/chromedriver
Mozilla Firefox binary:
/usr/share/pandora_server/util/selenium_headless_drivers/firefox/firefox
Geckodriver:
/usr/share/pandora_server/util/selenium_headless_drivers/geckodriver
These drivers can be downloaded from the Pandora FMS library and unzipped in the default path or installed online via the PFMS Marketplace.
For browsers to start in this mode, their specific dependencies installed on the system will also be necessary.
- For Mozilla Firefox:
gtk3,alsa-lib,libX11-xcb. - For Google Chrome:
nss,libdrm,mesa-libgbm.
Remote driver
The plugin will connect to a Selenium 4 server indicated by its URL, so it will be necessary to have access from the server running the plugin to the Selenium 4 server through the port it has listening (by default 4444 TCP).
Local Docker
The plugin will start a Docker container on the server where it runs using an image containing the drivers indicated for the local driver mode, allowing abstracting the dependencies of the real equipment.
By default, the image pandorafms/pandora_selenium_headless will be used (although it will be possible to indicate a different one for each execution), and the drivers will be looked for inside Docker in the following paths:
- Google Chrome binary:
/tmp/lib/chrome/google-chrome. - Chromedriver:
/tmp/lib/chromedriver. - Mozilla Firefox binary:
/tmp/lib/firefox/firefox. - Geckodriver:
/tmp/lib/geckodriver.
Remote Docker
The plugin will connect via SSH with a user and password to a remote server, where it will run a copy of the plugin itself (copied at that moment) in local Docker mode. Therefore, along with the requirements of the previous mode, connectivity with the remote server via SSH must also be allowed with the credentials indicated on the indicated port (by default 22 TCP).
The user indicated for the SSH connection must have sufficient permissions to start the Docker container and access the copied files in the temporary directory. A temporary directory will be used to copy the files to the remote server (by default /tmp), although a different path can be indicated in each execution.
Optional requirements
For all execution modes it will be possible, if desired, to make use of Google Chrome or Mozilla Firefox profiles for each transaction. In case of using this feature, it must be ensured that the paths to these profiles are found on the server where the transaction is initiated (whether local or remote).
In Docker execution modes (local, remote), it will be the host server that must have the paths to the profile folders, since the plugin will mount these folders as volumes of the container it starts.
It will also be possible to monitor connection statistics to the main URL of the SIDE indicated in each execution. For this, it will be necessary to have the curl executable installed on the computer where the plugin is launched.
It should be taken into account that if the test execution is performed in remote driver mode, the statistics will not be obtained from the Selenium 4 server, but from the server running the plugin.
Using WUX with Discovery PFMS
Install Discovery PFMS plugin
In order to make use of WUX monitoring with Selenium 4, the .disco must be previously installed in the Discovery section of the Pandora FMS Web Console. This can be done from the Manage disco packages view, selecting the .disco type file to download from the Pandora FMS library for said plugin:
Recording transactions with Selenium IDE
In order to execute these transactions, they must be previously recorded making use of the Selenium IDE extension available for Google Chrome or Mozilla Firefox browsers. After opening the extension, you will be asked to choose whether you want to record in a new project, open an existing one, create a new project, or simply close the extension.
If the first option is chosen, you will be asked to give a name to the project being created and subsequently indicate the base URL address for the recording.
In case of choosing the third option, you will only be asked to indicate the project name, so if you do not have previous recordings, you must also manually indicate the base URL address to start recording.
Once the extension is ready with these previous steps, the next thing to do is click on the REC button located in the upper right part of the screen. A new window will open in the selected browser and load the page indicated in the base URL section. From this moment on, any action carried out on that window will be recorded in the Selenium IDE extension project.
Once all the actions to be monitored later in the transaction execution have been performed, you must click on the Stop recording button (where the REC button was previously located) to stop recording. You will be asked to enter a name for the transaction test. A project in a recording is composed of one or more tests, which will be executed sequentially later, in case there is more than one, when loading it later in Pandora FMS. A new agent will be created for each test in a project.
Subsequently, a view similar to the following will appear:
If desired, there is the possibility of manually adding additional commands, such as phase separators, comments, or wait commands (wait).
In the SIDE file commands section is the complete list of supported commands.
To add them to the current recording, you must right-click on any of the existing commands and click on the Insert new command option:
This will insert an empty command line above the clicked command, which can be edited to add the command manually. It will suffice to enter the desired command in the Command field:
For example, to add a phase start command you must use:
//phase_start:nombre_fase
Compared to previous versions, it will not be necessary to indicate the end of the phase to close it; this will be automatically detected when a new phase_start command appears or, failing that, the transaction ends.
When the recording is finished and the additional commands to be used have been configured, the .side file can be generated, whose content will be what can be used in the plugin execution configuration. To do this, click on the floppy disk icon located in the upper right part of the Selenium IDE window, give the file a name in an easily locatable path, and save it.
Once the .side file has been generated, if you open it you will see that its interior is actually a JSON. This JSON format content is what must be copied and pasted in the Selenium IDE JSON box of the Test setup step of the plugin configuration, which will be seen below.
Transaction execution from Discovery
In order to execute the recordings from the Discovery tool in the Pandora FMS Web Console, a task must be created using Selenium 4 from the Applications menu (Management → Discovery → Applications menu; if it is inactive, you must use the PFSM Marketplace to install it):
A name must be indicated for said task and a group assigned to it. It is possible to add a description and modify other important parameters such as interval time or execution type:
In the next step, the following parameters will appear:
These will allow choosing one of the four available execution modes mentioned above, in addition to indicating in which web browser the transaction will be executed. For compatibility terms, it is recommended that it be the same browser where the transaction was recorded with Selenium IDE.
Once the execution type is indicated, depending on which option has been chosen, different configuration options will appear.
Local Docker
By default, the image to be used is indicated, so nothing needs to be filled in unless you want to use a different image. In case it is necessary to use a specific user's profile in the transaction execution, the user must be indicated. It will also be possible to indicate the path for the browser profiles used.
Remote Docker
The necessary data to connect via SSH to the remote server that will execute the task must be indicated. For connection data, the IP address or FQDN, SSH port, and access credentials fields will be required.
The temporary path will host the necessary files to carry out the execution, and the rest of the fields are the same as in the Local Docker execution.
Local Driver
In this type of execution, the path to the drivers necessary to carry out the execution can be indicated, which can be downloaded from the Pandora FMS library.
Regarding the tokens that can be found at the bottom:
- Virtual display: Used for the execution to use a virtual desktop. If not indicated, the server executing the task is required to have a physical desktop (monitor) connected.
- Headless driver: For the browser used to run in that mode, which is indicated for environments without a desktop.
It is recommended to leave both tokens checked.
Remote Driver
In the fourth available mode, the connection URL with the remote driver must be indicated. The operation of the user and profile parameters is as mentioned previously.
After selecting the connection mode, a final step must be configured before finishing the task configuration.
It is possible to indicate that insecure certificates are accepted and the monitoring of time statistics. There are also other configuration parameters such as the screen resolution at which the transaction will be executed, the global timeout time, and the wait time between recording commands.
Finally, as indicated in the transaction recording step, the JSON content of the .side format must be entered in the last field called Selenium IDE JSON.
After finishing configuring the task, it will be executed automatically after a few seconds, or it will be necessary to force the execution manually, depending on what was indicated in the first step.
When the execution finishes, you can check the summary view, which will indicate the agents that have been created from the task, which one or ones belong to test agents, and how many there are of each type.
Discovery PFMS task results
In the case of the example, the Selenium project has been called Selenium 4 and has two different tests called Test 1 and Test 2. If the Monitor time statistics option is checked during task configuration, an agent will be created with the project name that will house the performance data.
On the other hand, the agents of the recorded transactions will also be created, one for each test. In this case there will be two agents with the names Test 1 and Test 2:
Monitor results
After execution, agents will be created with the data on the transactions and will contain the modules of said transaction execution. The agent with the performance data will also contain the modules for that information and the Monitor time statistics option must be previously enabled in the last step of the task configuration.
The modules added to the test agents are at least the following three:
- Global status: Indicates if the test has been completed successfully or has failed at some point.
- Global time: It is a numeric type module that indicates the seconds it has taken to complete the test.
- Last error screenshot: If the test has failed, a screenshot of what appears in the browser at the moment the failure occurred is stored in this module.
In the description of the Global status and Last error screenshot modules, the text of the error returned by the Selenium engine is indicated.
In case phases have been configured in the transaction, modules indicating the status and time of each phase are created in addition to the previous ones. It is important to know that the Global time does not have to be a sum of the time modules of each phase, since the Global time also includes the times used by the browser to open and close, to name a few examples.
Regarding performance data, they indicate the time in milliseconds it took to perform each of the operations until reaching the site. In this case they would be:
- URL stat DNS: Time for URL DNS resolution.
- URL stat TSSL: Time to establish SSL connection.
- URL stat TST: Time until receiving the first byte.
- URL stat TT: Total transaction time to access the URL.
- URL stat TTC: TCP connection time.
- URL stat TTCP: Time until the connection is ready to transfer data.
- URL status: Monitors if the connection to the URL can be made.
On these modules, as in any other, you can create alerts, reports, and other actions in the rest of the Pandora FMS menus.
There is also a view in the agent dedicated solely to WUX data. It can be found in the tabs at the top right:
In addition to widgets for Dashboards that make specific reference to WUX modules:
The recording shown above is a simple recording. In case the recording has been configured to be divided into different phases, they will also be differentiated in the WUX data view:
And the same with the widgets:
Finally, mention that web data capture (web scraping) can also be performed, which will be described later.
Manual execution (from an agent, as a plugin)
For manual execution, an EndPoint can be configured within the Pandora FMS server itself that hosts the Selenium 4 plugin to perform these executions and generate XML files for each of them, to obtain different agents, and each with its respective modules.
To do this, the Selenium 4 plugin can be configured as an agent plugin using absolute paths, so that the path of the plugin file and the necessary configuration files can be indicated.
The template that can be used to configure the agent plugin using Selenium 4 looks as follows:
module_plugin /var/spool/pandora/data_in/discovery/pandorafms.selenium.4/bin/pandora_selenium -c /ruta/a/fichero/de/configuración -s /ruta/a/fichero/side -t nombre_tarea -i intervalo_agente -g ID_grupo -x
It is important to keep in mind that both the task configuration file and having the .SIDE file loaded on the machine must be manually configured beforehand.
To prepare the configuration file you can go to the “Parameters and configuration” section, where the data template to fill out is located. In the case of the .SIDE file, it will suffice to copy the file itself generated by the Selenium IDE extension.
It is important to apply the -x parameter since it is responsible for generating the execution data in XML format so it can be processed later. In the case of default executions through Discovery, the data format received is JSON:
If desired, it is also possible to execute the plugin from an EndPoint that is not installed on the same server as Pandora FMS. For this it is necessary to locally download on the server hosting the EndPoint the .disco package of the plugin, rename it to modify its format to .zip, and unzip the content to have access to the binary and the rest of the files it may need to work.
As for the necessary configuration, the file must also be created manually, as mentioned above, and the parameters -x must also be used for sending data in XML format and -S to indicate the IP address and port of the Tentacle server that will receive said XML, which is usually the same machine that hosts the Pandora FMS server. The execution would look similar to the following:
module_plugin /ruta/de/fichero/binario/pandora_selenium -c /ruta/a/fichero/de/configuración -s /ruta/a/fichero/side -t nombre_tarea -i intervalo_agente -g ID_grupo -x -S dirección_IP_Tentacle_server:Puerto_Tentacle
It is important to remember that each XML generated with this type of executions would correspond to a different agent, so the modules would not be hosted within the agent where the plugin is running.
Finally, it should be noted that, despite it being possible to perform these types of executions, either manually from the terminal or from the EndPoint, the recommendation is to always carry them out from the Discovery PFMS section, since originally the operation method is designed to work this way, and the task configuration is considerably simpler.
Parameters and configuration
| Short parameter / long parameter | Description |
|---|---|
-v --verbose | Optional. Displays information about the progress of the plugin execution through STDERR. |
-c <task_configuration_file_path> --conf <task_configuration_file_path> | Path to the configuration file of the task to be executed. |
-s <side_file_path> --side <side_file_path> | Path to the SIDE file to be executed. |
-t <task_name> --task <task_name> | Unique task name. It is used to generate temporary elements that do not overwrite those of other tasks that may be running on the same equipment. |
-i <agents_interval> --interval <agents_interval> | Optional. Monitoring interval of the agents generated by the plugin. By default: 300. |
-g <group_id> --group <group_id> | Optional. ID of the group where the agents generated by the plugin are to be created. By default: 0. |
-x --xml_mode | Optional. If indicated, the plugin will generate XML files for the agents instead of doing it through its STDOUT output. |
-S <server:port> --server <server:port> | Optional. For generating agents via XML. IP address and port of the Tentacle server to which to send the XML files. |
-T <temp_folder> --temp <temp_folder> | Optional. For generating agents via XML. Temporary directory for the XML files generated before being sent to the indicated Tentacle server. |
Configuration file (--conf)
{
"worker_mode" : "<local | remote>",
"run_mode" : "<driver | docker>",
"browser" : "<chrome | firefox>",
"driver_url" : "http://<selenium_ip>:<selenium_port>/wd/hub",
"ssh_address" : "<ssh_ip>",
"ssh_port" : "<ssh_port>",
"ssh_user" : "<ssh_user>",
"ssh_password" : "<ssh_password>",
"ssh_password_encrypt" : "<1 | 0>",
"ssh_temp_folder" : "<ssh_temp_folder_path>",
"docker_image": "<docker_image>",
"chromedriver_path": "<chromedriver_path>",
"chrome_binary_path": "<chrome_binary_path>",
"chrome_user_data_dir" : "<chrome_user_data_dir>",
"chrome_profile" : "<chrome_profile>",
"geckodriver_path": "<geckodriver_path>",
"firefox_binary_path": "<firefox_binary_path>",
"firefox_profile" : "<firefox_profile>",
"accept_insecure_certs" : "<1 | 0>",
"monitor_stats" : "<1 | 0>",
"browser_width" : "<width>",
"browser_height" : "<height>",
"global_timeout" : "<seconds>",
"wait_between_commands" : "<seconds>",
"phase_summarize" : "<1 | 0>",
"legacy_data_structure" : "<1 | 0>",
"legacy_data_agent_name" : "<agent_name>",
"legacy_data_agent_group" : "<group_name>"
}
Where each configuration element is:
worker_mode | Indicates whether the transaction will be launched locally or remotely. |
run_mode | Indicates whether the plugin will be executed with drivers or in Docker. |
browser | Indicates the web browser that will be used for the transaction. |
driver_url | Indicates the URL to the Selenium 4 server to execute the transaction. Only in remote/driver mode. |
ssh_address | Indicates the IP address of the server to which it will connect via SSH to execute the plugin. Only in remote/docker mode. |
ssh_port | Optional. Indicates the port number for the SSH connection. By default: 22. Only in remote/docker mode. |
ssh_user | Indicates the user for the SSH connection. Only in remote/docker mode. |
ssh_password | Indicates the password of the ssh_user. Only in remote/docker mode. |
ssh_password_encrypt | Optional. Indicates if the previous password is sent encrypted ( 1) or not (0). Only in remote/docker mode. Passwords can be encrypted by running the plugin from the Pandora FMS Discovery server. |
ssh_temp_folder | Optional. Indicates the path to the temporary directory for the necessary files during execution on the SSH server. By default: /tmp. Only in remote/docker mode. |
docker_image | Optional. Indicates the name of the Docker image to execute the transaction. By default: pandorafms/pandora_selenium_headless. Only in docker mode. |
chromedriver_path | Optional. Indicates the path to the chromedriver binary.1) Only in local/driver mode. |
chrome_binary_path | Optional. Indicates the path to the Google Chrome binary.2) Only in local/driver mode. |
chrome_user_data_dir | Optional. Indicates the path to the data directory ( data dir) of Google Chrome to be used. |
chrome_profile | Optional. Indicates the name of the Google Chrome profile to be used. It must be located inside the data_dir. If not indicated, the browser's default profile will be used. |
geckodriver_path | Indicates the path to the geckodriver binary.3) Only in local/driver mode. |
firefox_binary_path | Indicates the path to the Mozilla Firefox binary.4) Only in local/driver mode. |
firefox_profile | Optional. Indicates the path to the directory of the Mozilla Firefox profile to be used. If not indicated, the browser's default profile will be used. |
accept_insecure_certs | Optional. If indicated with a value of 1, insecure SSL certificates of the URLs accessed during the transaction will be automatically accepted as valid. |
monitor_stats | Optional. If indicated with a value of 1, connection statistics modules to the main URL of the indicated SIDE file will be generated. |
browser_width | Optional. Indicates the web browser width in pixels for the transaction. By default: 1920. |
browser_height | Optional. Indicates the browser height in pixels for the transaction. By default: 1080. |
global_timeout | Optional. Indicates the global timeout in seconds for the tasks performed by the plugin, such as connecting to the Selenium server, starting the browser drivers, etc. It is also the default timeout used for the Selenium commands executed. By default: 5. |
wait_between_commands | Optional. Indicates the time in seconds that the plugin will wait between each SIDE command it executes. This value can be adjusted with the SIDE itself using the setSpeed command. By default: 0. |
phase_summarize | Optional. Sets the Global_Time of the transaction as the sum of the Time modules of all phases. |
legacy_data_structure | Optional. Enables the change of nomenclature of the modules created in the transaction to the one Selenium 3 had. Useful for migrations of Selenium 3 to Selenium 4 tasks and reporting to already existing modules. |
legacy_data_agent_name | Optional. If legacy_data_structure is enabled, name of the agent to which the task will report. |
legacy_data_agent_group | Optional. If legacy_data_structure is enabled, name of the group to which the agent to which the task will report will belong. |
For example:
{
"worker_mode" : "local",
"run_mode" : "driver",
"browser" : "chrome",
"driver_url" : "",
"ssh_address" : "",
"ssh_port" : "",
"ssh_user" : "",
"ssh_password" : "",
"ssh_password_encrypt" : "",
"ssh_temp_folder" : "",
"docker_image": "",
"chromedriver_path": "",
"chrome_binary_path": "",
"chrome_user_data_dir" : "",
"chrome_profile" : "",
"geckodriver_path": "",
"firefox_binary_path": "",
"firefox_profile" : "",
"accept_insecure_certs" : "0",
"monitor_stats" : "1",
"browser_width" : "1920",
"browser_height" : "1080",
"global_timeout" : "10",
"wait_between_commands" : "0.2"
}
.SIDE files commands
The following custom commands can be configured to generate additional modules (all custom commands must start with //):
//phase_start:<phase_name> | Indicates the beginning of a phase, which will last until another //phase_start command is found or until the test ends. This will generate a module with the status of the phase and another module with the time it took to complete. For example: //phase_start:Login |
//getValue;<module_name>;<module_type>;<regexp> | Generates a module with content from the web page which can be obtained through a regular expression of its source code. For example: //getValue;Temperature;generic_data;<span class="temperature">(\d+\.*\,*\d*).*</span> It would obtain the temperature indicated on a web page with this line in its source code: <p> The temperature of the solar panel is: <span class="temperature">54 º C</span></p> |
//getVariable;<module_name>;<module_type>;<variable> | Generates a module with the content of a variable stored in the SIDE with store commands. For example: //getVariable;List count;generic_data;listCount |
//getScreenshot;<module_name> | Generates a module with a screenshot of the browser at that moment. For example: //getScreenshot;URL home |
The SIDE file commands enabled to be executed with the plugin are the following (consult the Selenium IDE documentation for their use):
addSelection | answerOnNextPrompt |
assert | assertAlert |
assertChecked | assertConfirmation |
assertEditable | assertElementPresent |
assertElementNotPresent | assertNotChecked |
assertNotEditable | assertNotSelectedValue |
assertNotText | assertPrompt |
assertSelectedValue | assertSelectedLabel |
assertText | assertTitle |
assertValue | check |
chooseCancelOnNextConfirmation | chooseCancelOnNextPrompt |
chooseOkOnNextConfirmation | click |
clickAt | close |
do | doubleClick |
doubleClickAt | dragAndDropToObject |
editContent | else |
elseIf | executeScript |
executeAsyncScript | forEach |
if | mouseDown |
mouseDownAt | mouseMoveAt |
mouseOut | mouseOver |
mouseUp | mouseUpAt |
open | pause |
removeSelection | run |
runScript | select |
selectFrame | selectWindow |
sendKeys | setSpeed |
setWindowSize | store |
storeAttribute | storeJson |
storeText | storeTitle |
storeValue | storeWindowHandle |
storeXpathCount | submit |
times | type |
uncheck | verify |
verifyChecked | verifyEditable |
verifyElementPresent | verifyElementNotPresent |
verifyNotChecked | verifyNotEditable |
verifyNotSelectedValue | verifyNotText |
verifySelectedLabel | verifySelectedValue |
verifyText | verifyTitle |
verifyValue | waitForElementEditable |
waitForElementNotEditable | waitForElementNotPresent |
waitForElementNotVisible | waitForElementPresent |
waitForElementVisible | waitForText |
webdriverAnswerOnVisiblePrompt | while |
webdriverChooseCancelOnVisibleConfirmation | |
webdriverChooseCancelOnVisiblePrompt | |
webdriverChooseOkOnVisibleConfirmation |
Web Scraping
It is possible to do web scraping with Pandora FMS; although it was designed to measure performance and complex transaction results, it is feasible to do it.
Web scraping is a technique used to extract information from websites in an automated way. Instead of collecting data manually, programs or scripts are used that navigate through web pages, identify relevant information, and store it in a database or structured file.
What is described here can be used both for WUX in Discovery mode (Selenium 4 only) and for WUX in integrated server mode (version 777 or earlier), with Selenium 3.
To do this there are two basic ways to do it, the simplest is to take a value directly from a web page ID (using the inspector itself of the Selenium console extension and passing it to Pandora FMS) or using a regexp to process HTML data in raw. In both cases, an additional command must be entered in the Selenium transaction.
Example, using it as a web scraper to read the number of reviews of an item in the Amazon Store®, using the capture of the value and storing it in a variable:
It will be stored as TEXT type in a variable called REVIEW. And an additional echo command will be created to show the value of that variable:
Here you can see the last two steps in the .side code generated by the Selenium extension:
{
"id": "55546183-fc2f-45b5-af7e-2ff27464798f",
"comment": "",
"command": "storeText",
"target": "css=.a-spacing-medium > .a-size-base",
"targets": [
[
"css=.a-spacing-medium > .a-size-base",
"css:finder"
],
[
"xpath=//div[@id='cm_cr_dp_d_rating_histogram']/div[3]/span",
"xpath:idRelative"
],
[
"xpath=//span/div/div/div/div/div/div[3]/span",
"xpath:position"
]
],
"value": "REVIEW"
}
{
"id": "69cd3cea-5981-4011-bb3d-88a1b58dc18e",
"comment": "",
"command": "echo",
"target": "${REVIEW}",
"targets": [],
"value": ""
}
The disadvantage of this method is that it will be saved as a text string, since when using an ID (in this case a span), everything between the tags of that ID is saved.
If you want to obtain a value in a more “refined” way, you must use the method of parsing with a regular expression to process the text:
- For this case, a number will be taken and converted to a numeric module in Pandora FMS
- As source code of the
.side, the created command will become a code similar to this one. It is important to note how characters like double quotes"or the\character are escaped. - What needs to be done is to determine the piece of HTML code with the text to capture, to do this, analyze with an HTML inspector the code area where the value is to be taken, example:
You look for what is between the tags:
<span id="acrCustomerReviewText" class="a-size-base">''
and
</span>
If a regexp is applied it will be:
<span id="acrCustomerReviewText" class="a-size-base">(\d+) valoraciones</span>
This has to be done by creating a “dummy” command (commented with //) at the end of the Selenium sequence (escaping any character with " or \) and using the getValue command to create a module called AMZ_001, of type generic_data (i.e., numeric) and providing the escaped regexp:
{
"id": "ae557b25-b096-4d6e-baa7-f7219ac16e04",
"comment": "",
"command": [
"//getValue;AMZ_001;generic_data;",
"<span id=\"acrCustomerReviewText\"",
" class=\"a-size-base\">(\\d+) valoraciones</span>"
],
"target": "",
"targets": [],
"value": ""
}
This after execution will return conventional Pandora FMS data, with which you can apply alerts, include in graphs, reports, and many more things.
Since the transaction uses a real browser, you can even make the connection with a specific user and navigate to, finally, obtain the needed data.
WUX Server and Selenium 3
Documentation described in the technical annex “WUX Monitoring with WUX server and Selenium 3”.
/usr/share/pandora_server/util/selenium_headless_drivers/chromedriver./usr/share/pandora_server/util/selenium_headless_drivers/chrome/google-chrome./usr/share/pandora_server/util/selenium_headless_drivers/geckodriver./usr/share/pandora_server/util/selenium_headless_drivers/firefox/firefox.


























