You are on page 1of 1

Database troubleshooting

This page outlines a few items that can be helpful when troubleshooting NHM database problems (PostgreSQL).

How to connect to the database


1. For a local SQL client & tunnel, see this page
2. Otherwise, the following command can be issue from a SG, which will give access to the command line SQL client:

/opt/rh/rh-postgresql94/root/usr/bin/psql -h postgresql01 -U kpiuser -d kpiservdb

Database space model


To avoid filling up the overall database filesystem, NHM has a limit on its database size. This is defined in a configuration model and can be found in the
following repository/class:

kpi-calculation-flow-model-api/src/main/java/com/ericsson/oss/services/nhm/kpicalculationservice/configuration
/ConfigurableParametersModel.java

Verify database & tables size


The following query reports the size for all tables within the database:

SELECT *, pg_size_pretty(total_bytes) AS total


, pg_size_pretty(index_bytes) AS index
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS table
FROM (
SELECT *, total_bytes-index_bytes-coalesce(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS table_name
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
, pg_total_relation_size(reltoastrelid) AS toast_bytes
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE relkind = 'r'
) a
) a;

PostgreSQL vacuum cron jobs


PostgreSQL vacuum jobs are located within ERICpostgresql. The following review highlights the location and how it was implemented:

https://gerrit.ericsson.se/#/c/4768569/

Verify calculated KPI instances from the database


The following query can be helpful to see the exact number of KPIs calculated per ROP:

select count(key), to_timestamp(rop / 1000) + (5 * interval '1 minute') rop_start, rop, concat(cast((cast(count
(key) as decimal) / 300000) as decimal(4,3)) * 100,'%') load_percent from kpi_data group by rop order by rop
desc limit 20

You might also like