Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 94b8778

Browse files
mrjimrollГоликов Сергей НиколаевичYannig
authored
Changes to Readme; System D examples (#173)
* Update README.md Added additional comments for DATA_SOURCE_NAME; Added mandatory environment variables for systemd integration Fixed /etc path; Add ASM instance connection example Linux System D configuration example Few ASM instance metric template: diskgroup size & usage; asm disks i/o stats (can be summarized by diskgroup using Prometheus GraphQL) Co-authored-by: Голиков Сергей Николаевич <[email protected]> Co-authored-by: Yannig <[email protected]>
1 parent 406f5d9 commit 94b8778

File tree

4 files changed

+199
-4
lines changed

4 files changed

+199
-4
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,19 @@ export DATA_SOURCE_NAME=user/password@//myhost:1521/service
104104
export DATA_SOURCE_NAME=user/password@//primaryhost:1521,standbyhost:1521/service
105105
# 19c client for primary/standby configuration with options
106106
export DATA_SOURCE_NAME=user/password@//primaryhost:1521,standbyhost:1521/service?connect_timeout=5&transport_connect_timeout=3&retry_count=3
107+
# 19c client for ASM instance connection (requires SYSDBA)
108+
export DATA_SOURCE_NAME=user/password@//primaryhost:1521,standbyhost:1521/+ASM?as=sysdba
107109
# Then run the exporter
108110
/path/to/binary/oracledb_exporter --log.level error --web.listen-address 0.0.0.0:9161
109111
```
110112

111113
# Integration with System D
112114

113115
Create **oracledb_exporter** user with disabled login and **oracledb_exporter** group\
114-
mkdir /etc/etc/oracledb_exporter\
115-
chown root:oracledb_exporter /etc/etc/oracledb_exporter
116-
chmod 775 /etc/etc/oracledb_exporter
117-
Put config files to **/etc/etc/oracledb_exporter**
116+
mkdir /etc/oracledb_exporter\
117+
chown root:oracledb_exporter /etc/oracledb_exporter
118+
chmod 775 /etc/oracledb_exporter
119+
Put config files to **/etc/oracledb_exporter**
118120
Put binary to **/usr/local/bin**
119121

120122
Create file **/etc/systemd/system/oracledb_exporter.service** with the following content:

default-asm-metrics.toml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
[[metric]]
2+
context = "diskgroup_size"
3+
labels = [ "inst_id", "node_name" , "instance_name", "diskgroup_name" ]
4+
metricsdesc = { total = "Total size of ASM disk group in MB.", free = "Free space available on ASM disk group in MB." }
5+
request = '''
6+
SELECT instance_number AS inst_id,
7+
host_name AS node_name,
8+
instance_name,
9+
name AS diskgroup_name,
10+
total_mb * 1024 * 1024 AS total,
11+
free_mb * 1024 * 1024 AS free
12+
FROM v$asm_diskgroup_stat, v$instance
13+
'''
14+
ignorezeroresult = true
15+
16+
[[metric]]
17+
context = "asmuptime"
18+
labels = [ "inst_id", "node_name", "instance_name"]
19+
metricsdesc = { uptime = "ASM uptime" }
20+
request = '''
21+
SELECT instance_number AS inst_id,
22+
host_name AS node_name,
23+
instance_name,
24+
(SYSDATE - startup_time) * 86400 AS uptime
25+
FROM v$instance
26+
'''
27+
28+
#[[metric]]
29+
#context = "asm_dg_stat"
30+
#labels = [ "inst_id", "diskgroup_name", "node_name", "instance_name" ]
31+
#metricsdesc = { reads = "Total number of I/O read requests for the DG.", writes = "Total number of I/O write requests for the DG.", bytes_read = "Total number of bytes read from the DG", bytes_written = "Total number of bytes written from the DG", iops = "Total number of I/O requests for the DG" }
32+
#metricstype = { reads = "counter", writes = "counter", bytes_read = "counter", bytes_written = "counter", iops = "counter" }
33+
#request = '''
34+
# SELECT i.instance_number AS inst_id,
35+
# i.host_name AS node_name,
36+
# i.instance_name,
37+
# g.name AS diskgroup_name,
38+
# SUM (ds.reads) AS reads,
39+
# SUM (ds.writes) AS writes,
40+
# SUM (ds.bytes_read) AS bytes_read,
41+
# SUM (ds.bytes_written) AS bytes_written,
42+
# SUM (ds.reads + ds.writes) AS iops
43+
# FROM v$asm_disk_stat ds, v$asm_diskgroup_stat g, v$instance i
44+
# WHERE ds.mount_status = 'CACHED' AND ds.group_number = g.group_number
45+
#GROUP BY i.instance_number,
46+
# i.host_name,
47+
# i.instance_name,
48+
# g.name
49+
#'''
50+
51+
[[metric]]
52+
context = "asm_disk_stat"
53+
labels = [ "inst_id", "node_name", "instance_name", "diskgroup_name", "disk_number", "failgroup", "path" ]
54+
metricsdesc = { reads = "Total number of I/O read requests for the DG.", writes = "Total number of I/O write requests for the DG.", read_time = "Total I/O time (in hundreths of a second) for read requests for the disk", write_time = "Total I/O time (in hundreths of a second) for write requests for the disk", bytes_read = "Total number of bytes read from the DG", bytes_written = "Total number of bytes written from the DG", iops = "Total number of I/O requests for the DG" }
55+
metricstype = { reads = "counter", writes = "counter", bytes_read = "counter", read_time = "counter", write_time = "counter", bytes_written = "counter", iops = "counter" }
56+
request = '''
57+
SELECT i.instance_number AS inst_id,
58+
i.host_name AS node_name,
59+
i.instance_name,
60+
g.name AS diskgroup_name,
61+
ds.disk_number AS disk_number,
62+
ds.failgroup AS failgroup,
63+
ds.reads AS reads,
64+
ds.writes AS writes,
65+
ds.read_time * 1000 AS read_time,
66+
ds.write_time * 1000 AS write_time,
67+
ds.bytes_read AS bytes_read,
68+
ds.bytes_written AS bytes_written,
69+
REGEXP_REPLACE (ds.PATH, '.*/\', '\') AS PATH,
70+
ds.reads + ds.writes AS iops
71+
FROM v$asm_disk_stat ds, v$asm_diskgroup_stat g, v$instance i
72+
WHERE ds.mount_status = 'CACHED' AND ds.group_number = g.group_number
73+
'''
74+
75+
[[metric]]
76+
context = "asm_space_consumers"
77+
labels = [ "inst_id", "diskgroup_name", "node_name", "instance_name", "sid", "file_type" ]
78+
metricsdesc = { size_mb = "Total space usage by db by file_type" , files = "Number of files by db by type" }
79+
request = '''
80+
SELECT i.instance_number AS inst_id,
81+
i.host_name AS node_name,
82+
i.instance_name,
83+
gname AS diskgroup_name,
84+
dbname AS sid,
85+
file_type,
86+
ROUND (SUM (space) / 1024 / 1024) size_mb,
87+
COUNT (*) AS files
88+
FROM v$instance i,
89+
(SELECT gname,
90+
REGEXP_SUBSTR (full_alias_path,
91+
'[[:alnum:]_]*',
92+
1,
93+
4) dbname,
94+
file_type,
95+
space,
96+
aname,
97+
system_created,
98+
alias_directory
99+
FROM ( SELECT CONCAT ('+' || gname,
100+
SYS_CONNECT_BY_PATH (aname, '/'))
101+
full_alias_path,
102+
system_created,
103+
alias_directory,
104+
file_type,
105+
space,
106+
LEVEL,
107+
gname,
108+
aname
109+
FROM (SELECT b.name gname,
110+
a.parent_index pindex,
111+
a.name aname,
112+
a.reference_index rindex,
113+
a.system_created,
114+
a.alias_directory,
115+
c.TYPE file_type,
116+
c.space
117+
FROM v$asm_alias a, v$asm_diskgroup b, v$asm_file c
118+
WHERE a.group_number = b.group_number
119+
AND a.group_number = c.group_number(+)
120+
AND a.file_number = c.file_number(+)
121+
AND a.file_incarnation = c.incarnation(+))
122+
START WITH (MOD (pindex, POWER (2, 24))) = 0
123+
AND rindex IN
124+
(SELECT a.reference_index
125+
FROM v$asm_alias a, v$asm_diskgroup b
126+
WHERE a.group_number =
127+
b.group_number
128+
AND (MOD (a.parent_index,
129+
POWER (2, 24))) =
130+
0)
131+
CONNECT BY PRIOR rindex = pindex)
132+
WHERE NOT file_type IS NULL AND system_created = 'Y')
133+
GROUP BY i.instance_number,
134+
i.host_name,
135+
i.instance_name,
136+
gname,
137+
dbname,
138+
file_type
139+
'''
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[Unit]
2+
Description=Service for oracle asm telemetry client
3+
After=network-online.target
4+
5+
[Service]
6+
Type=simple
7+
Environment="DATA_SOURCE_NAME=asmsnmp/password@//host:1521/+ASM?as=sysdba"
8+
Environment="LD_LIBRARY_PATH=/u01/app/oracle/product/19.0.0/dbhome_1/lib"
9+
Environment="ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1"
10+
User=oracledb_exporter
11+
Group=oracledb_exporter
12+
ExecStart=/usr/local/bin/oracledb_exporter \
13+
--default.metrics "/etc/oracledb_exporter/default-asm-metrics.toml" \
14+
--log.level "error" \
15+
--web.listen-address 0.0.0.0:9163 \
16+
--log.format "logger:syslog?appname=oracleasm_exporter&local=7"
17+
18+
KillMode=process
19+
RemainAfterExit=no
20+
Restart=on-failure
21+
RestartSec=5s
22+
23+
[Install]
24+
WantedBy=multi-user.target
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Ansible managed
3+
#
4+
5+
[Unit]
6+
Description=Service for oracle telemetry client
7+
After=network-online.target
8+
9+
[Service]
10+
Type=simple
11+
Environment="DATA_SOURCE_NAME=dbsnmp/password@//host:1521/service?transport_connect_timeout=5&retry_count=3"
12+
Environment="LD_LIBRARY_PATH=/u01/app/oracle/product/19.0.0/dbhome_1/lib"
13+
Environment="ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1"
14+
#Environment="PATH=$PATH:/u01/app/oracle/product/19.0.0/dbhome_1/bin"
15+
#Environment="TNS_ADMIN=/u01/app/oracle/product/19.0.0/dbhome_1/network/admin"
16+
User=oracledb_exporter
17+
Group=oracledb_exporter
18+
ExecStart=/usr/local/bin/oracledb_exporter \
19+
--default.metrics "/etc/oracledb_exporter/default-metrics.toml" \
20+
--log.level "error" \
21+
--web.listen-address 0.0.0.0:9161 \
22+
--log.format "logger:syslog?appname=oracledb_exporter&local=7"
23+
24+
KillMode=process
25+
RemainAfterExit=no
26+
Restart=on-failure
27+
RestartSec=5s
28+
29+
[Install]
30+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)