# SAP HANA Database # Introducción **Ver**. 28-06-2022 Plugin para monitorizar una base de datos de SAP Hana , mediante consultas personalizadas.
**Tipo**: Plug-in de servidor
# Matriz de compatibilidad
**Sistemas donde se ha probado**CentOS 7
**Sistemas donde debería funcionar**Cualquier sistema linux
**Versión de SAP donde se ha probado**2.00.059
**Sistemas donde debería funcionar**Cualquier versión
# Pre requisitos - Tener el **Data Server** de Pandora FMS habilitado - Tener el **Plugin Server** de Pandora FMS habilitado # Parámetros
**Parámetro****Descripción**
--ipIP o host de la base de datos(obligatorio)
--userNombre del user de SAP Hana(obligatorio)
--passwordPassword de SAP Hana (obligatorio)
--portPuerto de la base de datos. Para las bases de datos tenant HANA, utilice el número de puerto 3\*\*NN\*\*13 (donde NN es el número de instancia SAP, por ejemplo, 30013). Para las bases de datos del sistema HANA en un sistema multitenant, el número de puerto es 3\*\*NN\*\*13. Para las bases de datos del sistema HANA en single-tenant, el número de puerto es 3\*\*NN\*\*15.
--tentacle\_portPuerto de tentacle.Por defecto 41121 (opcional)
--tentacle\_addressIp del servidor tentacle al que mandar los datos (opcional)
--agent\_namePara ponerle un nombre al agente que contendrá los módulos de las custom querys, por defecto : "Sap\_Hana" (opcional).
--prefix\_modulePara ponerle un prefijo a los módulos por si se quieren diferenciar de otras ejecuciones.(opcional)
--confPath del archivo conf con las querys (obligatorio)
-g,--groupGrupo de destino de Pandora FMS (opcional)
--data\_dirDirectorio de datos de Pandora FMS. **Por defecto** es /var/spool/pandora/data\_in/ (opcional)
--as\_agent\_pluginEs opcional, si quieres que el plugin sea de agente y te meta los módulos en el agente de pandora, ejecuta esto con un 1 (opcional)
**Pandora\_hana.conf** En este archivo se introducirán las consultas SQL personalizadas que se ejecutaran en la base de datos SAP Hana que crearán módulos en PandoraFMS. El formato para añadir las querys es el siguiente: ``` nombre_modulo:query:tipo:descripción ``` **\* La descripción no es obligatoria, si no se introduce se quedará vacía.** Ejemplo: ``` Backups_Size:SELECT SUM(allocated_page_size) FROM M_CONVERTER_STATISTICS;:generic_data:Estimated backup size Timestamp:SELECT CURRENT_TIMESTAMP FROM DUMMY;:generic_data_string:Current timestamp Hana_version:SELECT VERSION FROM M_DATABASE;:generic_data_string:version Data_disk_information:SELECT HOST,PORT,FILE_NAME,STATE,SIZE,MAX_SIZE FROM M_DATA_VOLUMES:generic_data_string:Retrieve Hana disk info Hana_service_statics:SELECT SERVICE_NAME, DATABASE_NAME, REQUESTS_PER_SEC, RESPONSE_TIME FROM SYS_DATABASES.M_SERVICE_STATISTICS:generic_data_string:Retrieve Hana Requests per second Hana_cpu_time:SELECT HOST,PORT,SERVICE_NAME, SUM(CPU_TIME_SELF),SUM(CPU_TIME_CUMULATIVE) FROM M_SERVICE_THREADS GROUP BY HOST,PORT,SERVICE_NAME:generic_data_string:Retrieve Hana cpu usage Hana_rs_fragmentation:SELECT HOST, PORT, TO_DECIMAL(SUM(FREE_SIZE) * 100 / SUM(ALLOCATED_SIZE),10,2), TO_DECIMAL( SUM(FREE_SIZE)/(1024*1024), 10, 2), TO_DECIMAL( SUM(ALLOCATED_SIZE)/(1024*1024), 10, 2) FROM M_RS_MEMORY WHERE CATEGORY = 'TABLE' OR CATEGORY = 'CATALOG' GROUP BY HOST, PORT:generic_data_string:Retrieve Hana row store fragmentation Hana_license:SELECT VALID, PERMANENT, PRODUCT_LIMIT, PRODUCT_USAGE FROM M_LICENSE;:generic_data_string:Retrieve license usage Hana_IO_Stats:SELECT HOST,PORT,TYPE, TO_DECIMAL((TOTAL_READ_SIZE * 1.048576 / (TOTAL_READ_TIME+1)),10,2), TO_DECIMAL((TOTAL_WRITE_SIZE * 1.048576 / (TOTAL_WRITE_TIME+1)),10,2) FROM M_VOLUME_IO_TOTAL_STATISTICS:generic_data_string:Retrieve IO bandwidth Hana_get_stated_connections:SELECT COUNT(*) FROM PUBLIC.M_CONNECTIONS WHERE CONNECTION_STATUS ='RUNNING':generic_data:retrieve connection status Hana_Memory:SELECT HOST, round ( 100 * INSTANCE_TOTAL_MEMORY_USED_SIZE / INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE, 2), round (INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE / 1024/1024/1024, 2), round (INSTANCE_TOTAL_MEMORY_USED_SIZE / 1024/1024/1024, 2) from M_HOST_RESOURCE_UTILIZATION:generic_data_string:retrieve memory usages Hana_Transactions:SELECT count(*) FROM M_BLOCKED_TRANSACTIONS;:generic_data:retrieve SAP transaction status Check_norunning_backups:select * from SYS.M_BACKUP_CATALOG where STATE_NAME = 'running':generic_data_string:Check to make sure there are no running backups still Backup_id_running_backup:select BACKUP_ID from SYS.M_BACKUP_CATALOG where entry_type_name = 'complete data backup' and state_name = 'running' order by sys_start_time desc:generic_data_string:Query to find BACKUP_ID of running data backup ``` # Ejecución manual Con una ejecución con "as\_agent\_plugin" en 1 podremos ver el xml por terminal. ``` ./pandora_hana --ip --port --user --password --conf --as_agent_plugin 1 ``` [![image-1656435359935.PNG](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656435359935.PNG)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656435359935.PNG) Sin el parámetro "as\_agent\_plugin" se nos mostrará un 1 que indicará la correcta ejecución del plugin: ``` ./pandora_hana --ip --port --user --password --conf --data_dir ``` [![image-1656435538204.PNG](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656435538204.PNG)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656435538204.PNG) # Configuración en PandoraFMS **Instalación manual** Iremos a servidores > plugins: [![image-1629974405286.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/scaled-1680-/image-1629974405286.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/image-1629974405286.png) Pinchamos en añadir: [![image-1629974430627.png](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/scaled-1680-/image-1629974430627.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2021-08/image-1629974430627.png) Le ponemos en nombre y la descripción que se prefiera: [![image-1656437269121.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656437269121.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656437269121.png) Metemos como comando la ejecución con la ruta del plugin: ``` /path_pandora_hana ```

Recuerda que la ruta recomendada para el uso de los plugins de servidor es: /usr/share/pandora\_server/util/plugin/

[![image-1656437381803.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656437381803.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656437381803.png) Y en parámetros del plugin introduciremos estos seguidos de la macro "\_field<N>\_", los obligatorios para que el plugin funcione son --ip,--port,--user,--password y --conf.

Aunque no es obligatorio, es muy recomendable el uso del parámetro --agent\_name , ya que nos permite personalizar el nombre del agente que contendrá los módulos creados para cada consulta personalizada. También es recomendable usar el parámetro --prefix\_module ya que este nos permitirá asignar un prefijo a los módulos, lo que puede ser util para reconocerlos más rápido y diferenciarlos si creamos varias ejecuciones para bases de datos diferentes.

**--IP** [![image-1656437985204.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656437985204.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656437985204.png) **--PORT** [![image-1656438071776.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438071776.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438071776.png) **--USER** [![image-1656438378630.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438378630.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438378630.png) **--PASSWORD** [![image-1656438434646.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438434646.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438434646.png) **--CONF** [![image-1656438528074.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438528074.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438528074.png) **--AGENT\_NAME** [![image-1656438571290.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438571290.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438571290.png) Una vez hecho esto, daremos a "crear". Una vez hecho esto, solo queda llamarlo por lo que iremos a la vista de algún agente y crearemos un módulo de complementos: [![image-1646741530197.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-03/scaled-1680-/image-1646741530197.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-03/image-1646741530197.png) Le daremos un nombre y en el apartado "plugin" pondremos el que acabamos de configurar. [![image-1656438657656.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438657656.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438657656.png) Una vez hecho esto, damos a crear. Si el modulo se muestra con 1, quiere decir que se esta ejecutando correctamente [![image-1656438714123.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656438714123.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656438714123.png) # Módulos generados por el plugin El plugin creará un agente con el nombre que le hayamos puesto con el parámetro "--agent\_name" si no se usa este parámetro se quedara con "Sap Hana" por defecto: [![image-1656435971981.png](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/scaled-1680-/image-1656435971981.png)](https://pandorafms.com/guides/public/uploads/images/gallery/2022-06/image-1656435971981.png) En este agente se crearán un módulo por cada consulta personalizada especificada en pandora\_hana.conf, con el nombre que le hayamos asignado a cada modulo en cada una de las consultas personalizadas. Por ejemplo el siguiente conf: ``` Backups_Size:SELECT SUM(allocated_page_size) FROM M_CONVERTER_STATISTICS;:generic_data:Estimated backup size Timestamp:SELECT CURRENT_TIMESTAMP FROM DUMMY;:generic_data_string:Current timestamp Hana_version:SELECT VERSION FROM M_DATABASE;:generic_data_string:version Data_disk_information:SELECT HOST,PORT,FILE_NAME,STATE,SIZE,MAX_SIZE FROM M_DATA_VOLUMES:generic_data_string:Retrieve Hana disk info Hana_service_statics:SELECT SERVICE_NAME, DATABASE_NAME, REQUESTS_PER_SEC, RESPONSE_TIME FROM SYS_DATABASES.M_SERVICE_STATISTICS:generic_data_string:Retrieve Hana Requests per second Hana_cpu_time:SELECT HOST,PORT,SERVICE_NAME, SUM(CPU_TIME_SELF),SUM(CPU_TIME_CUMULATIVE) FROM M_SERVICE_THREADS GROUP BY HOST,PORT,SERVICE_NAME:generic_data_string:Retrieve Hana cpu usage Hana_rs_fragmentation:SELECT HOST, PORT, TO_DECIMAL(SUM(FREE_SIZE) * 100 / SUM(ALLOCATED_SIZE),10,2), TO_DECIMAL( SUM(FREE_SIZE)/(1024*1024), 10, 2), TO_DECIMAL( SUM(ALLOCATED_SIZE)/(1024*1024), 10, 2) FROM M_RS_MEMORY WHERE CATEGORY = 'TABLE' OR CATEGORY = 'CATALOG' GROUP BY HOST, PORT:generic_data_string:Retrieve Hana row store fragmentation Hana_license:SELECT VALID, PERMANENT, PRODUCT_LIMIT, PRODUCT_USAGE FROM M_LICENSE;:generic_data_string:Retrieve license usage Hana_IO_Stats:SELECT HOST,PORT,TYPE, TO_DECIMAL((TOTAL_READ_SIZE * 1.048576 / (TOTAL_READ_TIME+1)),10,2), TO_DECIMAL((TOTAL_WRITE_SIZE * 1.048576 / (TOTAL_WRITE_TIME+1)),10,2) FROM M_VOLUME_IO_TOTAL_STATISTICS:generic_data_string:Retrieve IO bandwidth Hana_get_stated_connections:SELECT COUNT(*) FROM PUBLIC.M_CONNECTIONS WHERE CONNECTION_STATUS ='RUNNING':generic_data:retrieve connection status Hana_Memory:SELECT HOST, round ( 100 * INSTANCE_TOTAL_MEMORY_USED_SIZE / INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE, 2), round (INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE / 1024/1024/1024, 2), round (INSTANCE_TOTAL_MEMORY_USED_SIZE / 1024/1024/1024, 2) from M_HOST_RESOURCE_UTILIZATION:generic_data_string:retrieve memory usages Hana_Transactions:SELECT count(*) FROM M_BLOCKED_TRANSACTIONS;:generic_data:retrieve SAP transaction status Check_norunning_backups:select * from SYS.M_BACKUP_CATALOG where STATE_NAME = 'running':generic_data_string:Check to make sure there are no running backups still Backup_id_running_backup:select BACKUP_ID from SYS.M_BACKUP_CATALOG where entry_type_name = 'complete data backup' and state_name = 'running' order by sys_start_time desc:generic_data_string:Query to find BACKUP_ID of running data backup. ``` Creará los siguientes módulos:
Backups\_SizeEstimated backup size
TimestampCurrent timestamp
Hana\_versionversion Sap hana
Data\_disk\_informationRetrieve Hana disk info
Hana\_service\_staticsRetrieve Hana Requests per second
Hana\_cpu\_timeRetrieve Hana cpu usage
Hana\_rs\_fragmentationRetrieve Hana row store fragmentation
Hana\_licenseRetrieve license usage
Hana\_IO\_StatsRetrieve IO bandwidth
Hana\_get\_stated\_connectionsretrieve connection status
Hana\_Memoryretrieve memory usages
Hana\_Transactionsretrieve SAP transaction status
Check\_norunning\_backupsCheck to make sure there are no running backups still
Backup\_id\_running\_backupQuery to find BACKUP\_ID of running data backup