Execution of scripts
WOCU-Monitoring offers the possibility to execute scripts previously loaded into the system by an administrator.
Loading scripts
The scripts should be left in the following directory:
/opt/wocu/embedded/wocu/script_launcher/scripts/
Once copied, execution permissions must be granted (if they do not already exist).
The following conditions must be met for the correct execution of the scripts:
The script name must not contain spaces.
They must not write to intermediate or final files during execution.
They shall manage internally the arrival or absence of parameters.
They must take into account possible blockages and, if they occur, manage them appropriately to avoid timeouts.
Automatic parameter collection
In order for the system to add the parameters automatically, you need to include as many lines as you want.
Each of them must begin with the prefix ##autoload__parameter
followed by the variable name.
Here are some examples of defining parameters within a script:
Parameter host_name
##__autoload__parameter__host_name
Parameter service name
##__autoload__parameter__service name
Parameter Stop Condition
##__autoload__parameter__Stop Condition
As can be seen, parameter names may contain spaces.
Example
In the following script, two input parameters are defined that will later be displayed in the form that will allow its execution.
#!/bin/bash
##__autoload__parameter__host1
##__autoload__parameter__host2
##__autoload__parameter__Stop Condition
# Nota: El tercer parámetro no se usa en el script
host1=$1
host2=$2
echo "Primero el parámetro host1: ${host1}"
ping -c1 ${host1}
echo "Después el parámetro host2 ${host2}"
ping -c1 ${host2}
Execution of a script
The functionality is prepared to load, update and remove scripts automatically. Each time the Advanced Diagnosis window is accessed, the reload process is carried out, warning the system of possible changes.
This process is transparent and does not require manual actions:
First, access Advanced Diagnosis, which can be found under the Settings drop-down menu.
![]()
Once there, a drop-down will be displayed with the list of scripts loaded in the system.
![]()
After selecting a script from the list, as many fields will appear as parameters have been defined using the method shown above.
![]()
Additionally, a file selector will appear that allows the upload of a parameter file, in CSV format.
At this point, there are two possible ways of executing the script, each of which has implications for the outcome.
Execution with manually specified parameters
This type of execution refers to the one that receives the necessary parameters for the script based on the information entered by the administrator in the fields of the Parameters section.
The output displayed includes all the information generated during the execution, including the main messages, possible errors and an indicator reflecting the final result of the process.
Execution with file-loaded parameters
In this use case, the administrator is expected to upload a CSV file with headers.
The file must contain as many columns as the number of parameters supported by the script and each row will represent one execution of the script with that set of parameters.
The return in this type of execution is a text file with extension txt
. In this file you will find an entry for each run carried out, i.e. for each row of the CSV file, not counting the headers.
Example
JSON
// Execution date: 2025-03-14 12:29:13
{
"1": {
"parameters": [
"www.example.es",
"www.example.com",
"42"
],
"output": [
"Primero el parámetro host1: www.example.es",
"PING www.example.es (185.53.177.53) 56(84) bytes of data.",
"64 bytes from 185.53.177.53 (185.53.177.53): icmp_seq=1 ttl=48 time=45.9 ms",
"",
"--- www.example.es ping statistics ---",
"1 packets transmitted, 1 received, 0% packet loss, time 0ms",
"rtt min/avg/max/mdev = 45.860/45.860/45.860/0.000 ms",
"Después el parámetro host2 www.example.com",
"PING a1422.dscr.akamai.net (2.22.146.153) 56(84) bytes of data.",
"64 bytes from a2-22-146-153.deploy.static.akamaitechnologies.com (2.22.146.153): icmp_seq=1 ttl=55 time=13.8 ms",
"",
"--- a1422.dscr.akamai.net ping statistics ---",
"1 packets transmitted, 1 received, 0% packet loss, time 0ms",
"rtt min/avg/max/mdev = 13.836/13.836/13.836/0.000 ms",
""
],
"errors": [
""
],
"return_code": 0
},
"2": {
"parameters": [
"8.8.8.8",
"8.8.4.4",
"41"
],
"output": [
"Primero el parámetro host1: 8.8.8.8",
"PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.",
"64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=14.5 ms",
"",
"--- 8.8.8.8 ping statistics ---",
"1 packets transmitted, 1 received, 0% packet loss, time 0ms",
"rtt min/avg/max/mdev = 14.501/14.501/14.501/0.000 ms",
"Después el parámetro host2 8.8.4.4",
"PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.",
"64 bytes from 8.8.4.4: icmp_seq=1 ttl=117 time=13.3 ms",
"",
"--- 8.8.4.4 ping statistics ---",
"1 packets transmitted, 1 received, 0% packet loss, time 0ms",
"rtt min/avg/max/mdev = 13.283/13.283/13.283/0.000 ms",
""
],
"errors": [
""
],
"return_code": 0
}
}