[ZBXNEXT-8705] Tablespace used_pct_max wrong in Zabbix Agent 2 Plugin Created: 2021 Feb 04 Updated: 2024 Sep 05 Resolved: 2023 Nov 10 |
|
Status: | Closed |
Project: | ZABBIX FEATURE REQUESTS |
Component/s: | Agent2 plugin (G), Templates (T) |
Affects Version/s: | None |
Fix Version/s: | 6.0.24rc1, 6.4.9rc1, 7.0.0alpha8, 7.0 (plan) |
Type: | Change Request | Priority: | Major |
Reporter: | Hubert Nachbaur | Assignee: | Kristaps Naglis |
Resolution: | Fixed | Votes: | 3 |
Labels: | Agent2, Oracle | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Attachments: |
![]() |
||||||||
Issue Links: |
|
||||||||
Team: | |||||||||
Sprint: | Sprint 104 (Sep 2023), Sprint 105 (Oct 2023), Sprint 106 (Nov 2023) | ||||||||
Story Points: | 0.25 |
Description |
Currently the metric used_pct_max for the tablespaces in the Zabbix Agent 2 Oracle plugin returns the allocated and not the used percentage of the tablespace. Please change the sql statement to something like this: old: ROUND(DECODE(SUM(df.MAX_BYTES), 0, 0, (SUM(df.BYTES) / SUM(df.MAX_BYTES) * 100)), 2) AS USED_PCT_MAX, new: ROUND(DECODE(SUM(df.MAX_BYTES), 0, 0, (SUM(df.BYTES)-SUM(f.FREE)) / SUM(df.MAX_BYTES)* 100), 2) AS USED_PCT_MAX, With this change you will get the same values as in dba_tablespace_usage_metrics.
|
Comments |
Comment by Aleksandrs Larionovs (Inactive) [ 2021 Feb 08 ] |
Hello, |
Comment by Hubert Nachbaur [ 2021 Feb 09 ] |
I'm already using the latest version and it's still not fixed. Please compare the values you get with dba_tablespace_usage_metrics. Example of the tablespace SYSAUX on my test db:
The correct value for USED_PCT_MAX is 27,67 and not 74,5. (1562378240-982056960)/2097152000*100 (FILE_BYTES-USED_BYTES)/MAY_BYTES*100 74,5 is the percentage of the allocated space of a tablespace, not the usage.
|
Comment by Hubert Nachbaur [ 2021 Jun 22 ] |
In the Oracle template for Zabbix agent 2 USED_PCT_MAX is used as "Tablespace allocated, percent", so no change is needed for USED_PCT_MAX. I've changed USED_FILE_PCT to get the correct usage of the tablespace in percent and uploaded the patch to this ticket. |
Comment by Claudio Gajardo [ 2022 Jul 15 ] |
Hola, Aplique esta solución: old: ROUND(DECODE(SUM(df.MAX_BYTES), 0, 0, (SUM(df.BYTES) / SUM(df.MAX_BYTES) * 100)), 2) AS USED_PCT_MAX, new: ROUND(DECODE(SUM(df.MAX_BYTES), 0, 0, (SUM(df.BYTES)-SUM(f.FREE)) / SUM(df.MAX_BYTES)* 100), 2) AS USED_PCT_MAX, en: template item Oracle: Get tablespaces stats (db.odbc.get[tablespace_stats,"\{$ORACLE.DSN}"]) Y se solucionó para tablespaces de tipo PERMANENTE, no así para TEMPORARY Tablespaces... Revisando la query , se debe además modificar la query mas abajo cambiando lo siguiente: old: ROUND(DECODE(SUM(Y.MAX_BYTES), 0, 0, (SUM(Y.BYTES) / SUM (Y.MAX_BYTES) * 100)), 2) AS USED_PCT_MAX new: ROUND(DECODE(SUM(Y.MAX_BYTES), 0, 0, (SUM(Y.BYTES) - SUM(Y.FREE)) / SUM(Y.MAX_BYTES)* 100), 2) AS USED_PCT_MAX, Con esto, el USED_PCT_MAX para tablespace TEMP será mostrado correctamente.... La query final con las dos correciones es la siguiente: SELECT df.tablespace_name AS TABLESPACE, df.type AS TYPE, NVL(SUM(df.BYTES), 0) AS FILE_BYTES, NVL(SUM(df.MAX_BYTES), 0) AS MAX_BYTES, NVL(SUM(f.FREE), 0) AS FREE_BYTES, SUM(df.BYTES)-SUM(f.FREE) AS USED_BYTES, ROUND(DECODE(SUM(df.MAX_BYTES), 0, 0, (SUM(df.BYTES)-SUM(f.FREE)) / SUM(df.MAX_BYTES)* 100), 2) AS USED_PCT_MAX, ROUND(DECODE(SUM(df.BYTES), 0, 0,(SUM(df.BYTES)-SUM(f.FREE))/ SUM(df.BYTES)* 100), 2) AS USED_FILE_PCT, DECODE(df.STATUS, 'ONLINE', 1, 'OFFLINE', 2, 'READ ONLY', 3, 0) AS STATUS FROM ( SELECT ddf.file_id, dt.contents AS TYPE, dt.STATUS , ddf.file_name, ddf.tablespace_name, TRUNC(ddf.bytes) AS bytes, TRUNC(GREATEST(ddf.bytes, ddf.maxbytes)) AS max_bytes FROM dba_data_files ddf, dba_tablespaces dt WHERE ddf.tablespace_name = dt.tablespace_name ) df, ( SELECT TRUNC(SUM(bytes)) AS FREE, file_id FROM dba_free_space GROUP BY file_id ) f WHERE df.file_id = f.file_id |
Comment by Hubert Nachbaur [ 2022 Aug 11 ] |
Hello, with this small (corrected) patch I get the same values for USED_FILE_PCT as in dba_tablespace_usage_metrics (USED_PERCENT). |
Comment by Markus Bergholz [ 2023 Mar 28 ] |
Any progress here? We faced the same issue. |
Comment by Markus Bergholz [ 2023 Mar 28 ] |
Another workaround is to patch the template
``` min(/kvasy Oracle by Zabbix agent 2/oracle.tbs_used_bytes"{#TABLESPACE}",5m)/min(/kvasy Oracle by Zabbix agent 2/oracle.tbs_max_bytes"{#TABLESPACE}",5m)>{$ORACLE.TBS.UTIL.PCT.MAX.HIGH} ```{} |
Comment by Kristaps Naglis [ 2023 Sep 13 ] |
All metrics here are working as they are expected to. When creating tablespaces in Oracle, you can define 2 types of sizes - SIZE and MAXSIZE to which it can autoextend. ExplanationUSED_FILE_PCTThis metric calculates percentage of currently used bytes from currently allocated tablespace size (in Oracle terms - SIZE), i.e., how much is currently used from SIZE. (USED_BYTES / FILE_BYTES) * 100 USED_PCT_MAXThis metric calculates percentage of currently allocated tablespace size to its maximum allowed size, i.e., how much SIZE is of MAXSIZE. This metric is useful to see when your tablespace allocated size is nearing its maximum allowed size. (FILE_BYTES / MAX_BYTES) * 100 Item logic is also mentioned in respective item descriptions. SolutionI understand that there is a need for a metric that shows percentage of tablespace current byte usage from its maximum allowed size (USED_BYTES from MAXSIZE) (USED_BYTES / MAX_BYTES) * 100 We will work on implementing this for Oracle Agent2 and ODBC templates |
Comment by Kristaps Naglis [ 2023 Nov 09 ] |
Implemented in:
|