Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / oracle / oracle_sysstat_ @ 827c75fb

Historique | Voir | Annoter | Télécharger (29 ko)

1 7c08e6c4 K.Cima
#!/bin/bash
2
# -*- sh -*-
3
4
: << =cut
5
6
=head1 NAME
7
8
  oracle_sysstat_* - Munin plugin to monitor Oracle Statistics
9
10 ca01c6e3 K.Shimadera
    execute                 - To monitor Oracle Sysstat SQL Execute Count
11
    parse                   - To monitor Oracle Sysstat SQL Parse Count
12
    tablefetch              - To monitor Oracle Sysstat SQL Table Fetch Rows
13
    tablescan               - To monitor Oracle Sysstat SQL Table Scans
14
    transaction             - To monitor Oracle Sysstat SQL Transactions
15
    sort                    - To monitor Oracle Sysstat SQL Sorts
16
    logon                   - To monitor Oracle Sysstat User Logons
17
    cursor                  - To monitor Oracle Sysstat User Opened Cursors
18
    enqueue                 - To monitor Oracle Sysstat Enqueues
19
    redolog                 - To monitor Oracle Sysstat Redo Entries
20
    redosize                - To monitor Oracle Sysstat Redo Size
21
    physicaliops            - To monitor Oracle Sysstat I/O Physical Requests
22
    physicalrw              - To monitor Oracle Sysstat I/O Physical Bytes
23
    blockrw                 - To monitor Oracle Sysstat I/O Blocks
24
    netrw                   - To monitor Oracle Sysstat I/O Network Bytes
25
    sgainfo                 - To monitor Oracle Memory SGA
26
    pgastat                 - To monitor Oracle Memory PGA
27
    cputime                 - To monitor Oracle CPU Time
28
    cachehit                - To monitor Oracle Cache Hit Ratio
29
    sessionuser             - To monitor Oracle Session Users
30
    sessionwait             - To monitor Oracle Session Wait
31
    eventwait               - To monitor Oracle Wait Events
32
    eventwaitapplication    - To monitor Oracle Wait Events Application
33
    eventwaitnetwork        - To monitor Oracle Wait Events Network
34
    eventwaitconcurrency    - To monitor Oracle Wait Events Concurrency
35
    eventwaituserio         - To monitor Oracle Wait Events User I/O
36
    eventwaitsystemio       - To monitor Oracle Wait Events System I/O
37
    eventwaitcluster        - To monitor Oracle Wait Events Cluster
38
    eventwaitadministrative - To monitor Oracle Wait Events Administrative
39
    eventwaitconfiguration  - To monitor Oracle Wait Events Configuration
40
    tablespace              - To monitor Oracle Table Space Usage
41
    asmusage                - To monitor Oracle ASM Disk Group Usage
42 7c08e6c4 K.Cima
43
=head1 CONFIGURATION
44
45
  To get a list of symlinks that can be created, run:   
46
47
    ./oracle_sysstat_ suggest
48
49
  Make symlinks:
50
51
    munin-node-configure --families=contrib --suggest --shell
52
    ...
53
54
  The following shows example settings for this plugin:
55
56
    [oracle_sysstat_*]
57
      user  oracle
58
      env.oracle_auth  / as SYSDBA
59
      env.ORACLE_HOME  /path/to/oracle/product/version
60
      env.ORACLE_SID   SOMESID
61
62
    [oracle_sysstat_asmusage]
63
      user  grid
64
      env.oracle_auth  / as SYSASM
65
      env.ORACLE_HOME  /path/to/grid/home/version
66
      env.ORACLE_SID   SOMESID
67
68
=head1 NOTES
69
70
  Uses the command "sqlplus".
71
  Tested with Oracle Database 12c R1.
72
73
=head1 AUTHOR
74
75
  K.Cima https://github.com/shakemid
76
77
=head1 LICENSE
78
79
  GPLv2
80
81
=cut
82
83
# Magic markers
84
#%# family=contrib
85
#%# capabilities=autoconf suggest
86
87
# Like perl 'use strict;' 
88 ca01c6e3 K.Shimadera
set -o nounset
89
90
# Include plugin.sh
91
. "${MUNIN_LIBDIR:-}/plugins/plugin.sh"
92 7c08e6c4 K.Cima
93
# Environments
94 fe8908c3 K.Cima
: "${ORACLE_HOME:=$( echo /opt/oracle/product/* )}"
95
: "${ORACLE_SID:=orcl}"
96
: "${oracle_auth:=/ as SYSDBA}"
97 7c08e6c4 K.Cima
98
PATH=$PATH:$ORACLE_HOME/bin
99
export PATH ORACLE_HOME ORACLE_SID
100
101
# Module name
102 fe8908c3 K.Cima
module=$( basename "$0" | sed -e 's/^.*_//' )
103 7c08e6c4 K.Cima
104
# Graph settings
105
declare -A global_attrs  # required
106 69f98e7f K.Cima
declare -A data_attrs    # required (format: field type draw label)
107 7c08e6c4 K.Cima
declare -A getfield_func # optional
108
declare -A getvalue_func # required
109
110
key=execute
111
global_attrs[$key]="
112 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat SQL Execute Count
113 7c08e6c4 K.Cima
    graph_category db
114
    graph_args --base 1000 --lower-limit 0 --rigid
115
    graph_vlabel count per second
116 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat SQL Execute Count
117 7c08e6c4 K.Cima
"
118
data_attrs[$key]="
119 ca01c6e3 K.Shimadera
    execute_count   DERIVE LINE execute count
120
    user_calls      DERIVE LINE user calls
121
    recursive_calls DERIVE LINE recursive calls
122 7c08e6c4 K.Cima
"
123
getvalue_func[$key]=getvalue_sysstat
124
125
key=parse
126
global_attrs[$key]="
127 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat SQL Parse Count
128 7c08e6c4 K.Cima
    graph_category db
129
    graph_args --base 1000 --lower-limit 0 --rigid
130
    graph_vlabel count per second
131 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat SQL Parse Count
132 7c08e6c4 K.Cima
"
133
data_attrs[$key]="
134 ca01c6e3 K.Shimadera
    parse_count_total    DERIVE LINE parse count (total)
135
    parse_count_hard     DERIVE LINE parse count (hard)
136
    parse_count_describe DERIVE LINE parse count (describe)
137
    parse_count_failures DERIVE LINE parse count (failures)
138 7c08e6c4 K.Cima
"
139
getvalue_func[$key]=getvalue_sysstat
140
141
key=tablefetch
142
global_attrs[$key]="
143 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat SQL Table Fetch Rows
144 7c08e6c4 K.Cima
    graph_category db
145
    graph_args --base 1000 --lower-limit 0 --rigid
146
    graph_vlabel count per second
147 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat SQL Table Fetch Rows
148 7c08e6c4 K.Cima
"
149
data_attrs[$key]="
150 ca01c6e3 K.Shimadera
    table_fetch_by_rowid      DERIVE LINE table fetch by rowid
151
    table_scan_rows_gotten    DERIVE LINE table scan rows gotten
152
    table_fetch_continued_row DERIVE LINE table fetch continued row
153 7c08e6c4 K.Cima
"
154
getvalue_func[$key]=getvalue_sysstat
155
156
key=tablescan
157
global_attrs[$key]="
158 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat SQL Table Scans
159 7c08e6c4 K.Cima
    graph_category db
160
    graph_args --base 1000 --lower-limit 0 --rigid
161
    graph_vlabel count per second
162 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat SQL Table Scans
163 7c08e6c4 K.Cima
"
164
data_attrs[$key]="
165 69f98e7f K.Cima
    table_scans_short_tables DERIVE LINE table scans (short tables)
166
    table_scans_long_tables  DERIVE LINE table scans (long tables)
167 7c08e6c4 K.Cima
"
168
getvalue_func[$key]=getvalue_sysstat
169
170
key=transaction
171
global_attrs[$key]="
172 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat SQL Transactions
173 7c08e6c4 K.Cima
    graph_category db
174
    graph_args --base 1000 --lower-limit 0 --rigid
175
    graph_vlabel count per second
176 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat SQL Transactions
177 7c08e6c4 K.Cima
"
178
data_attrs[$key]="
179 69f98e7f K.Cima
    user_commits   DERIVE LINE user commits
180
    user_rollbacks DERIVE LINE user rollbacks
181 7c08e6c4 K.Cima
"
182
getvalue_func[$key]=getvalue_sysstat
183
184
key=sort
185
global_attrs[$key]="
186 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat SQL Sorts
187 7c08e6c4 K.Cima
    graph_category db
188
    graph_args --base 1000 --lower-limit 0 --rigid
189
    graph_vlabel count per second
190 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat SQL Sorts
191 7c08e6c4 K.Cima
"
192
data_attrs[$key]="
193 69f98e7f K.Cima
    sorts_memory DERIVE LINE sorts (memory)
194
    sorts_disk   DERIVE LINE sorts (disk)
195 7c08e6c4 K.Cima
"
196
getvalue_func[$key]=getvalue_sysstat
197
198 ca01c6e3 K.Shimadera
key=logon
199
global_attrs[$key]="
200
    graph_title Oracle Sysstat User Logons
201
    graph_category db
202
    graph_args --base 1000 --lower-limit 0 --rigid
203
    graph_vlabel count per second
204
    graph_info Oracle Sysstat User Logons
205
"
206
data_attrs[$key]="
207
    logon DERIVE LINE logons cumulative
208
"
209
getvalue_func[$key]=getvalue_sysstat
210
211 7c08e6c4 K.Cima
key=cursor
212
global_attrs[$key]="
213 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat User Opened Cursors
214 7c08e6c4 K.Cima
    graph_category db
215
    graph_args --base 1000 --lower-limit 0 --rigid
216
    graph_vlabel count
217 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat User Opened Cursors
218 7c08e6c4 K.Cima
"
219
data_attrs[$key]="
220 69f98e7f K.Cima
    open_cursor GAUGE LINE opened cursors current
221 7c08e6c4 K.Cima
"
222
getvalue_func[$key]=getvalue_sysstat
223
224
key=enqueue
225
global_attrs[$key]="
226
    graph_title Oracle Sysstat Enqueues
227
    graph_category db
228
    graph_args --base 1000 --lower-limit 0 --rigid
229
    graph_vlabel count per second
230
    graph_info Oracle Sysstat Enqueues
231
"
232
data_attrs[$key]="
233 69f98e7f K.Cima
    enqueue_requests    DERIVE LINE enqueue requests
234
    enqueue_releases    DERIVE LINE enqueue releases
235
    enqueue_conversions DERIVE LINE enqueue conversions
236
    enqueue_waits       DERIVE LINE enqueue waits
237
    enqueue_timeouts    DERIVE LINE enqueue timeouts
238
    enqueue_deadlocks   DERIVE LINE enqueue deadlocks
239 7c08e6c4 K.Cima
"
240
getvalue_func[$key]=getvalue_sysstat
241
242
key=redolog
243
global_attrs[$key]="
244 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat Redo Entries
245 7c08e6c4 K.Cima
    graph_category db
246
    graph_args --base 1000 --lower-limit 0 --rigid
247
    graph_vlabel count per second
248 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat Redo Entries
249 7c08e6c4 K.Cima
"
250
data_attrs[$key]="
251 69f98e7f K.Cima
    redo_entries                   DERIVE LINE redo entries
252 ca01c6e3 K.Shimadera
    redo_writes                    DERIVE LINE redo writes
253
    redo_synch_writes              DERIVE LINE redo synch writes
254 69f98e7f K.Cima
    redo_buffer_allocation_retries DERIVE LINE redo buffer allocation retries
255
    redo_log_space_requests        DERIVE LINE redo log space requests
256 7c08e6c4 K.Cima
"
257
getvalue_func[$key]=getvalue_sysstat
258
259 ca01c6e3 K.Shimadera
key=redosize
260
global_attrs[$key]="
261
    graph_title Oracle Sysstat Redo Size
262
    graph_category db
263
    graph_args --base 1024 --lower-limit 0 --rigid
264
    graph_vlabel bytes per second
265
    graph_info Oracle Sysstat Redo Size
266
"
267
data_attrs[$key]="
268
    redo_size    DERIVE LINE redo size
269
    redo_wastage DERIVE LINE redo wastage
270
"
271
getvalue_func[$key]=getvalue_sysstat
272
273 7c08e6c4 K.Cima
key=physicaliops
274
global_attrs[$key]="
275 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat I/O Physical Requests
276 7c08e6c4 K.Cima
    graph_category db
277
    graph_args --base 1000 --lower-limit 0 --rigid
278
    graph_vlabel iops
279 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat I/O Physical Requests
280 7c08e6c4 K.Cima
"
281
data_attrs[$key]="
282 69f98e7f K.Cima
    physical_read_total        DERIVE LINE2 physical read total IO requests
283
    physical_read              DERIVE LINE  physical read IO requests
284
    physical_read_total_multi  DERIVE LINE  physical read total multi block requests
285
    physical_write_total       DERIVE LINE2 physical write total IO requests
286
    physical_write             DERIVE LINE  physical write IO requests
287
    physical_write_total_multi DERIVE LINE  physical write total multi block requests
288 7c08e6c4 K.Cima
"
289
getvalue_func[$key]=getvalue_sysstat
290
291
key=physicalrw
292
global_attrs[$key]="
293 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat I/O Physical Bytes
294 7c08e6c4 K.Cima
    graph_category db
295
    graph_args --base 1024 --lower-limit 0 --rigid
296
    graph_vlabel bytes per second
297 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat I/O Physical Bytes
298 7c08e6c4 K.Cima
"
299
data_attrs[$key]="
300 69f98e7f K.Cima
    physical_read_total  DERIVE LINE2 physical read total bytes
301
    physical_read        DERIVE LINE  physical read bytes
302
    physical_write_total DERIVE LINE2 physical write total bytes
303
    physical_write       DERIVE LINE  physical write bytes
304 7c08e6c4 K.Cima
"
305
getvalue_func[$key]=getvalue_sysstat
306
307 ca01c6e3 K.Shimadera
key=blockrw
308
global_attrs[$key]="
309
    graph_title Oracle Sysstat I/O Blocks
310
    graph_category db
311
    graph_args --base 1000 --lower-limit 0 --rigid
312
    graph_vlabel blocks per second
313
    graph_info Oracle Sysstat I/O Blocks
314
"
315
data_attrs[$key]="
316
    db_block_gets      DERIVE LINE db block gets
317
    db_block_changes   DERIVE LINE db block changes
318
    consistent_gets    DERIVE LINE consistent gets
319
    consistent_changes DERIVE LINE consistent changes
320
    physical_reads     DERIVE LINE physical reads
321
    physical_writes    DERIVE LINE physical writes
322
"
323
getvalue_func[$key]=getvalue_sysstat
324
325
326 7c08e6c4 K.Cima
key=netrw
327
global_attrs[$key]="
328 ca01c6e3 K.Shimadera
    graph_title Oracle Sysstat I/O Network Bytes
329 7c08e6c4 K.Cima
    graph_category db
330
    graph_args --base 1024 --lower-limit 0 --rigid
331
    graph_vlabel bytes per second
332 ca01c6e3 K.Shimadera
    graph_info Oracle Sysstat I/O Network Bytes
333 7c08e6c4 K.Cima
"
334
data_attrs[$key]="
335 69f98e7f K.Cima
    bytes_sent_via_sql_net_to_client       DERIVE LINE bytes sent via SQL*Net to client
336
    bytes_received_via_sql_net_from_client DERIVE LINE bytes received via SQL*Net from client
337
    bytes_sent_via_sql_net_to_dblink       DERIVE LINE bytes sent via SQL*Net to dblink
338
    bytes_received_via_sql_net_from_dblink DERIVE LINE bytes received via SQL*Net from dblink
339 7c08e6c4 K.Cima
"
340
getvalue_func[$key]=getvalue_sysstat
341
342
key=sgainfo
343
global_attrs[$key]="
344
    graph_title Oracle Memory SGA
345
    graph_category db
346
    graph_args --base 1024 --lower-limit 0 --rigid
347
    graph_vlabel bytes
348
    graph_info Oracle Memory SGA
349
"
350
data_attrs[$key]="
351 69f98e7f K.Cima
    maximum_sga_size    GAUGE LINE      Maximum SGA Size
352
    fixed_sga_size      GAUGE AREASTACK Fixed SGA Size
353
    redo_buffers        GAUGE AREASTACK Redo Buffers
354
    shared_pool_size    GAUGE AREASTACK Shared Pool Size
355
    large_pool_size     GAUGE AREASTACK Large Pool Size
356
    java_pool_size      GAUGE AREASTACK Java Pool Size
357
    streams_pool_size   GAUGE AREASTACK Streams Pool Size
358
    shared_io_pool_size GAUGE AREASTACK Shared IO Pool Size
359
    buffer_cache_size   GAUGE AREASTACK Buffer Cache Size
360
    in_memory_area_size GAUGE AREASTACK In-Memory Area Size
361 7c08e6c4 K.Cima
"
362
getvalue_func[$key]=getvalue_sgainfo
363
364
key=pgastat
365
global_attrs[$key]="
366
    graph_title Oracle Memory PGA
367
    graph_category db
368
    graph_args --base 1024 --lower-limit 0 --rigid
369
    graph_vlabel bytes
370
    graph_info Oracle Memory PGA
371
"
372
data_attrs[$key]="
373 ca01c6e3 K.Shimadera
    pga_target       GAUGE LINE aggregate PGA target parameter
374
    pga_auto_target  GAUGE LINE aggregate PGA auto target
375
    pga_allocated    GAUGE LINE total PGA allocated
376
    pga_inuse        GAUGE AREA total PGA inuse
377 7c08e6c4 K.Cima
"
378
getvalue_func[$key]=getvalue_pgastat
379
380 ca01c6e3 K.Shimadera
key=cputime
381
global_attrs[$key]="
382
    graph_title Oracle CPU Time
383
    graph_category db
384
    graph_args --base 1000 --lower-limit 0 --rigid
385
    graph_vlabel seconds
386
    graph_info Oracle CPU Time
387
"
388
data_attrs[$key]="
389
    db_time                                        DERIVE LINE2 DB time
390
    db_cpu                                         DERIVE LINE2 DB CPU
391
    background_elapsed_time                        DERIVE LINE2 background elapsed time
392
    background_cpu_time                            DERIVE LINE2 background cpu time
393
    connection_management_call_elapsed_time        DERIVE LINE  connection management call elapsed time
394
    sequence_load_elapsed_time                     DERIVE LINE  sequence load elapsed time
395
    sql_execute_elapsed_time                       DERIVE LINE  sql execute elapsed time
396
    parse_time_elapsed                             DERIVE LINE  parse time elapsed
397
    hard_parse_elapsed_time                        DERIVE LINE  hard parse elapsed time
398
    hard_parse_sharing_criteria_elapsed_time       DERIVE LINE  hard parse (sharing criteria) elapsed time
399
    hard_parse_bind_mismatch_elapsed_time          DERIVE LINE  hard parse (bind mismatch) elapsed time
400
    failed_parse_elapsed_time                      DERIVE LINE  failed parse elapsed time
401
    failed_parse_out_of_shared_memory_elapsed_time DERIVE LINE  failed parse (out of shared memory) elapsed time
402
    pl_sql_execution_elapsed_time                  DERIVE LINE  PL/SQL execution elapsed time
403
    inbound_pl_sql_rpc_elapsed_time                DERIVE LINE  inbound PL/SQL rpc elapsed time
404
    pl_sql_compilation_elapsed_time                DERIVE LINE  PL/SQL compilation elapsed time
405
    java_execution_elapsed_time                    DERIVE LINE  Java execution elapsed time
406
    repeated_bind_elapsed_time                     DERIVE LINE  repeated bind elapsed time
407
    rman_cpu_time_backup_restore                   DERIVE LINE  RMAN cpu time (backup/restore)
408
"
409
getvalue_func[$key]=getvalue_cputime
410
411 7c08e6c4 K.Cima
key=cachehit
412 ca01c6e3 K.Shimadera
# buf_hitratio = 1 - physical_reads / ( db_block_gets + consistent_gets )
413
# lib_hitratio = 1 - reloads / pins
414 827c75fb K.Shimadera
# dict_hitratio = ( gets - misses ) / gets
415
field_info=$( for field in buf_physical buf_logical lib_pins lib_reloads dict_gets dict_getmisses
416
   do
417
       echo "${field}.graph no"
418
       echo "${field}.type DERIVE"
419
       echo "${field}.min 0"
420
       echo "${field}.label ${field}"
421
   done
422
)
423 7c08e6c4 K.Cima
global_attrs[$key]="
424
    graph_title Oracle Cache Hit Ratio
425
    graph_category db
426
    graph_args --base 1000 --lower-limit 0 --upper-limit 100 --rigid
427
    graph_vlabel %
428 ca01c6e3 K.Shimadera
    graph_info Oracle Cache Hit Ratio - The graph shows cache hit ratio between munin-update intervals (5 minutes in most cases).
429 7c08e6c4 K.Cima
    graph_scale no
430 ca01c6e3 K.Shimadera
431 827c75fb K.Shimadera
    ${field_info}
432 ca01c6e3 K.Shimadera
    buf_hitratio.cdef 100,1,buf_physical,buf_logical,/,-,*,FLOOR
433
    lib_hitratio.cdef 100,1,lib_reloads,lib_pins,/,-,*,FLOOR
434 827c75fb K.Shimadera
    dict_hitratio.cdef 100,dict_gets,dict_getmisses,-,dict_gets,/,*,FLOOR
435 7c08e6c4 K.Cima
"
436
data_attrs[$key]="
437 ca01c6e3 K.Shimadera
    buf_hitratio GAUGE LINE Buffer Cache Hit Ratio
438
    lib_hitratio GAUGE LINE Library Cache Hit Ratio
439 827c75fb K.Shimadera
    dict_hitratio GAUGE LINE Dictionary Cache Hit Ratio
440 7c08e6c4 K.Cima
"
441
getvalue_func[$key]=getvalue_cachehit
442
443
key=sessionuser
444
global_attrs[$key]="
445
    graph_title Oracle Session Users
446
    graph_category db
447
    graph_args --base 1000 --lower-limit 0 --rigid
448
    graph_vlabel count
449
    graph_info Oracle Session Users
450
"
451
data_attrs[$key]=""
452
getfield_func[$key]=getfield_sessionuser
453
getvalue_func[$key]=getvalue_sessionuser
454
455
key=sessionwait
456
global_attrs[$key]="
457
    graph_title Oracle Session Wait
458
    graph_category db
459
    graph_args --base 1000 --lower-limit 0 --rigid
460
    graph_vlabel count
461
    graph_info Oracle Session Wait
462
"
463
data_attrs[$key]=""
464
getfield_func[$key]=getfield_sessionwait
465
getvalue_func[$key]=getvalue_sessionwait
466
467
key=eventwait
468
global_attrs[$key]="
469
    graph_title Oracle Wait Events
470
    graph_category db
471
    graph_args --base 1000 --lower-limit 0 --rigid
472
    graph_vlabel microseconds
473 827c75fb K.Shimadera
    graph_info Oracle Wait Events - It may look wierd that Y-axis indicates 'microseconds per second'. Although number of times of wait event looks easier to understand, in many cases the number of events does not matter, but wait time become more important to analyze bottle necks.
474 7c08e6c4 K.Cima
"
475
data_attrs[$key]=""
476
getfield_func[$key]=getfield_eventwait
477
getvalue_func[$key]=getvalue_eventwait
478
479
key=eventwaitapplication
480
global_attrs[$key]="
481
    graph_title Oracle Wait Events Application
482
    graph_category db
483
    graph_args --base 1000 --lower-limit 0 --rigid
484
    graph_vlabel microseconds
485
    graph_info Oracle Wait Events Application
486
"
487
data_attrs[$key]=""
488 69f98e7f K.Cima
getfield_func[$key]="getfield_eventwait2 Application"
489
getvalue_func[$key]="getvalue_eventwait2 Application"
490 7c08e6c4 K.Cima
491 ca01c6e3 K.Shimadera
key=eventwaitnetwork
492
global_attrs[$key]="
493
    graph_title Oracle Wait Events Network
494
    graph_category db
495
    graph_args --base 1000 --lower-limit 0 --rigid
496
    graph_vlabel microseconds
497
    graph_info Oracle Wait Events Network
498
"
499
data_attrs[$key]=""
500
getfield_func[$key]="getfield_eventwait2 Network"
501
getvalue_func[$key]="getvalue_eventwait2 Network"
502
503 7c08e6c4 K.Cima
key=eventwaitconcurrency
504
global_attrs[$key]="
505
    graph_title Oracle Wait Events Concurrency
506
    graph_category db
507
    graph_args --base 1000 --lower-limit 0 --rigid
508
    graph_vlabel microseconds
509
    graph_info Oracle Wait Events Concurrency
510
"
511
data_attrs[$key]=" "
512 69f98e7f K.Cima
getfield_func[$key]="getfield_eventwait2 Concurrency"
513
getvalue_func[$key]="getvalue_eventwait2 Concurrency"
514 7c08e6c4 K.Cima
515
key=eventwaituserio
516
global_attrs[$key]="
517
    graph_title Oracle Wait Events User I/O
518
    graph_category db
519
    graph_args --base 1000 --lower-limit 0 --rigid
520
    graph_vlabel microseconds
521
    graph_info Oracle Wait Events User I/O
522
"
523
data_attrs[$key]=""
524 69f98e7f K.Cima
getfield_func[$key]="getfield_eventwait2 User I/O"
525
getvalue_func[$key]="getvalue_eventwait2 User I/O"
526 7c08e6c4 K.Cima
527
key=eventwaitsystemio
528
global_attrs[$key]="
529
    graph_title Oracle Wait Events System I/O
530
    graph_category db
531
    graph_args --base 1000 --lower-limit 0 --rigid
532
    graph_vlabel microseconds
533
    graph_info Oracle Wait Events System I/O
534
"
535
data_attrs[$key]="
536
"
537 69f98e7f K.Cima
getfield_func[$key]="getfield_eventwait2 System I/O"
538
getvalue_func[$key]="getvalue_eventwait2 System I/O"
539 7c08e6c4 K.Cima
540
key=eventwaitcluster
541
global_attrs[$key]="
542
    graph_title Oracle Wait Events Cluster
543
    graph_category db
544
    graph_args --base 1000 --lower-limit 0 --rigid
545
    graph_vlabel microseconds
546
    graph_info Oracle Wait Events Cluster
547
"
548
data_attrs[$key]=" "
549 69f98e7f K.Cima
getfield_func[$key]="getfield_eventwait2 Cluster"
550
getvalue_func[$key]="getvalue_eventwait2 Cluster"
551 7c08e6c4 K.Cima
552 ca01c6e3 K.Shimadera
key=eventwaitadministrative
553
global_attrs[$key]="
554
    graph_title Oracle Wait Events Administrative
555
    graph_category db
556
    graph_args --base 1000 --lower-limit 0 --rigid
557
    graph_vlabel microseconds
558
    graph_info Oracle Wait Events Administrative
559
"
560
data_attrs[$key]=" "
561
getfield_func[$key]="getfield_eventwait2 Administrative"
562
getvalue_func[$key]="getvalue_eventwait2 Administrative"
563
564
key=eventwaitconfiguration
565
global_attrs[$key]="
566
    graph_title Oracle Wait Events Configuration
567
    graph_category db
568
    graph_args --base 1000 --lower-limit 0 --rigid
569
    graph_vlabel microseconds
570
    graph_info Oracle Wait Events Configuration
571
"
572
data_attrs[$key]=" "
573
getfield_func[$key]="getfield_eventwait2 Configuration"
574
getvalue_func[$key]="getvalue_eventwait2 Configuration"
575
576 7c08e6c4 K.Cima
key=tablespace
577
global_attrs[$key]="
578
    graph_title Oracle Table Space Usage
579
    graph_category db
580
    graph_args --base 1000 --lower-limit 0 --upper-limit 100 --rigid
581
    graph_vlabel %
582
    graph_info Oracle Table Space Usage
583
    warning ${warning:=92}
584
    critical ${critical:=98}
585
"
586
data_attrs[$key]=""
587
getfield_func[$key]=getfield_tablespace
588
getvalue_func[$key]=getvalue_tablespace
589
590
key=asmusage
591
global_attrs[$key]="
592
    graph_title Oracle ASM Disk Group Usage
593
    graph_category db
594
    graph_args --base 1000 --lower-limit 0 --upper-limit 100 --rigid
595
    graph_vlabel %
596
    graph_info Oracle ASM Disk Group Usage
597
    warning ${warning:=92}
598
    critical ${critical:=98}
599
"
600
data_attrs[$key]=""
601
getfield_func[$key]=getfield_asmusage
602
getvalue_func[$key]=getvalue_asmusage
603
604
# End of Graph Settings
605
606
# sqlplus options
607 99e235ce K.Cima
: "${sqlplus:=sqlplus -S -L}"
608 7c08e6c4 K.Cima
sqlplus_variables="
609 ca01c6e3 K.Shimadera
    whenever sqlerror exit sql.sqlcode
610 7c08e6c4 K.Cima
    set pagesize 0
611
    set feed off
612
    set head off
613
    set linesize 256
614
    set numwidth 20
615
"
616
617
# functions 
618
619
autoconf() {
620 fe8908c3 K.Cima
    if [ -x "$( which "${sqlplus}" )" ]; then
621 7c08e6c4 K.Cima
        echo yes
622
    else
623
        echo "no (failed to find executable 'sqlplus')"
624
    fi
625
}
626
627
suggest() {
628 ca01c6e3 K.Shimadera
    # print hash keys as available module names
629 fe8908c3 K.Cima
    echo "${!global_attrs[@]}" | tr ' ' '\n' | sort
630 7c08e6c4 K.Cima
}
631
632
config() {
633 ca01c6e3 K.Shimadera
    local label_max_length=45
634
635 7c08e6c4 K.Cima
    # print global attributes
636
    sed -e 's/^  *//' -e '/^$/d' <<< "${global_attrs[$module]}"
637
638
    # print data source attributes
639 69f98e7f K.Cima
    # split line into field,type,draw,label 
640
    local fields field type draw label
641 827c75fb K.Shimadera
    fields=
642 69f98e7f K.Cima
    while read -r field type draw label
643 7c08e6c4 K.Cima
    do
644 827c75fb K.Shimadera
        [ -z "$field" ] && continue
645
        fields="${fields} ${field}"
646 ca01c6e3 K.Shimadera
647
        echo "${field}.type ${type}"
648
        echo "${field}.draw ${draw}"
649
        echo "${field}.label ${label:0:${label_max_length}}"
650
        if [ "${type}" = DERIVE ]; then
651
            echo "${field}.min 0"
652
        fi
653 7c08e6c4 K.Cima
    done <<< "${data_attrs[$module]}"
654
655 69f98e7f K.Cima
    echo graph_order "$fields"
656 7c08e6c4 K.Cima
}
657
658 289b99d4 K.Cima
# wrapper for getfield_*
659 7c08e6c4 K.Cima
getfield() {
660 69f98e7f K.Cima
    local func arg
661 7c08e6c4 K.Cima
    if [ -n "${getfield_func[$module]:-}" ]; then
662 69f98e7f K.Cima
        # call getfield_* function with argument if necessary
663
        read -r func arg <<< "${getfield_func[$module]}"
664
        $func "$arg"
665 7c08e6c4 K.Cima
    fi
666
}
667
668 289b99d4 K.Cima
# wrapper for getvalue_*
669 7c08e6c4 K.Cima
getvalue() {
670 69f98e7f K.Cima
    local func arg
671
    # call getvalue_* function with argument if necessary
672
    read -r func arg <<< "${getvalue_func[$module]}"
673
    $func "$arg"
674 7c08e6c4 K.Cima
}
675
676
getvalue_sysstat() {
677 69f98e7f K.Cima
    local field type draw label
678
    while read -r field type draw label
679 7c08e6c4 K.Cima
    do
680
        [ -z "$field" ] && continue
681
682 827c75fb K.Shimadera
        echo "${sqlplus_variables}
683
          VAR vf VARCHAR2(64)
684
          VAR vl VARCHAR2(64)
685
          EXEC :vf := '${field}' 
686
          EXEC :vl := '${label}' 
687
          SELECT
688
            :vf || '.value ' || value
689
          FROM
690
            v\$sysstat
691
          WHERE
692
            name = :vl;
693
        "
694 ca01c6e3 K.Shimadera
    done <<< "${data_attrs[$module]}" | ${sqlplus} "${oracle_auth}"
695 7c08e6c4 K.Cima
}
696
697
getvalue_sgainfo() {
698 69f98e7f K.Cima
    local field type draw label
699
    while read -r field type draw label
700 7c08e6c4 K.Cima
    do
701
        [ -z "$field" ] && continue
702
703 827c75fb K.Shimadera
        echo "${sqlplus_variables}
704
          VAR vf VARCHAR2(64)
705
          VAR vl VARCHAR2(64)
706
          EXEC :vf := '${field}' 
707
          EXEC :vl := '${label}' 
708
          SELECT
709
            :vf || '.value ' || bytes
710
          FROM
711
            v\$sgainfo
712
          WHERE
713
            name = :vl;
714
        "
715 ca01c6e3 K.Shimadera
    done <<< "${data_attrs[$module]}" | ${sqlplus} "${oracle_auth}"
716 7c08e6c4 K.Cima
}
717
718
getvalue_pgastat() {
719 69f98e7f K.Cima
    local field type draw label
720
    while read -r field type draw label
721 7c08e6c4 K.Cima
    do
722
        [ -z "$field" ] && continue
723
724 827c75fb K.Shimadera
        echo "${sqlplus_variables}
725
          VAR vf VARCHAR2(64)
726
          VAR vl VARCHAR2(64)
727
          EXEC :vf := '${field}' 
728
          EXEC :vl := '${label}' 
729
          SELECT
730
            :vf || '.value ' || value
731
          FROM
732
            v\$pgastat
733
          WHERE
734
            name = :vl;
735
        "
736 ca01c6e3 K.Shimadera
    done <<< "${data_attrs[$module]}" | ${sqlplus} "${oracle_auth}"
737 7c08e6c4 K.Cima
}
738
739 ca01c6e3 K.Shimadera
getvalue_cputime() {
740
    local field type draw label
741
    while read -r field type draw label
742
    do
743
        [ -z "$field" ] && continue
744
745 827c75fb K.Shimadera
        echo "${sqlplus_variables}
746
          VAR vf VARCHAR2(64)
747
          VAR vl VARCHAR2(64)
748
          EXEC :vf := '${field}' 
749
          EXEC :vl := '${label}' 
750
          SELECT
751
            :vf || '.value ' || ROUND( value / 1000000 )
752
          FROM
753
            v\$sys_time_model
754
          WHERE
755
            stat_name = :vl;
756
        "
757 ca01c6e3 K.Shimadera
    done <<< "${data_attrs[$module]}" | ${sqlplus} "${oracle_auth}"
758
}
759
760
getvalue_cachehit() {
761
    ${sqlplus} "${oracle_auth}" <<EOF
762
${sqlplus_variables}
763 7c08e6c4 K.Cima
SELECT
764 ca01c6e3 K.Shimadera
  'buf_physical.value ' || value
765 7c08e6c4 K.Cima
FROM
766 ca01c6e3 K.Shimadera
  v\$sysstat
767
WHERE
768
  name = 'physical reads cache'
769 7c08e6c4 K.Cima
;
770 ca01c6e3 K.Shimadera
SELECT 
771
  'buf_logical.value ' || ( sd.value + sc.value )
772
FROM 
773
  v\$sysstat sd, v\$sysstat sc 
774
WHERE 
775
  sd.name = 'db block gets from cache' AND sc.name = 'consistent gets from cache'
776 7c08e6c4 K.Cima
;
777 ca01c6e3 K.Shimadera
SELECT 'lib_pins.value '    || SUM(pins)    FROM v\$librarycache;
778
SELECT 'lib_reloads.value ' || SUM(reloads) FROM v\$librarycache;
779 827c75fb K.Shimadera
SELECT 'dict_gets.value '      || SUM(gets)      FROM v\$rowcache;
780
SELECT 'dict_getmisses.value ' || SUM(getmisses) FROM v\$rowcache;
781 7c08e6c4 K.Cima
EOF
782
}
783
784
getfield_sessionuser() {
785 ca01c6e3 K.Shimadera
    data_attrs[$module]=$( ${sqlplus} "${oracle_auth}" <<EOF
786 7c08e6c4 K.Cima
${sqlplus_variables}
787
SELECT
788
  REGEXP_REPLACE( username, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
789 69f98e7f K.Cima
  ' GAUGE LINE ' ||  username
790 7c08e6c4 K.Cima
FROM
791
  dba_users
792
WHERE
793
  account_status = 'OPEN'
794
ORDER BY
795
  username;
796
EOF
797 ca01c6e3 K.Shimadera
)
798 7c08e6c4 K.Cima
}
799
800
getvalue_sessionuser() {
801 99e235ce K.Cima
    ${sqlplus} "${oracle_auth}" <<EOF
802 7c08e6c4 K.Cima
${sqlplus_variables}
803
SELECT
804
  REGEXP_REPLACE( du.username, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || '.value ' ||
805
  count(vs.username)
806
FROM 
807
  ( SELECT
808
      username
809
    FROM
810
      dba_users
811
    WHERE
812
      account_status = 'OPEN'
813
  ) du
814
  LEFT JOIN v\$session vs
815
ON
816
  du.username = vs.username
817
GROUP BY
818
  du.username;
819
EOF
820
}
821
822
getfield_sessionwait() {
823 ca01c6e3 K.Shimadera
    data_attrs[$module]=$( ${sqlplus} "${oracle_auth}" <<EOF
824 7c08e6c4 K.Cima
${sqlplus_variables}
825 ca01c6e3 K.Shimadera
SELECT 'CPU GAUGE AREASTACK CPU' from dual;
826 7c08e6c4 K.Cima
SELECT
827
  REGEXP_REPLACE( wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
828 69f98e7f K.Cima
  ' GAUGE AREASTACK ' || wait_class
829 7c08e6c4 K.Cima
FROM
830
  v\$event_name
831
WHERE
832
  wait_class NOT IN ( 'Other', 'Idle' )
833
GROUP BY
834
  wait_class
835
ORDER BY
836
  wait_class;
837
SELECT 'Other GAUGE AREASTACK Other' from dual;
838
SELECT 'Idle  GAUGE AREASTACK Idle' from dual;
839
EOF
840 ca01c6e3 K.Shimadera
)
841 7c08e6c4 K.Cima
}
842
843
getvalue_sessionwait() {
844 99e235ce K.Cima
    ${sqlplus} "${oracle_auth}" <<EOF
845 7c08e6c4 K.Cima
${sqlplus_variables}
846
SELECT
847 ca01c6e3 K.Shimadera
  'CPU.value ' || count(wait_class)
848
FROM
849
  v\$session
850
WHERE
851
  wait_time != 0
852
;
853
SELECT
854 7c08e6c4 K.Cima
  REGEXP_REPLACE( en.wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || '.value ' ||
855
  count(se.wait_class)
856
FROM
857
  ( SELECT
858
      wait_class
859
    FROM
860
      v\$event_name
861
    GROUP BY
862
      wait_class
863
  ) en
864
  LEFT JOIN v\$session se
865
ON
866
  en.wait_class = se.wait_class AND 
867 ca01c6e3 K.Shimadera
  se.username is not null AND
868
  se.wait_time = 0
869 7c08e6c4 K.Cima
GROUP BY
870 ca01c6e3 K.Shimadera
  en.wait_class
871
;
872 7c08e6c4 K.Cima
EOF
873
}
874
875
getfield_eventwait() {
876 ca01c6e3 K.Shimadera
    data_attrs[$module]=$( ${sqlplus} "${oracle_auth}" <<EOF
877 7c08e6c4 K.Cima
${sqlplus_variables}
878
SELECT
879
  REGEXP_REPLACE( wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
880 69f98e7f K.Cima
  ' DERIVE LINE ' || wait_class
881 7c08e6c4 K.Cima
FROM
882
  v\$event_name
883
WHERE
884
  wait_class NOT IN ( 'Other', 'Idle' )
885
GROUP BY
886
  wait_class
887
ORDER BY
888
  wait_class;
889
SELECT 'Other DERIVE LINE Other' from dual;
890
EOF
891 ca01c6e3 K.Shimadera
)
892 7c08e6c4 K.Cima
}
893
894
getvalue_eventwait() {
895 99e235ce K.Cima
    ${sqlplus} "${oracle_auth}" <<EOF
896 7c08e6c4 K.Cima
${sqlplus_variables}
897
SELECT
898
  REGEXP_REPLACE( en.wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || '.value ' ||
899
  NVL( SUM(se.time_waited_micro), 0 )
900
FROM
901
  ( SELECT
902
      wait_class
903
    FROM
904
      v\$event_name
905
    WHERE
906 3e4a48ab K.Cima
      wait_class NOT IN ( 'Idle' )
907 7c08e6c4 K.Cima
    GROUP BY
908
      wait_class
909
  ) en
910
  LEFT JOIN v\$system_event se
911
ON
912
  en.wait_class = se.wait_class
913
GROUP BY
914 3e4a48ab K.Cima
  en.wait_class;
915 7c08e6c4 K.Cima
EOF
916
}
917
918
getfield_eventwait2() {
919
    local waitclass="$1"
920
921 ca01c6e3 K.Shimadera
    data_attrs[$module]=$( ${sqlplus} "${oracle_auth}" <<EOF
922 7c08e6c4 K.Cima
${sqlplus_variables}
923
VAR vl VARCHAR2(64)
924
EXEC :vl := '${waitclass}' 
925
SELECT
926
  REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
927 ca01c6e3 K.Shimadera
  ' DERIVE LINE ' || name
928 7c08e6c4 K.Cima
FROM
929
  v\$event_name 
930
WHERE
931
  wait_class = :vl
932
ORDER BY
933
  name;
934
EOF
935 ca01c6e3 K.Shimadera
)
936 7c08e6c4 K.Cima
}
937
938
getvalue_eventwait2() {
939
    local waitclass="$1"
940
941 99e235ce K.Cima
    ${sqlplus} "${oracle_auth}" <<EOF
942 7c08e6c4 K.Cima
${sqlplus_variables}
943
VAR vl VARCHAR2(64)
944
EXEC :vl := '${waitclass}' 
945
SELECT
946
  REGEXP_REPLACE( en.name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || '.value ' || 
947
  NVL( se.time_waited_micro, 0 )
948
FROM
949
  v\$event_name en LEFT JOIN v\$system_event se
950
ON
951
  en.name = se.event
952
WHERE
953
  en.wait_class = :vl;
954
EOF
955
}
956
957
getfield_tablespace() {
958 ca01c6e3 K.Shimadera
    data_attrs[$module]=$( ${sqlplus} "${oracle_auth}" <<EOF
959 7c08e6c4 K.Cima
${sqlplus_variables}
960
SELECT
961
  REGEXP_REPLACE( tablespace_name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
962 69f98e7f K.Cima
  ' GAUGE LINE ' || tablespace_name
963 7c08e6c4 K.Cima
FROM
964
  dba_data_files
965
ORDER BY
966
  tablespace_name;
967
EOF
968 ca01c6e3 K.Shimadera
)
969 7c08e6c4 K.Cima
}
970
971
getvalue_tablespace() {
972 99e235ce K.Cima
    ${sqlplus} "${oracle_auth}" <<EOF
973 7c08e6c4 K.Cima
${sqlplus_variables}
974
SELECT
975
  REGEXP_REPLACE( tablespace_name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || '.value ' ||
976
  ROUND( (total_bytes - free_total_bytes) / total_bytes * 100, 0 )
977
FROM
978
  ( SELECT
979
      tablespace_name,
980
      SUM(bytes) total_bytes
981
    FROM
982
      dba_data_files
983
    GROUP BY
984
      tablespace_name
985
  ),
986
  ( SELECT
987
      tablespace_name free_tablespace_name,
988
      SUM(bytes) free_total_bytes
989
    FROM
990
      dba_free_space
991
    GROUP BY
992
      tablespace_name
993
  )
994
WHERE
995
  tablespace_name = free_tablespace_name;
996
EOF
997
}
998
999
getfield_asmusage() {
1000 ca01c6e3 K.Shimadera
    data_attrs[$module]=$( ${sqlplus} "${oracle_auth}" <<EOF
1001 7c08e6c4 K.Cima
${sqlplus_variables}
1002
SELECT
1003
  REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
1004 69f98e7f K.Cima
  ' GAUGE LINE ' || name
1005 7c08e6c4 K.Cima
FROM
1006
  v\$asm_diskgroup
1007
ORDER BY
1008
  name;
1009
EOF
1010 ca01c6e3 K.Shimadera
)
1011 7c08e6c4 K.Cima
}
1012
1013
getvalue_asmusage() {
1014 99e235ce K.Cima
    ${sqlplus} "${oracle_auth}" <<EOF
1015 7c08e6c4 K.Cima
${sqlplus_variables}
1016
SELECT
1017
  REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || '.value ' ||
1018
  ROUND( ( total_mb - free_mb ) / total_mb * 100 )
1019
FROM
1020
  v\$asm_diskgroup
1021
ORDER BY
1022
  name;
1023
EOF
1024
}
1025
1026
# main
1027
case ${1:-} in
1028
autoconf)
1029
    autoconf
1030
    ;;
1031
suggest)
1032
    suggest
1033
    ;;
1034
config)
1035
    getfield
1036
    config
1037
    ;;
1038
*)
1039
    getvalue
1040
    ;;
1041
esac
1042
1043
exit 0