Skip to content

Commit

Permalink
Merge pull request #597 from ministryofjustice/DBA-598-ME
Browse files Browse the repository at this point in the history
Initial Version
  • Loading branch information
bill-buchan authored Mar 8, 2024
2 parents aaffa7d + b71ef0a commit eacf89a
Show file tree
Hide file tree
Showing 19 changed files with 700 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<TargetCollectionExt EXT_NAME="ME$ARCHIVELOG_DELETION_POLICY" EXT_VERSION="2" TARGET_TYPE="host"><CollectionItem NAME="ME$ARCHIVELOG_DELETION_POLICY" UPLOAD="YES">
<Schedule>
<IntervalSchedule INTERVAL="12" TIME_UNIT="Hr"/>
</Schedule>
<MetricColl NAME="ME$ARCHIVELOG_DELETION_POLICY">
<Condition COLUMN_NAME="OUTPUT_MESSAGE" CRITICAL="&#39;&#39;" OPERATOR="NE" OCCURRENCES="1" MESSAGE="%value%" CLEAR_MESSAGE="Archivelog Deletion Policy is OK"/>
</MetricColl>
</CollectionItem>
</TargetCollectionExt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<MetricExtensionArchive name="MEAME$ARCHIVELOG_DELETION_POLICY">
<MetricExtension name="ME$ARCHIVELOG_DELETION_POLICY" type="host" version="2" is_repos="FALSE" display_name="Archivelog Deletion Policy" description="Check RMAN Archivelog Deletion Policy does not include Backup if no Backups taken on host" version_comment=" " metadata_digest="e02e83e86137ecf892639eb0fcae241c" coll_digest="be21f123e5b495bb6b3d4c22422ebcdd" attach_digest="4d93b4d5572f2229f7ad0b9d850a87d8">
<scripts name="archivelog_deletion_policy_check.sh">
</scripts>
</MetricExtension>
</MetricExtensionArchive>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<TargetMetadataExt EXT_NAME="ME$ARCHIVELOG_DELETION_POLICY" EXT_VERSION="2" TARGET_TYPE="host"><Metric NAME="ME$ARCHIVELOG_DELETION_POLICY" TYPE="TABLE">
<Display>
<Label NLSID="NLS_METRIC_hostME$ARCHIVELOG_DELETION_POLICY">Archivelog Deletion Policy</Label>
<Description NLSID="NLS_DESCRIPTION_hostME$ARCHIVELOG_DELETION_POLICY">Check RMAN Archivelog Deletion Policy does not include Backup if no Backups taken on host</Description>
</Display>
<TableDescriptor>
<ColumnDescriptor NAME="OUTPUT_MESSAGE" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$ARCHIVELOG_DELETION_POLICYOUTPUT_MESSAGE">Output Message</Label>
</Display>
<CategoryValue CLASS="Default" CATEGORY_NAME="Fault">
</CategoryValue>
</ColumnDescriptor>
</TableDescriptor>
<QueryDescriptor FETCHLET_ID="OSLineToken">
<Property NAME="command" SCOPE="GLOBAL">/bin/bash</Property>
<Property NAME="script" SCOPE="GLOBAL" OPTIONAL="TRUE">%scriptsDir%/archivelog_deletion_policy_check.sh</Property>
<Property NAME="scriptLoc" SCOPE="GLOBAL" OPTIONAL="TRUE">%scriptsDir%</Property>
<Property NAME="delimiter" SCOPE="GLOBAL" OPTIONAL="TRUE">|</Property>
<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE" OPTIONAL="TRUE">NAME</Property>
<CredentialRef NAME="OSCreds"></CredentialRef>
</QueryDescriptor>
</Metric>
</TargetMetadataExt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
#
# Check that RMAN Policy does not require archivelogs to be backed up on
# instance where backups are not being run.
#

# When the agent runs on engineering hosts the open file limit is set by the root user at boot time
# (unless agent is restarted manually), so the process limit may be less than that specified in .bash_profile.
# Check if this is the case and override the process limit if required to prevent an error being thrown.
PROC_HARD_LIMIT=$(ulimit -Hn)
PROFILE_PROC_LIMIT=$(grep -E "ulimit.*-u.*-n" ~/.bash_profile | sed -r 's/.*-n ([[:digit:]]+).*/\1/')

if [[ ${PROFILE_PROC_LIMIT} -gt ${PROC_HARD_LIMIT} ]];
then
source <(sed -r "s/ulimit -u ([[:digit:]]+) -n ([[:digit:]]+)/ulimit -u \1 -n ${PROC_HARD_LIMIT}/" ~/.bash_profile)
else
. ~/.bash_profile
fi

# Check if Archivelog Deletion Policy requires a backup
if [[ $(echo "show archivelog deletion policy;" | rman target / | grep -E "ARCHIVELOG DELETION POLICY.*BACKED UP.*") ]];
then
if [[ $(echo "list backup summary completed after \"SYSDATE-7\";" | rman target / | grep "specification does not match any backup in the repository") ]];
then
echo "Archivelog deletion policy requires backups but no backups taken in the last 7 days"
fi
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<TargetCollectionExt EXT_NAME="ME$ALFRESCO_CONNECTIVITY" EXT_VERSION="2" TARGET_TYPE="host"><CollectionItem NAME="ME$ALFRESCO_CONNECTIVITY" UPLOAD="YES">
<Schedule>
<IntervalSchedule INTERVAL="15" TIME_UNIT="Min"/>
</Schedule>
<MetricColl NAME="ME$ALFRESCO_CONNECTIVITY">
<Condition COLUMN_NAME="CONNECTIVITY_STATUS" CRITICAL="SUCCESS" OPERATOR="NE" OCCURRENCES="1" MESSAGE="Alfresco connectivity has failed %CONNECTIVITY_MESSAGE%" CLEAR_MESSAGE="Alfresco connectivity status is %value%"/>
</MetricColl>
</CollectionItem>
</TargetCollectionExt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<MetricExtensionArchive name="MEAME$ALFRESCO_CONNECTIVITY">
<MetricExtension name="ME$ALFRESCO_CONNECTIVITY" type="host" version="2" is_repos="FALSE" display_name="Alfresco Connectivity" description="Check Connectivity to Alfresco from Within Database" version_comment=" " metadata_digest="723131db77e63673a3c6f10b1121791b" coll_digest="e4fc06bf01e443162c26f6f31d0cf545" attach_digest="f1475414870f8d1e232923de5159d67d">
<scripts name="alfresco_connectivity.sh">
</scripts>
</MetricExtension>
</MetricExtensionArchive>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<TargetMetadataExt EXT_NAME="ME$ALFRESCO_CONNECTIVITY" EXT_VERSION="2" TARGET_TYPE="host"><Metric NAME="ME$ALFRESCO_CONNECTIVITY" TYPE="TABLE">
<Display>
<Label NLSID="NLS_METRIC_hostME$ALFRESCO_CONNECTIVITY">Alfresco Connectivity</Label>
<Description NLSID="NLS_DESCRIPTION_hostME$ALFRESCO_CONNECTIVITY">Check Connectivity to Alfresco from Within Database</Description>
</Display>
<TableDescriptor>
<ColumnDescriptor NAME="CONNECTIVITY_STATUS" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$ALFRESCO_CONNECTIVITYCONNECTIVITY_STATUS">Connectivity Status</Label>
</Display>
<CategoryValue CLASS="Default" CATEGORY_NAME="Response">
</CategoryValue>
</ColumnDescriptor>
<ColumnDescriptor NAME="CONNECTIVITY_MESSAGE" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$ALFRESCO_CONNECTIVITYCONNECTIVITY_MESSAGE">Connectivity Message</Label>
</Display>
<CategoryValue CLASS="Default" CATEGORY_NAME="Response">
</CategoryValue>
</ColumnDescriptor>
</TableDescriptor>
<QueryDescriptor FETCHLET_ID="OSLineToken">
<Property NAME="command" SCOPE="GLOBAL">/bin/bash</Property>
<Property NAME="script" SCOPE="GLOBAL" OPTIONAL="TRUE">%scriptsDir%/alfresco_connectivity.sh</Property>
<Property NAME="scriptLoc" SCOPE="GLOBAL" OPTIONAL="TRUE">%scriptsDir%</Property>
<Property NAME="delimiter" SCOPE="GLOBAL" OPTIONAL="TRUE">|</Property>
<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE" OPTIONAL="TRUE">NAME</Property>
<CredentialRef NAME="OSCreds"></CredentialRef>
</QueryDescriptor>
</Metric>
</TargetMetadataExt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
#
# Although Alfresco availability is monitored directly, there may be reasons that the database
# itself cannot connect - for example incorrect wallet location or contents, or blocking access
# control list. This ME checks that the database can at least connect to Alfresco although it
# does not make any attempt to retrieve valid data.

. ~/.bash_profile

sqlplus -s / as sysdba <<EOF
WHENEVER SQLERROR EXIT FAILURE;
SET FEEDBACK OFF
SET HEADING OFF
SET SERVEROUT ON
SET NEWPAGE 0
SET PAGESIZE 0
SET LINES 2000
ALTER SESSION SET CURRENT_SCHEMA=delius_app_schema;
SET SERVEROUT ON
DECLARE
l_url spg_control.value_string%TYPE;
l_wallet_location spg_control.value_string%TYPE;
l_http_request utl_http.req;
l_http_response utl_http.resp;
l_text VARCHAR2(32767);
BEGIN
SELECT
value_string
INTO l_wallet_location
FROM
spg_control
WHERE
control_code = 'ALFWALLET';
utl_http.set_wallet(l_wallet_location, NULL);
SELECT
value_string
INTO l_url
FROM
spg_control
WHERE
control_code = 'ALFURL';
-- Make a HTTP request and get the response.
l_http_request := utl_http.begin_request(l_url);
l_http_response := utl_http.get_response(l_http_request);
utl_http.end_response(l_http_response);
-- If we get here then connectivity is available
-- (We are only checking connectivity - not fetching a valid web
-- page so a response code of 404 is valid).
dbms_output.put_line('SUCCESS|HTTP Response Code: ' || l_http_response.status_code);
EXCEPTION
WHEN OTHERS THEN
utl_http.end_response(l_http_response);
dbms_output.put_line(SUBSTR(translate('FAIL|' || dbms_utility.format_error_stack, '|'
|| chr(10)
|| chr(13), '| '),1,1000));
END;
/
EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<TargetCollectionExt EXT_NAME="ME$AUDITED_INTERACTION_CHECKSUM_VALIDATION" EXT_VERSION="1" TARGET_TYPE="host"><CollectionItem NAME="ME$AUDITED_INTERACTION_CHECKSUM_VALIDATION" UPLOAD="YES">
<Schedule>
<IntervalSchedule INTERVAL="4" TIME_UNIT="Hr"/>
</Schedule>
<MetricColl NAME="ME$AUDITED_INTERACTION_CHECKSUM_VALIDATION">
<Condition COLUMN_NAME="RANGE_END_DAYS_AGO" CRITICAL="4" OPERATOR="GT" OCCURRENCES="1" MESSAGE="No validated audit data for %keyValue% database for over %value% days." CLEAR_MESSAGE="Validated audit data for %keyValue% database found."/>
<Condition COLUMN_NAME="CHECKSUM_VALIDATION_STATUS" CRITICAL="Y" OPERATOR="NE" OCCURRENCES="1" MESSAGE="An error has been found validating the checksum for the %keyValue% database." CLEAR_MESSAGE="Alert for %columnName% for %keyValue% is cleared" CLEAR_MESSAGE_NLSID="EMAGENT_DEFAULT_NO_ROW_CLEAR_MESSAGE_WITH_KEY"/>
<Condition COLUMN_NAME="RANGE_DISCONTINUITY" CRITICAL="0" OPERATOR="GT" OCCURRENCES="1" MESSAGE="A gap has been found in the audited interaction checksum validation range for the %keyValue% database." CLEAR_MESSAGE="Alert for %columnName% for %keyValue% is cleared" CLEAR_MESSAGE_NLSID="EMAGENT_DEFAULT_NO_ROW_CLEAR_MESSAGE_WITH_KEY"/>
</MetricColl>
</CollectionItem>
</TargetCollectionExt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<MetricExtensionArchive name="MEAME$AUDITED_INTERACTION_CHECKSUM_VALIDATION">
<MetricExtension name="ME$AUDITED_INTERACTION_CHECKSUM_VALIDATION" type="host" version="1" is_repos="FALSE" display_name="Audited Interaction Checksum Validation" description="Audited Interaction Data Repository Checksum Validation" version_comment=" " metadata_digest="364481e02b9f6d2f7b15fff6f26aa905" coll_digest="684ff77783d1f74b373b22e9ecf2b473" attach_digest="923628a4d267d3606d318d6bd511ab18">
<scripts name="checksum_validation.sh">
</scripts>
</MetricExtension>
</MetricExtensionArchive>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<TargetMetadataExt EXT_NAME="ME$AUDITED_INTERACTION_CHECKSUM_VALIDATION" EXT_VERSION="1" TARGET_TYPE="host"><Metric NAME="ME$AUDITED_INTERACTION_CHECKSUM_VALIDATION" TYPE="TABLE">
<Display>
<Label NLSID="NLS_METRIC_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATION">Audited Interaction Checksum Validation</Label>
<Description NLSID="NLS_DESCRIPTION_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATION">Audited Interaction Data Repository Checksum Validation</Description>
</Display>
<TableDescriptor>
<ColumnDescriptor NAME="CLIENT_DB" TYPE="STRING" IS_KEY="TRUE">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONCLIENT_DB">Client Database</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="RESETLOGS_DATE_TIME" TYPE="STRING" IS_KEY="TRUE">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONRESETLOGS_DATE_TIME">Resetlogs Date Time</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="RANGE_START_DATE_TIME" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONRANGE_START_DATE_TIME">Range Start Date Time</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="RANGE_END_DATE_TIME" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONRANGE_END_DATE_TIME">Range End Date Time</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="RANGE_START_DAYS_AGO" TYPE="NUMBER">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONRANGE_START_DAYS_AGO">Range Start Days Ago</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="RANGE_END_DAYS_AGO" TYPE="NUMBER">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONRANGE_END_DAYS_AGO">Range End Days Ago</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="ROW_COUNT" TYPE="NUMBER">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONROW_COUNT">Audited Interaction Rows Added</Label>
</Display>
<CategoryValue CLASS="Default" CATEGORY_NAME="Capacity">
</CategoryValue>
</ColumnDescriptor>
<ColumnDescriptor NAME="DATA_CHECKSUM" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONDATA_CHECKSUM">Data Checksum Value</Label>
</Display>
</ColumnDescriptor>
<ColumnDescriptor NAME="CHECKSUM_VALIDATION_STATUS" TYPE="STRING">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONCHECKSUM_VALIDATION_STATUS">Checksum Validation Status</Label>
</Display>
<CategoryValue CLASS="Default" CATEGORY_NAME="Fault">
</CategoryValue>
</ColumnDescriptor>
<ColumnDescriptor NAME="RANGE_DISCONTINUITY" TYPE="NUMBER">
<Display>
<Label NLSID="NLS_COLUMN_hostME$AUDITED_INTERACTION_CHECKSUM_VALIDATIONRANGE_DISCONTINUITY">Range Discontinuity</Label>
</Display>
<CategoryValue CLASS="Default" CATEGORY_NAME="Fault">
</CategoryValue>
</ColumnDescriptor>
</TableDescriptor>
<QueryDescriptor FETCHLET_ID="OSLineToken">
<Property NAME="command" SCOPE="GLOBAL">/bin/bash</Property>
<Property NAME="script" SCOPE="GLOBAL" OPTIONAL="TRUE">%scriptsDir%/checksum_validation.sh</Property>
<Property NAME="scriptLoc" SCOPE="GLOBAL" OPTIONAL="TRUE">%scriptsDir%</Property>
<Property NAME="delimiter" SCOPE="GLOBAL" OPTIONAL="TRUE">|</Property>
<Property NAME="ENVEM_TARGET_NAME" SCOPE="INSTANCE" OPTIONAL="TRUE">NAME</Property>
<CredentialRef NAME="OSCreds"></CredentialRef>
</QueryDescriptor>
</Metric>
</TargetMetadataExt>
Loading

0 comments on commit eacf89a

Please sign in to comment.