# discovery



# Global variables

**Descripción**

Las siguientes variables pueden modificarse de modo global.

<table border="1" id="bkmrk-transfer_mode-modo-d"><tbody><tr><td>**Nombre**</td><td>**Descripción**</td><td>**Valor por defecto**</td></tr><tr><td><div><div>_ERROR_LEVEL</div></div></td><td>Esta variable se utiliza para controlar el nivel de error.</td><td>0</td></tr><tr><td><div><div>_SUMMARY</div></div></td><td>Este diccionario se utiliza para almacenar un sumario de elementos</td><td>{}</td></tr><tr><td><div><div>_INFO</div></div></td><td>Esta variable se utiliza para almacenar posibles errores en la ejecución</td><td>""</td></tr><tr><td><div><div>_MONITORING_DATA</div></div></td><td>Esta lista se utiliza para almacenar elementos</td><td>\[\]</td></tr></tbody></table>

Para modificar las variables globales use la función :

[set\_disco\_error\_level](https://pandorafms.com/guides/public/books/plugintools/page/set-disco-error-level)

[set\_disco\_summary](https://pandorafms.com/guides/public/books/plugintools/page/set-disco-summary)

[set\_disco\_info\_value](https://pandorafms.com/guides/public/books/plugintools/page/set-disco-info-value)

[set\_disco\_monitoring\_data](https://pandorafms.com/guides/public/books/plugintools/page/set-disco-monitoring-data)

**Versión**

- 1.0.0

# set_disco_error_level

**Descripción**

Establece el nivel de error al valor especificado.

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="border-collapse: collapse; width: 100%; height: 58px;"><tbody><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">**Nombre**</td><td style="width: 6.25%; height: 29px;">**Tipo**</td><td style="width: 7.73148%; height: 29px;">**Requerido**</td><td style="width: 48.5185%; height: 29px;">**Descripción**</td></tr><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">value</td><td style="width: 6.25%; height: 29px;">int</td><td style="width: 7.73148%; height: 29px;">Si</td><td style="width: 48.5185%; height: 29px;">El valor del nivel de error. Por defecto es 0</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Set the error level to 1
pt.discovery.set_disco_error_level(1)

# Your code continues here without error level checking
print("Error level has been set to 1. Continue processing...")
```

# set_disco_summary

**Descripción**

Establecer valor fijo en el diccionario '\_SUMMARY'.

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Create a sample data dictionary
sample_data = {
    'total_devices': 50,
    'active_devices': 30,
    'inactive_devices': 20
}

# Set the discovery summary using the sample data
pt.set_disco_summary(sample_data)

# Verify by printing the updated _SUMMARY
print(pt._SUMMARY)
```

# set_disco_summary_value

**Descripción**

Establece un valor fijo para una clave del diccionario '\_SUMMARY'.

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="height: 87px; width: 477px;"><tbody><tr style="height: 29px;"><td style="height: 29px; width: 72px;">**Nombre** </td><td style="height: 29px; width: 45px;">**Tipo**</td><td style="height: 29px; width: 83px;">**Requerido**</td><td style="height: 29px; width: 277px;">**Descripción**</td></tr><tr style="height: 29px;"><td style="height: 29px; width: 72px;">key</td><td style="height: 29px; width: 45px;">str</td><td style="height: 29px; width: 83px;">Si</td><td style="height: 29px; width: 277px;">Clave para la que se establece el valor</td></tr><tr style="height: 29px;"><td style="height: 29px; width: 72px;">value</td><td style="height: 29px; width: 45px;">any</td><td style="height: 29px; width: 83px;">Si</td><td style="height: 29px; width: 277px;">Valor a asignar a la clave</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Set a fixed value for a specific key in the discovery summary
pt.set_disco_summary_value('total_devices', 100)
pt.set_disco_summary_value('active_devices', 75)
pt.set_disco_summary_value('inactive_devices', 25)

# Verify by printing the updated _SUMMARY
print(pt._SUMMARY)
```

# add_disco_summary_value

**Descripción**

Añade un valor a una clave del diccionario 'resumen'.

Si la clave ya existe, se incrementará el valor. En caso contrario, se creará una nueva clave.

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="border-collapse: collapse; width: 100%; height: 87px;"><tbody><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">**Nombre**</td><td style="width: 6.25%; height: 29px;">**Tipo**</td><td style="width: 8.84259%; height: 29px;">**Requerido**</td><td style="width: 47.4074%; height: 29px;">**Descripción**</td></tr><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">key</td><td style="width: 6.25%; height: 29px;">str</td><td style="width: 8.84259%; height: 29px;">SI</td><td style="width: 47.4074%; height: 29px;">Clave a la que añadir el valor</td></tr><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">value</td><td style="width: 6.25%; height: 29px;">None</td><td style="width: 8.84259%; height: 29px;">SI</td><td style="width: 47.4074%; height: 29px;">Valor a añadir a la clave</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Add values to existing keys in the discovery summary
pt.set_disco_summary_value('total_devices', 100)
pt.set_disco_summary_value('active_devices', 75)
pt.set_disco_summary_value('inactive_devices', 25)

# Add values to existing keys using add_disco_summary_value function
pt.add_disco_summary_value('total_devices', 10)
pt.add_disco_summary_value('active_devices', 5)
pt.add_disco_summary_value('inactive_devices', 5)

# Add values to new keys using add_disco_summary_value function
pt.add_disco_summary_value('new_key', 50)

# Verify by printing the updated _SUMMARY
print(pt._SUMMARY)
```

# set_disco_info_value

**Descripción**

Establece un valor fijo en la variable 'info'.

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 12.5%;">**Nombre**</td><td style="width: 6.25%;">**Tipo**</td><td style="width: 9.21296%;">**Requerido**</td><td style="width: 47.037%;">**Descripción**</td></tr><tr><td style="width: 12.5%;">value</td><td style="width: 6.25%;">str</td><td style="width: 9.21296%;">Si</td><td style="width: 47.037%;">El valor a establecer en la variable 'info'. Por defecto es una cadena vacía.</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Set a value to the _INFO variable
pt.set_disco_info_value("This is some information about the discovery.")

# Verify by printing the updated _INFO
print(discovery._INFO)
```

# add_disco_info_value

**Descripción**

Añade datos a la variable 'info'.

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 12.5%;">**Nombre**</td><td style="width: 6.25%;">**Tipo**</td><td style="width: 8.10185%;">**Requerido**</td><td style="width: 48.1481%;">**Descripción**</td></tr><tr><td style="width: 12.5%;">value</td><td style="width: 6.25%;">str</td><td style="width: 8.10185%;">Si</td><td style="width: 48.1481%;">Los datos a añadir a la variable 'info'. Por defecto es una cadena vacía</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Add data to the _INFO variable
pt.add_disco_info_value("Additional information: ")
pt.add_disco_info_value("System status: OK")

# Verify by printing the updated _INFO variable
print(pt._INFO)
```

# set_disco_monitoring_data

**Descripción**

Establecer un valor fijo en los datos de seguimiento

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="border-collapse: collapse; width: 100%; height: 58px;"><tbody><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">**Nombre**</td><td style="width: 6.25%; height: 29px;">**Tipo**</td><td style="width: 9.21296%; height: 29px;">**Requerido**</td><td style="width: 47.037%; height: 29px;">**Descripción**</td></tr><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">data</td><td style="width: 6.25%; height: 29px;">list</td><td style="width: 9.21296%; height: 29px;">Si</td><td style="width: 47.037%; height: 29px;">Lista con los datos</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Example data for disk monitoring
disk_monitoring_data = [
    {'path': '/dev/sda1', 'usage': '75%'},
    {'path': '/dev/sdb1', 'usage': '42%'},
    {'path': '/dev/sdc1', 'usage': '90%'}
]

# Set the monitoring data for disk usage
pt.set_disco_monitoring_data(disk_monitoring_data)

# Verify by printing the updated _MONITORING_DATA variable
print(pt._MONITORING_DATA)
```

# add_disco_monitoring_data

**Descripción**

Añadir valor a los datos de seguimiento

**Parámetros**

<table border="1" id="bkmrk-module-acepta-el-tip" style="border-collapse: collapse; width: 100%; height: 58px;"><tbody><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">**Nombre**</td><td style="width: 6.25%; height: 29px;">**Tipo**</td><td style="width: 9.21296%; height: 29px;">**Requerido**</td><td style="width: 47.037%; height: 29px;">**Descripción**</td></tr><tr style="height: 29px;"><td style="width: 12.5%; height: 29px;">data</td><td style="width: 6.25%; height: 29px;">dict</td><td style="width: 9.21296%; height: 29px;">Si</td><td style="width: 47.037%; height: 29px;">Diccionario con los datos</td></tr></tbody></table>

**Return**

<table border="1" id="bkmrk-tipo-none" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 100%;">**Tipo**</td></tr><tr><td style="width: 100%;">None</td></tr></tbody></table>

**Versión**

- 1.0.0

**Ejemplo**

```
import pandoraPlugintools as pt

# Example data for disk monitoring to be added
new_disk_data = {'path': '/dev/sdd1', 'usage': '60%'}

# Add the new disk monitoring data to the global monitoring dataset
pt.add_disco_monitoring_data(new_disk_data)

# Verify by printing the updated _MONITORING_DATA variable
print(pt._MONITORING_DATA)
```

# disco_output

**Descripción**

Imprime la salida JSON y sale del script.

**Requisitos**

- json
- sys

**Ejemplo**

```
import pandoraPlugintools as pt
import sys  # Don't forget to import the sys module for the sys.exit() function

# Set values for _SUMMARY, _INFO, and _MONITORING_DATA (for demonstration purposes)
pt.set_disco_summary({'disk_usage': '80%'})
pt.set_disco_info_value('Disk usage information')
pt.add_disco_monitoring_data({'path': '/dev/sda1', 'usage': '70%'})

# Call the disco_output function to print JSON output and exit with a specific error level
pt.disco_output()
```