# Marklogic monitoring

# Introducción

<span style="font-weight: 400;">El plugin de Pandora FMS para la monitorización de motores de bases de datos MarkLogic NoSQL, provee el conjunto de módulos necesarios para controlar el estado de los siguientes elementos de la arquitectura de ML:</span>

- <span style="font-weight: 400;">Bosques</span>
- <span style="font-weight: 400;">Bases de datos</span>
- <span style="font-weight: 400;">Servidores (servicios)</span>
- <span style="font-weight: 400;">Hosts</span>

<span style="font-weight: 400;">Se mostrará información de cada uno de los elementos monitorizados, extrayendo esta información de la API Rest provista por defecto por el producto ML.</span>

<span style="font-weight: 400;">Podrá configurar el nivel de detalle que requiera, excluyendo elementos de la monitorización, o habilitando la generación de módulos de información avanzada.</span>

# Matriz de compatibilidad

<span style="font-weight: 400;">Desarrollado bajo LATEST en MarkLogic 9.</span>

<span style="font-weight: 400;">No deberían encontrarse problemas de compatibilidad para ninguna versión del API inferior a esta.</span>

# Prerequisitos

<span style="font-weight: 400;">Se requiere la siguiente información para configurar correctamente el complemento de monitorización MarkLogic:</span>

*<span style="font-weight: 400;">Agente</span>*<span style="font-weight: 400;">: máquina que ejecutará el complemento.</span>

- <span style="font-weight: 400;">Acceso desde el agente al puerto 8002 de uno de los nodos de su instalación de MarkLogic NoSQL.</span>
- <span style="font-weight: 400;">Usuario con permisos de lectura que pueda acceder a la API Rest ubicada en </span>*<span style="font-weight: 400;">/manage/LATEST.</span>*
- <span style="font-weight: 400;">Contraseña del usuario.</span>
- <span style="font-weight: 400;">Nombre del realm de la instalación.</span>
- <span style="font-weight: 400;">Conectividad desde el agente al puerto TCP 41121 de su servidor Pandora FMS.</span>
- <span style="font-weight: 400;">Conectividad TCP desde el agente a los puertos de los Appserver a monitorizar (en caso de monitorizar de puertos).</span>

# Configuración

<span style="font-weight: 400;">Para configurar el plugin se necesita completar los siguientes elementos:</span>

<span style="font-weight: 400;"><span style="font-weight: 600;">Configuración de acceso a la API Rest de MarkLogic</span></span>

<span style="font-weight: 400;">Configure los parámetros necesarios para garantizar que el plugin es capaz de conectar con la API, este bloque de configuración es estrictamente necesario.</span>

*<span style="font-weight: 400;">Ejemplo</span>*<span style="font-weight: 400;">:</span>

```
# MarkLogic NoSQL Server access configuration
ml_server = your.marklogic.server
ml_port = 8002
ml_user = admin
ml_pass = admin
ml_realm = public
use_ssl = 0
```

Configuración de destino de información

<span style="font-weight: 400;">El plugin dispone de dos modos de trabajo.</span>

<span style="font-weight: 400;">Como plugin de agente, enviará a la salida estándar como módulos los mensajes informativos de operaciones realizadas. La información extraída de la API se enviará a su servidor de Pandora utilizando el método configurado en el archivo de configuración.</span>

*<span style="font-weight: 400;">Ejemplo de configuración de métodos de transferencia</span>*<span style="font-weight: 400;">:</span>

```
# Pandora Server configuration
mode = tentacle
tentacle_ip = your.pandora.server
tentacle_port = 41121
tentacle_opts =
tentacle_client = /usr/bin/tentacle_client
local_folder = /var/spool/pandora/data_in
#tentacle_client = "C:\Program Files\pandora_agent\util\tentacle_client.exe"
temp = /tmp
```

<span style="font-weight: 400;">Actualmente, se admiten los siguientes modos de transferencia:</span>

- <span style="font-weight: 400;">Tentacle (envío remoto).</span>
- <span style="font-weight: 400;">Copia local (para trabajo en modo plugin de servidor).</span>

<span style="font-weight: 400;">Como plugin de servidor, los datos extraídos se enviarán en un XML en paralelo, tal y como sucede en el modo plugin de agente, pero en este caso, los mensajes de operación se mostrarán por la salida estándar de error (STDERR) y se retornará un valor numérico identificativo del estado de la ejecución. Este tipo de ejecución se puede lanzar desde el servidor de pandora o el cron de sistema.</span>

**Configuración de los agentes generados**

**Configuración de nombre**

**<span style="font-weight: 400;">La información extraída de la instalación de MarkLogic NoSQL se envía a Pandora FMS </span>**<span style="font-weight: 400;">clasificada como agentes por cada elemento significativo encontrado en el sistema.</span>

- <span style="font-weight: 400;">Bosques</span>
- <span style="font-weight: 400;">Bases de datos</span>
- <span style="font-weight: 400;">Servidores (servicios)</span>
- <span style="font-weight: 400;">Hosts</span>

<span style="font-weight: 400;">Para controlar estos agentes y poder encontrarlos fácilmente en su sistema, se dispone de la posibilidad de configurar el nombre utilizando una </span>**cabecera** <span style="font-weight: 400;">de nombre común.</span>

```
# Agent name personalization
agent_name_header = ML_
```

<span style="font-weight: 400;">Siguiendo este ejemplo, todos los agentes generados por el complemento tendrán el nombre (agent\_name): </span>*<span style="font-weight: 400;">ML\_&lt;tipo de objeto&gt;\_&lt;Nombre&gt;</span>*

<span style="font-weight: 400;">Donde el tipo de objeto sigue el siguiente esquema:</span>

- **F**<span style="font-weight: 400;">:</span> <span style="font-weight: 400;">bosque (forest) </span>
- **DB**<span style="font-weight: 400;">:</span> <span style="font-weight: 400;">base de datos (database) </span>
- **S**<span style="font-weight: 400;">:</span> <span style="font-weight: 400;">servicio/aplicación ML (server) </span>
- **H**<span style="font-weight: 400;">:</span> <span style="font-weight: 400;">servidor (host) </span>

<span style="font-weight: 400;">En el caso de los agentes de tipo Servicio/aplicación (S), es posible configurar el complemento para que los agentes generados indiquen el </span>**tipo de servidor**<span style="font-weight: 400;"> del que se trata en su agent\_name (HTTP, Task, webDAV, XDBC u ODBC):</span>

```
# Show server type (http, task, webDAV, xdbc, or odbc) in the agent name.
show_server_type_in_agentname = 1
```

<span style="font-weight: 400;">Quedando el nombre de agente como: </span>*<span style="font-weight: 400;">ML\_S\_&lt;Nombre&gt; \[&lt;tipo&gt;\]</span>*

**Nota importante:**<span style="font-weight: 400;"> Tenga en cuenta que si se activa esta opción, los agentes de tipo Servicio/aplicación preexistentes dejarán de recibir datos del complemento, y se generarán agentes nuevos con el tipo de servidor incluido en su agent\_name.</span>

**Configuración de grupo**

<span style="font-weight: 400;">Puede personalizar el intervalo del agente y el grupo al que pertenece personalizando la siguiente configuración:</span>

```
# Agent configuration
agent_interval = 300
agent_group = MarkLogic
```

<span style="font-weight: 400;">Puede indicar al complemento que, en caso de no existir, cree el </span>**grupo** <span style="font-weight: 400;">al que se asignarán los agentes. </span>

Nota **importante:** <span style="font-weight: 400;">no utilizar la auto-creación de grupo si su Pandora FMS forma parte de un entorno con metaconsola. La edición o creación de grupos en nodos con metaconsola activa, pueden corromper la integridad de la sincronización de grupos del conjunto total de nodos y metaconsola.</span>

<span style="font-weight: 400;">Si su instalación no tiene metaconsola, puede configurar la auto-creación de grupo configurando los siguientes elementos:</span>

```
# Create Group ~ Pandora FMS Console API
#  DO NOT ENABLE IT IF THERE IS AN ACTIVE METACONSOLE IN YOUR ENVIRONMENT
autocreate_group = 1

# Pandora API configuration
api_url = http://your.pandora.server/pandora_console/include/api.php
api_user = admin
api_user_pass = pandora
api_pass = 1234

# Group definition (global name: agent_group)
group_icon = Servers
```

**Configuración de los módulos**

<span style="font-weight: 400;">Utilizando el fichero de configuración, puede personalizar los siguientes parámetros de los módulos generados por el complemento:</span>

- <span style="font-weight: 400;">Establecer el intervalo de los módulos.</span>
- <span style="font-weight: 400;">Lista de etiquetas (tags) que se agregarán a los módulos.</span>
- <span style="font-weight: 400;">Establecer el grupo de módulo (clasificatorio).</span>
- <span style="font-weight: 400;">Instrucciones para situación crítica.</span>
- <span style="font-weight: 400;">Instrucciones para situación de advertencia.</span>
- <span style="font-weight: 400;">Plantillas de alertas asignadas.</span>

```
# Module configuration
# Module interval
module_interval = 1

# Tags (comma separated)
# Ensure tags exists in your environment
module_tags  = NoSQL

# Module group (default)
module_group =

# Warning instructions
#warning_instructions = Some text to guide team to solve a warning condition

# Critical instructions
#critical_instructions = Some text to guide team to solve a critical condition

# Define as many tokens as templates are needed to be applied
# global_alerts = critical condition
# global_alerts = warning condition

```

**Personalización de la monitorización**

**<span style="font-weight: 400;">Puede controlar los elementos de su infraestructura que van a ser monitorizados:</span>**

```
# Information filter
check_hosts = 1
check_databases = 1
check_forests = 1
check_servers = 1
```

<span style="font-weight: 400;">Además de la monitorización de puerto para los Appserver con el parámetro check\_server\_ports:</span>

```
check_server_ports = 1
```

<span style="font-weight: 400;">Esta opción permite monitorizar la conectividad vía TCP del puerto de servicio de los Appservers, creando un módulo remoto en los agentes que indica su estado operativo.</span>

<span style="font-weight: 400;">Puede también personalizar el nivel de detalle (número de módulos) que genera el complemento habilitando el modo detallado o desactivándolo:</span>

```
# Detailed information (generate extra modules)
show_detailed_hosts = 0
show_detailed_databases = 0
show_detailed_forests = 0
show_detailed_servers = 1
```

**Nota**<span style="font-weight: 400;">: Se recomienda habilitar la información detallada en los módulos de entidades servicio.</span>

<span style="font-weight: 400;">Puede configurar excepciones de los elementos para evitar monitorizar entidades no deseadas:</span>

```
# Databases
# System databases: triggers, modules, security, schema
exlude_databases =

# Forests
# System forests: triggers, modules, security, schema
exlude_forests =

# Servers
exlude_servers =
```

# Ejecución manual

<span style="font-weight: 400;">Para ejecutar el complemento de monitorización del sistema MarkLogic NoSQL, debe ejecutarlo pasando como argumento el fichero de configuración:</span>

```
$ perl pandora_marklogic.pl
Pandora FMS Plugin for MarkLogic NoSQL Monitoring

At least one parameter is needed by this plugin:
Usage: pandora_marklogic.pl pandora_ml.conf
```

<span style="font-weight: 400;">En caso de error podrá consultar los posibles fallos encontrados en la descripción del módulo de mensaje de plugin:</span>

```
$ perl pandora_marklogic.pl pandora_ml.conf
<module>
    <name><![CDATA[Plugin message]]></name>
    <type>generic_proc</type>
    <data><![CDATA[0]]></data>
    <description><![CDATA[ No response from http://your.marklogic.server:8002/manage/LATEST/hosts?format=json
  No response from http://your.marklogic.server:8002/manage/LATEST/databases?format=json
    No response from http://your.marklogic.server:8002/manage/LATEST/forests?format=json
  No response from http://your.marklogic.server:8002/manage/LATEST/servers?format=json
 ]]></description>
    <tags>NoSQL</tags>
</module>
```

<span style="font-weight: 400;">Ejemplo de despliegue a través del CRON de Sistema:</span>

```
# START: Marklogic plugin
*/5 * * * * root perl /usr/share/pandora_server/util/pandora_marklogic.pl /usr/share/pandora_server/util/testing.conf
# END: Marklogic plugin
```

# Módulos generados por el plugin

<span style="font-weight: 400;">A continuación puedes encontrar un resumen de los módulos generados por el plugin por tipo de instancia:</span>

**Hosts**

- <span style="font-weight: 400;">Possible error messages</span>
- <span style="font-weight: 400;">Online (boolean)</span>
- <span style="font-weight: 400;">Total rate</span>
- <span style="font-weight: 400;">Total load</span>
- <span style="font-weight: 400;">Deadlock wait load</span>
- <span style="font-weight: 400;">Journal write rate</span>
- <span style="font-weight: 400;">Secure (boolean)</span>

**Databases**

- <span style="font-weight: 400;">State (boolean)</span>
- <span style="font-weight: 400;">Min capacity</span>
- <span style="font-weight: 400;">Foreign forests lag exceeded</span>
- <span style="font-weight: 400;">Pending lag</span>
- <span style="font-weight: 400;">Total rate</span>
- <span style="font-weight: 400;">Total load</span>
- <span style="font-weight: 400;">Forest count</span>
- <span style="font-weight: 400;">Rebalancing state</span>
- <span style="font-weight: 400;">Forest count</span>

**Forests**

- <span style="font-weight: 400;">State</span>
- <span style="font-weight: 400;">Pending lag</span>
- <span style="font-weight: 400;">Enabled (boolean)</span>
- <span style="font-weight: 400;">Rebalancing state</span>
- <span style="font-weight: 400;">Local disk failover</span>
- <span style="font-weight: 400;">Total rate</span>
- <span style="font-weight: 400;">Total load</span>
- <span style="font-weight: 400;">Query read load</span>
- <span style="font-weight: 400;">Save write load</span>

**Servers (services)**

- <span style="font-weight: 400;">Enabled (boolean)</span>
- <span style="font-weight: 400;">State</span>