Projet

Général

Profil

Révision fa208cb6

IDfa208cb6f212370e7d9b3e5792b1f23a9e39f7cc
Parent b02ca514
Enfant edb7a1f9

Ajouté par K.Cima il y a plus de 8 ans

Improve oracle_sysstat

- Change to multi-graph plugin
- Add dirtyconfig
- Add config for multi-instance databases

Voir les différences:

plugins/oracle/oracle_sysstat
5 5

  
6 6
=head1 NAME
7 7

  
8
  oracle_sysstat_* - Munin plugin to monitor Oracle Statistics
8
  oracle_sysstat - Munin multi-graph plugin to monitor Oracle Statistics
9 9

  
10
  These modules are implemented:
10 11
    execute                 - To monitor Oracle Sysstat SQL Execute Count
11 12
    parse                   - To monitor Oracle Sysstat SQL Parse Count
12 13
    tablefetch              - To monitor Oracle Sysstat SQL Table Fetch Rows
......
42 43

  
43 44
=head1 CONFIGURATION
44 45

  
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
46
  Make symlink:
47
    cd /path/to/munin/etc/plugins
48
    ln -s /path/to/munin/lib/plugins/oracle_sysstat .
49
    ln -s /path/to/munin/lib/plugins/oracle_sysstat oracle_sysstat_asmusage # if necessary
52 50
    ...
53 51

  
54 52
  The following shows example settings for this plugin:
55 53

  
56
    [oracle_sysstat_*]
54
    [oracle_sysstat]
57 55
      user  oracle
56
      env.ORACLE_SID   ORCL
57
      env.ORACLE_HOME  /path/to/oracle/home
58 58
      env.oracle_auth  / as SYSDBA
59
      env.ORACLE_HOME  /path/to/oracle/product/version
60
      env.ORACLE_SID   SOMESID
61 59

  
62 60
    [oracle_sysstat_asmusage]
63 61
      user  grid
64
      env.oracle_auth  / as SYSASM
65
      env.ORACLE_HOME  /path/to/grid/home/version
66
      env.ORACLE_SID   SOMESID
62
      env.ORACLE_SID     +ASM
63
      env.ORACLE_HOME    /path/to/grid/home
64
      env.oracle_auth    / as SYSASM
65
      env.include_module asmusage
66
      env.plugin_name    oracle_sysstat
67

  
68
=head1 ENVIRONMENT VARIABLES
69

  
70
  env.ORACLE_SID:
71
    example:  env.ORACLE_SID  SOMESID
72
    default:  ORCL
73

  
74
  env.ORACLE_HOME:
75
    example:  env.ORACLE_HOME  /opt/oracle/...
76
    default:  Try to find from oratab file
77

  
78
  env.oracle_auth:
79
    example:  env.oracle_auth user/pass as SYSDBA
80
    default:  / as SYSDBA
81

  
82
  env.exclude_module:
83
    example:  env.exclude_module  asmusage tablespace
84
    default:  asmusage
85

  
86
    Module name(s) to exclude seperated by white-space.
87
    By default, asmusage module is excluded because another privilege 
88
    is necessary to connect ASM instance.
89

  
90
  env.include_module:
91
    example:  env.include_module  asmusage
92
    default:  none
93

  
94
    Module name(s) to include seperated by white-space.
95
    If both include_module and exclude_module are set, exclude will be 
96
    ignored.
97

  
98
  env.plugin_name: 
99
    example:  env.plugin_name  oracle_sysstat_2
100
    default:  program name (usually oracle_sysstat)
101

  
102
    Used for internal graph name. 
103
    It will be useful to monitor multi-instance databases.
104

  
105
  env.db_name: 
106
    example:  env.db_name  dbname
107
    default:  none
108

  
109
    Used for graph title. 
110
    It will be useful to monitor multi-instance databases.
67 111

  
68 112
=head1 NOTES
69 113

  
......
78 122

  
79 123
  GPLv2
80 124

  
81
=cut
125
=head1 MAGIC MARKERS
82 126

  
83
# Magic markers
84
#%# family=contrib
85
#%# capabilities=autoconf suggest
127
  #%# family=contrib
128
  #%# capabilities=autoconf
86 129

  
87
# Like perl 'use strict;' 
88
set -o nounset
130
=cut
89 131

  
90 132
# Include plugin.sh
91 133
. "${MUNIN_LIBDIR:-}/plugins/plugin.sh"
134
is_multigraph "$@"
92 135

  
93
# Environments
94
: "${ORACLE_HOME:=$( echo /opt/oracle/product/* )}"
95
: "${ORACLE_SID:=orcl}"
136
# Like perl 'use strict;' 
137
set -o nounset
138

  
139
# Global variables
140
: "${ORACLE_SID:=ORCL}"
141
: "${ORACLE_HOME:=$( cat /etc/oratab /var/opt/oracle/oratab \
142
    | awk -F: '$1 == "'$ORACLE_SID'" { print $2 }' 2>/dev/null )}"
96 143
: "${oracle_auth:=/ as SYSDBA}"
144
: "${exclude_module:=asmusage}"
145
: "${include_module:=}"
146
: "${plugin_name:=${0##*/}}"
147
[ -n "${db_name:=}" ] && db_name=" ($db_name)"
97 148

  
98 149
PATH=$PATH:$ORACLE_HOME/bin
99 150
export PATH ORACLE_HOME ORACLE_SID
100 151

  
101
# Module name
102
module=$( basename "$0" | sed -e 's/^.*_//' )
103

  
104 152
# Graph settings
105 153
declare -A global_attrs  # required
106 154
declare -A data_attrs    # required (format: field type draw label)
107 155
declare -A getfield_func # optional
108 156
declare -A getvalue_func # required
109 157

  
158
# Note: Bash 4 (or above) is required to use hash.
159

  
110 160
key=execute
111 161
global_attrs[$key]="
112
    graph_title Oracle Sysstat SQL Execute Count
162
    graph_title Oracle$db_name Sysstat SQL Execute Count
113 163
    graph_category db
114 164
    graph_args --base 1000 --lower-limit 0 --rigid
115 165
    graph_vlabel count per second
......
124 174

  
125 175
key=parse
126 176
global_attrs[$key]="
127
    graph_title Oracle Sysstat SQL Parse Count
177
    graph_title Oracle$db_name Sysstat SQL Parse Count
128 178
    graph_category db
129 179
    graph_args --base 1000 --lower-limit 0 --rigid
130 180
    graph_vlabel count per second
......
140 190

  
141 191
key=tablefetch
142 192
global_attrs[$key]="
143
    graph_title Oracle Sysstat SQL Table Fetch Rows
193
    graph_title Oracle$db_name Sysstat SQL Table Fetch Rows
144 194
    graph_category db
145 195
    graph_args --base 1000 --lower-limit 0 --rigid
146 196
    graph_vlabel count per second
......
155 205

  
156 206
key=tablescan
157 207
global_attrs[$key]="
158
    graph_title Oracle Sysstat SQL Table Scans
208
    graph_title Oracle$db_name Sysstat SQL Table Scans
159 209
    graph_category db
160 210
    graph_args --base 1000 --lower-limit 0 --rigid
161 211
    graph_vlabel count per second
......
169 219

  
170 220
key=transaction
171 221
global_attrs[$key]="
172
    graph_title Oracle Sysstat SQL Transactions
222
    graph_title Oracle$db_name Sysstat SQL Transactions
173 223
    graph_category db
174 224
    graph_args --base 1000 --lower-limit 0 --rigid
175 225
    graph_vlabel count per second
......
183 233

  
184 234
key=sort
185 235
global_attrs[$key]="
186
    graph_title Oracle Sysstat SQL Sorts
236
    graph_title Oracle$db_name Sysstat SQL Sorts
187 237
    graph_category db
188 238
    graph_args --base 1000 --lower-limit 0 --rigid
189 239
    graph_vlabel count per second
......
197 247

  
198 248
key=logon
199 249
global_attrs[$key]="
200
    graph_title Oracle Sysstat User Logons
250
    graph_title Oracle$db_name Sysstat User Logons
201 251
    graph_category db
202 252
    graph_args --base 1000 --lower-limit 0 --rigid
203 253
    graph_vlabel count per second
......
210 260

  
211 261
key=cursor
212 262
global_attrs[$key]="
213
    graph_title Oracle Sysstat User Opened Cursors
263
    graph_title Oracle$db_name Sysstat User Opened Cursors
214 264
    graph_category db
215 265
    graph_args --base 1000 --lower-limit 0 --rigid
216 266
    graph_vlabel count
......
223 273

  
224 274
key=enqueue
225 275
global_attrs[$key]="
226
    graph_title Oracle Sysstat Enqueues
276
    graph_title Oracle$db_name Sysstat Enqueues
227 277
    graph_category db
228 278
    graph_args --base 1000 --lower-limit 0 --rigid
229 279
    graph_vlabel count per second
......
241 291

  
242 292
key=redolog
243 293
global_attrs[$key]="
244
    graph_title Oracle Sysstat Redo Entries
294
    graph_title Oracle$db_name Sysstat Redo Entries
245 295
    graph_category db
246 296
    graph_args --base 1000 --lower-limit 0 --rigid
247 297
    graph_vlabel count per second
......
258 308

  
259 309
key=redosize
260 310
global_attrs[$key]="
261
    graph_title Oracle Sysstat Redo Size
311
    graph_title Oracle$db_name Sysstat Redo Size
262 312
    graph_category db
263 313
    graph_args --base 1024 --lower-limit 0 --rigid
264 314
    graph_vlabel bytes per second
......
272 322

  
273 323
key=physicaliops
274 324
global_attrs[$key]="
275
    graph_title Oracle Sysstat I/O Physical Requests
325
    graph_title Oracle$db_name Sysstat I/O Physical Requests
276 326
    graph_category db
277 327
    graph_args --base 1000 --lower-limit 0 --rigid
278 328
    graph_vlabel iops
......
290 340

  
291 341
key=physicalrw
292 342
global_attrs[$key]="
293
    graph_title Oracle Sysstat I/O Physical Bytes
343
    graph_title Oracle$db_name Sysstat I/O Physical Bytes
294 344
    graph_category db
295 345
    graph_args --base 1024 --lower-limit 0 --rigid
296 346
    graph_vlabel bytes per second
......
306 356

  
307 357
key=blockrw
308 358
global_attrs[$key]="
309
    graph_title Oracle Sysstat I/O Blocks
359
    graph_title Oracle$db_name Sysstat I/O Blocks
310 360
    graph_category db
311 361
    graph_args --base 1000 --lower-limit 0 --rigid
312 362
    graph_vlabel blocks per second
......
325 375

  
326 376
key=netrw
327 377
global_attrs[$key]="
328
    graph_title Oracle Sysstat I/O Network Bytes
378
    graph_title Oracle$db_name Sysstat I/O Network Bytes
329 379
    graph_category db
330 380
    graph_args --base 1024 --lower-limit 0 --rigid
331 381
    graph_vlabel bytes per second
......
341 391

  
342 392
key=sgainfo
343 393
global_attrs[$key]="
344
    graph_title Oracle Memory SGA
394
    graph_title Oracle$db_name Memory SGA
345 395
    graph_category db
346 396
    graph_args --base 1024 --lower-limit 0 --rigid
347 397
    graph_vlabel bytes
348 398
    graph_info Oracle Memory SGA
349 399
"
350 400
data_attrs[$key]="
351
    maximum_sga_size    GAUGE LINE      Maximum SGA Size
352 401
    fixed_sga_size      GAUGE AREASTACK Fixed SGA Size
353 402
    redo_buffers        GAUGE AREASTACK Redo Buffers
354 403
    shared_pool_size    GAUGE AREASTACK Shared Pool Size
......
358 407
    shared_io_pool_size GAUGE AREASTACK Shared IO Pool Size
359 408
    buffer_cache_size   GAUGE AREASTACK Buffer Cache Size
360 409
    in_memory_area_size GAUGE AREASTACK In-Memory Area Size
410
    maximum_sga_size    GAUGE LINE      Maximum SGA Size
361 411
"
362 412
getvalue_func[$key]=getvalue_sgainfo
363 413

  
364 414
key=pgastat
365 415
global_attrs[$key]="
366
    graph_title Oracle Memory PGA
416
    graph_title Oracle$db_name Memory PGA
367 417
    graph_category db
368 418
    graph_args --base 1024 --lower-limit 0 --rigid
369 419
    graph_vlabel bytes
370 420
    graph_info Oracle Memory PGA
371 421
"
372 422
data_attrs[$key]="
423
    pga_inuse        GAUGE AREA total PGA inuse
424
    pga_allocated    GAUGE LINE total PGA allocated
373 425
    pga_target       GAUGE LINE aggregate PGA target parameter
374 426
    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 427
"
378 428
getvalue_func[$key]=getvalue_pgastat
379 429

  
380 430
key=cputime
381 431
global_attrs[$key]="
382
    graph_title Oracle CPU Time
432
    graph_title Oracle$db_name CPU Time
383 433
    graph_category db
384 434
    graph_args --base 1000 --lower-limit 0 --rigid
385 435
    graph_vlabel seconds
......
421 471
   done
422 472
)
423 473
global_attrs[$key]="
424
    graph_title Oracle Cache Hit Ratio
474
    graph_title Oracle$db_name Cache Hit Ratio
425 475
    graph_category db
426 476
    graph_args --base 1000 --lower-limit 0 --upper-limit 100 --rigid
427 477
    graph_vlabel %
......
429 479
    graph_scale no
430 480

  
431 481
    ${field_info}
432
    buf_hitratio.cdef 100,1,buf_physical,buf_logical,/,-,*,FLOOR
433
    lib_hitratio.cdef 100,1,lib_reloads,lib_pins,/,-,*,FLOOR
434
    dict_hitratio.cdef 100,dict_gets,dict_getmisses,-,dict_gets,/,*,FLOOR
482
    buf_hitratio.cdef 100,1,buf_physical,buf_logical,/,-,*
483
    lib_hitratio.cdef 100,1,lib_reloads,lib_pins,/,-,*
484
    dict_hitratio.cdef 100,dict_gets,dict_getmisses,-,dict_gets,/,*
435 485
"
436 486
data_attrs[$key]="
437 487
    buf_hitratio GAUGE LINE Buffer Cache Hit Ratio
......
442 492

  
443 493
key=sessionuser
444 494
global_attrs[$key]="
445
    graph_title Oracle Session Users
495
    graph_title Oracle$db_name Session Users
446 496
    graph_category db
447 497
    graph_args --base 1000 --lower-limit 0 --rigid
448 498
    graph_vlabel count
......
454 504

  
455 505
key=sessionwait
456 506
global_attrs[$key]="
457
    graph_title Oracle Session Wait
507
    graph_title Oracle$db_name Session Wait
458 508
    graph_category db
459 509
    graph_args --base 1000 --lower-limit 0 --rigid
460 510
    graph_vlabel count
......
466 516

  
467 517
key=eventwait
468 518
global_attrs[$key]="
469
    graph_title Oracle Wait Events
519
    graph_title Oracle$db_name Wait Events
470 520
    graph_category db
471 521
    graph_args --base 1000 --lower-limit 0 --rigid
472 522
    graph_vlabel microseconds
......
478 528

  
479 529
key=eventwaitapplication
480 530
global_attrs[$key]="
481
    graph_title Oracle Wait Events Application
531
    graph_title Oracle$db_name Wait Events Application
482 532
    graph_category db
483 533
    graph_args --base 1000 --lower-limit 0 --rigid
484 534
    graph_vlabel microseconds
......
490 540

  
491 541
key=eventwaitnetwork
492 542
global_attrs[$key]="
493
    graph_title Oracle Wait Events Network
543
    graph_title Oracle$db_name Wait Events Network
494 544
    graph_category db
495 545
    graph_args --base 1000 --lower-limit 0 --rigid
496 546
    graph_vlabel microseconds
......
502 552

  
503 553
key=eventwaitconcurrency
504 554
global_attrs[$key]="
505
    graph_title Oracle Wait Events Concurrency
555
    graph_title Oracle$db_name Wait Events Concurrency
506 556
    graph_category db
507 557
    graph_args --base 1000 --lower-limit 0 --rigid
508 558
    graph_vlabel microseconds
......
514 564

  
515 565
key=eventwaituserio
516 566
global_attrs[$key]="
517
    graph_title Oracle Wait Events User I/O
567
    graph_title Oracle$db_name Wait Events User I/O
518 568
    graph_category db
519 569
    graph_args --base 1000 --lower-limit 0 --rigid
520 570
    graph_vlabel microseconds
......
526 576

  
527 577
key=eventwaitsystemio
528 578
global_attrs[$key]="
529
    graph_title Oracle Wait Events System I/O
579
    graph_title Oracle$db_name Wait Events System I/O
530 580
    graph_category db
531 581
    graph_args --base 1000 --lower-limit 0 --rigid
532 582
    graph_vlabel microseconds
......
539 589

  
540 590
key=eventwaitcluster
541 591
global_attrs[$key]="
542
    graph_title Oracle Wait Events Cluster
592
    graph_title Oracle$db_name Wait Events Cluster
543 593
    graph_category db
544 594
    graph_args --base 1000 --lower-limit 0 --rigid
545 595
    graph_vlabel microseconds
......
551 601

  
552 602
key=eventwaitadministrative
553 603
global_attrs[$key]="
554
    graph_title Oracle Wait Events Administrative
604
    graph_title Oracle$db_name Wait Events Administrative
555 605
    graph_category db
556 606
    graph_args --base 1000 --lower-limit 0 --rigid
557 607
    graph_vlabel microseconds
......
563 613

  
564 614
key=eventwaitconfiguration
565 615
global_attrs[$key]="
566
    graph_title Oracle Wait Events Configuration
616
    graph_title Oracle$db_name Wait Events Configuration
567 617
    graph_category db
568 618
    graph_args --base 1000 --lower-limit 0 --rigid
569 619
    graph_vlabel microseconds
......
575 625

  
576 626
key=tablespace
577 627
global_attrs[$key]="
578
    graph_title Oracle Table Space Usage
628
    graph_title Oracle$db_name Table Space Usage
579 629
    graph_category db
580 630
    graph_args --base 1000 --lower-limit 0 --upper-limit 100 --rigid
581 631
    graph_vlabel %
......
589 639

  
590 640
key=asmusage
591 641
global_attrs[$key]="
592
    graph_title Oracle ASM Disk Group Usage
642
    graph_title Oracle$db_name ASM Disk Group Usage
593 643
    graph_category db
594 644
    graph_args --base 1000 --lower-limit 0 --upper-limit 100 --rigid
595 645
    graph_vlabel %
......
611 661
    set feed off
612 662
    set head off
613 663
    set linesize 256
614
    set numwidth 20
664
    set numwidth 30
615 665
"
616 666

  
617
# functions 
667
# Functions 
618 668

  
619 669
autoconf() {
620 670
    if [ -x "$( which "${sqlplus}" )" ]; then
......
624 674
    fi
625 675
}
626 676

  
627
suggest() {
628
    # print hash keys as available module names
629
    echo "${!global_attrs[@]}" | tr ' ' '\n' | sort
677
config() {
678
    for module in $( module_list )
679
    do
680
        do_config
681
    done
682
}
683

  
684
fetch() {
685
    for module in $( module_list )
686
    do
687
        do_fetch
688
    done
630 689
}
631 690

  
632
config() {
691
do_config() {
633 692
    local label_max_length=45
634 693

  
694
    getfield
695
    echo "multigraph ${plugin_name}_${module}"
696

  
635 697
    # print global attributes
636 698
    sed -e 's/^  *//' -e '/^$/d' <<< "${global_attrs[$module]}"
637 699

  
......
653 715
    done <<< "${data_attrs[$module]}"
654 716

  
655 717
    echo graph_order "$fields"
718
    echo
719
}
720

  
721
do_fetch() {
722
    echo "multigraph ${plugin_name}_${module}"
723
    getvalue
724
    echo
725
}
726

  
727
module_list() {
728
    local i
729

  
730
    if [ -n "$include_module" ]; then
731
        echo "$include_module"
732
    else
733
        for i in $exclude_module
734
        do 
735
            # remove excluded modules
736
            unset -v "global_attrs[$i]"
737
        done
738

  
739
        # print hash keys as available module names
740
        echo "${!global_attrs[@]}"
741
    fi
656 742
}
657 743

  
658 744
# wrapper for getfield_*
......
778 864
SELECT 'lib_reloads.value ' || SUM(reloads) FROM v\$librarycache;
779 865
SELECT 'dict_gets.value '      || SUM(gets)      FROM v\$rowcache;
780 866
SELECT 'dict_getmisses.value ' || SUM(getmisses) FROM v\$rowcache;
867
SELECT 'buf_hitratio.value 0' FROM dual;
868
SELECT 'lib_hitratio.value 0' FROM dual;
869
SELECT 'dict_hitratio.value 0' FROM dual;
781 870
EOF
782 871
}
783 872

  
......
1023 1112
EOF
1024 1113
}
1025 1114

  
1026
# main
1115
# Main
1027 1116
case ${1:-} in
1028 1117
autoconf)
1029 1118
    autoconf
1030 1119
    ;;
1031
suggest)
1032
    suggest
1033
    ;;
1034 1120
config)
1035
    getfield
1036 1121
    config
1122
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
1037 1123
    ;;
1038 1124
*)
1039
    getvalue
1125
    fetch
1040 1126
    ;;
1041 1127
esac
1042 1128

  

Formats disponibles : Unified diff