Skip to content

Instantly share code, notes, and snippets.

@sebastianwebber
Created November 10, 2016 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianwebber/0382f845acb9effb72fe0ff8d970bd11 to your computer and use it in GitHub Desktop.
Save sebastianwebber/0382f845acb9effb72fe0ff8d970bd11 to your computer and use it in GitHub Desktop.
Lista os indices para uso do LLD no zabbix
-- Based on https://wiki.postgresql.org/wiki/Disk_Usage
---- To use on zabbix for LLD
---- Sorted to the greatest size to the lowest size
WITH index_stats AS (
SELECT
pg_class.oid,
nspname AS table_schema,
relname AS index_NAME,
pg_total_relation_size(pg_class.oid) AS total_bytes
FROM pg_class
LEFT JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
WHERE pg_class.relkind = 'i'
AND pg_namespace.nspname = 'public'
ORDER BY total_bytes
), pretty_stats as (
SELECT
index_stats.index_NAME as "#INDEXNAME",
index_stats.total_bytes as "#TOTALBYTES"
FROM index_stats
)
SELECT json_build_object('DATA', json_agg(row_to_json(data))) FROM pretty_stats as data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment