Monitoring Oracle
Contents
|
Requisitos
Para monitorar o Oracle é necessário:
- criação de usuário e senha no Oracle;
- aplicar os GRANTS (create session, select any dictionary e select any table);
- arquivo tnsnames.ora com as configurações para conexão com as databases;
- caso seja utilizado, também é necessário o arquivo sqlnet.ora;
Procedimento
Para criar o usuário e senha no Oracle, e aplicar os GRANTS você pode executar no Oracle a sequência de comandos abaixo:
CREATE user opmon IDENTIFIED BY oradbmon;
GRANT CREATE session TO opmon;
GRANT SELECT any dictionary TO opmon;
GRANT SELECT any table TO opmon;
Ativando o Oracle no OpMon
Antes de continuar tenha em "mãos" o arquivo tnsnames.ora.
- Obs.: Caso o OpMon não tenha um DNS interno da rede, não utilize nomes (server-ora.com.br) no arquivo de tnsnames.ora.
Criar a seguinte arvore de diretórios e o arquivo sqlnet.ora, conforme abaixo:
- Obs.: Os seguintes comandos devem ser executados com usuário root
[otto@rocket ~]$ mkdir -p /usr/lib/oracle/11.1/client/network/admin
Utilizando um editor em modo texto, crie o seguinte arquivo abaixo:
[otto@rocket admin]$ cat sqlnet.ora NAMES.DIRECTORY_PATH=(TNSNAMES)
Em seguida copie o arquivo tnsnames.ora para o seguinte diretório: /usr/lib/oracle/11.1/client/network/admin
Testando acesso ao banco
Antes de continuar você precisa saber quais instances estão definidas no arquivo de tnsnames.ora, segue a dica: Abra o arquivo com um editor modo texto: Ex.: Vi/Vim Terá algo semelhante:
<NOME DA INSTANCE> =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = <ENDEREÇO IP>)(PORT = <PORTA>))
)
(CONNECT_DATA =
(SERVICE_NAME = <SERVICE NAME>)
)
)Para testar o acesso bastar utilizar um client oracle modo texto disponível no OpMon, segue:
[otto@rocket ~]$ sqlplus <username>/<password>@<instance>
Terá um retorno semelhante:
[otto@rocket ~]$ sqlplus <username>/<password>@<instance> SQL*Plus: Release 11.1.0.7.0 - Production on Wed Aug 3 15:12:41 2011 Copyright (c) 1982, 2008, Oracle. All rights reserved. Connected to: Oracle Database 10g Release 10.2.0.4.0 - 64bit Production SQL>
Utilizando o check_oracle_health
Para saber mais como funciona o plugin consulte o Help no OpMon ou via Shell (SSH).
[otto@rocket ~]$ /usr/local/opmon/libexec/check_oracle_health --help
Segue abaixo um exemplo de checagem com uma query onde retorna um resultado simples numérico:
[otto@rocket ~]$ /usr/local/opmon/libexec/check_oracle_health --connect=<NOME DA INSTANCE> --user=<USERNAME> --password=<PASSWORD> --mode=sql --name2="Usuarios connectados" --name='SELECT COUNT(*) FROM v$session WHERE type = 'USER'' --warning 90 --critical 95 OK - usuarios connectados: 0 | 'usuarios'=0;90;95
Abaixo uma lista de alguns serviços disponíveis para monitoração do Oracle
| tnsping | Check the reachability of the server |
| connection-time | Time to connect to the server |
| connected-users | Number of currently connected users |
| sga-data-buffer-hit-ratio | Data Buffer Cache Hit Ratio |
| sga-library-cache-hit-ratio | Library Cache Hit Ratio |
| sga-dictionary-cache-hit-ratio | Dictionary Cache Hit Ratio |
| sga-latches-hit-ratio | Latches Hit Ratio |
| sga-shared-pool-reload-ratio | Shared Pool Reloads vs. Pins |
| sga-shared-pool-free | Shared Pool Free Memory |
| pga-in-memory-sort-ratio | PGA in-memory sort ratio |
| invalid-objects | Number of invalid objects in database |
| stale-statistics | Find objects with stale optimizer statistics |
| tablespace-usage | Used space in tablespaces |
| tablespace-free | Free space in tablespaces |
| tablespace-remaining-time | Remaining time until a tablespace is full |
| tablespace-fragmentation | Free space fragmentation index |
| tablespace-io-balance | balanced io of all datafiles |
| tablespace-can-allocate-next | Segments (of a tablespace) can allocate next extent |
| datafile-io-traffic | io operations/per sec of a datafile |
| soft-parse-ratio | Percentage of soft parses |
| switch-interval | Time between redo log file switches |
| retry-ratio | Redo buffer allocation retries |
| redo-io-traffic | Redo log io bytes per second |
| roll-header-contention | Rollback segment header contention |
| roll-block-contention | Rollback segment block contention |
| roll-hit-ratio | Rollback segment hit ratio (gets/waits) |
| roll-wraps | Rollback segment wraps (per sec) |
| roll-extends | Rollback segment extends (per sec) |
| roll-avgactivesize | Rollback segment average active size |
| seg-top10-logical-reads | user objects among top 10 logical reads |
| seg-top10-physical-reads | user objects among top 10 physical reads |
| seg-top10-buffer-busy-waits | user objects among top 10 buffer busy waits |
| seg-top10-row-lock-waits | user objects among top 10 row lock waits |
| event-waits | processes wait events |
| event-waiting | time spent by processes waiting for an event |
| enqueue-contention | percentage of enqueue requests which must wait |
| enqueue-waiting | percentage of time spent waiting for the enqueue |
| latch-contention | percentage of latch get requests which must wait |
| latch-waiting | percentage of time a latch spends sleeping |
| sysstat | change of sysstat values over time |
| flash-recovery-area-usage | Used space in flash recovery area |
| flash-recovery-area-free | Free space in flash recovery area |
| sql | any sql command returning a single number |
| list-tablespaces | convenience function which lists all tablespaces |
| list-datafiles | convenience function which lists all datafiles |
| list-enqueues | convenience function which lists all enqueues |
| list-latches | convenience function which lists all latches |
| list-events | convenience function which lists all events |
| list-background-events | convenience function which lists all background events |
| list-sysstats | convenience function which lists all statistics from v$sysstat |

