# Data Guard monitoring

## dgcheck.ksh

This is an intelligent Oracle Data Guard monitoring script. Even if the Data Guard broker configuration is successful it warns in case the database Flash Recovery Area becomes busy, or if you forgot that restart the archive log shipping, apply process after an application upgrade and so on …

:information\_source: “dgcheck.ksh” supports several standby databases

The execution of dgcheck.ksh requires a configuration file, which contains the following parameters.

**The script requires command lines argument in addition to the configuration file. Some of the configuration file parameters are also available in command-line.**

**The parameters given in command line are from higher priority compared to their configuration values.**

Example:

* The default configuration parameter NoSuccessMail is set to 0. Which means each time the dgcheck.ksh script starts it sends the report mail even if the status is successful.

```
dgcheck.ksh –s ${ORACLE_SID}
```

* To receive the report only on case of errors launch the script as follows

```
dgcheck.ksh –s ${ORACLE_SID} –nosuccessmail
```

### Requirements

On the dgecheck host, the Oracle\*Net tnsnames.ora file shall contain the following entries:

* Primary database connection string
* Standby database connection string
* Application connection string

Starting with Oracle 11g it’s no more required to add the primary and standby database connection string to the host’s tnsnames.ora as dgcheck extracts and uses the connection string from Data Guard Broker database parameter “StaticConnectIdentifier”. This parameter replaces the Oracle 10g Data Guard Broker parameter “InitialConnectIdentifier” which refers only the tnsnames alias.

### parameters

A hyphen character prefixes the command line parameters as they are be used within a shell.

#### –h or –help

Display the Synopsis.

#### –f or –-ConfigFile

:information\_source:The dbi services best practice consist of saving the configuration file under the database admin directory which makes the command-line parameter “ConfigFile” useless

```
cp ${DMK_HA}/templates/dgcheck.cfg \\
	${DMK_ORA_ADMIN_SID}/etc/dgcheck.cfg
```

Otherwise the command-line parameter becomes mandatory

```
dgcheck.ksh –s ${ORACLE_SID} –c <path to the configuration file>
```

#### –s or --sid

```
#*************************************************************
# Commandline : --sid or -s
# You do not need to specify the ORACLE_SID of the Instance
# This SID is used in order to set the environment to the same
# Oracle binarie level, 11gR2 Data Guard - 11gR2 dgcheck Env
ORACLE_SID="<Oracle_Sid>"
```

#### –c or –-ConnectString

```
#*************************************************************
# Commandline : --connectstring or -c
# ConnectString [MANDATORY]
# This should be set to application TAF connect string
ConnectString="sys/<password@<ConnectString>"
```

#### –n or –-NoSucessMail

```
#*************************************************************
# Commandline : --nosuccessmail -n
# Default is : "0" -means the sucessmail will be sent
# "1" -mail sent by error
NoSuccessMail="0"
```

#### –ignore-flashback

Ignore warnings about the database flashback feature for the report and the mail. This command line argument is valid for the primary database and the standby database.

:warning:**dbi services recommend to enable the database flashback feature on the primary and standby database. (V$DATABASE.FLASHBACK\_ON = ON)**

#### –ignore-force-logging

Ignore warnings about the database force logging mode for the report and the mail. This command line argument is valid for the primary database and the standby database.

:warning:**dbi services strongly recommend to enable the database force logging. (V$DATABASE.FORCE\_LOGGING = YES)**

#### MailRecipients

```
#*************************************************************
# MailRecipients
# comma separated list of mail recipients
# Default is empty
MailRecipients=""
```

#### Customer

```
#*************************************************************
# Name/ShortName of the customer
# Default is : "dbi-services"
Customer=""
```

#### SmtpServer

```
#*************************************************************
# SmtpServer
# Infrastructure SMTP server
# Default is : "" - sendmail
SmtpServer=""
```

#### MailFrom

```
#*************************************************************
# MailFrom
# Hardcode address From sender
# Default is : "" - ${USERNAME}.${HOSTNAME}@${DOMAIN}
MailFrom=""
```

## Data Guard automatic Failover/Switchover alerting

You might already wonder why Oracle does not provide a feature to monitor and inform you that an automatic failover occurred. To fill this gap dbi services developed a PL/SQL framework which sends a mail each time the database role change.

Prior to the installation you should know:

* The ip or name of your SMTP server
* The list of mail recipients
* The sender mail address (depending on the Enterprise Mailing Policies)

Please read the README for details about the installation process and the required database privileges.

```
more ${DMK_HA}/sql/DG_roleChange_alerting/README.txt
```
