summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Hensman <richard@onevisionconsulting.co.uk>2012-07-19 20:44:44 (GMT)
committerJohn Mazzitelli <mazz@redhat.com>2012-08-06 18:59:57 (GMT)
commitb1867328cf3186d0c86a44b5296c1fbd1f48f1d8 (patch)
treec3414f52b756cce626e21a60aac30959f180f12b
parent9726761caf702f5a53f33ef2d957a84e55953196 (diff)
downloadrhq-b1867328cf3186d0c86a44b5296c1fbd1f48f1d8.zip
rhq-b1867328cf3186d0c86a44b5296c1fbd1f48f1d8.tar.gz
rhq-b1867328cf3186d0c86a44b5296c1fbd1f48f1d8.tar.xz
Add support for monitoring Flash Recovery Areas to the Oracle plugin
-rw-r--r--modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleFlashRecoveryAreaComponent.java83
-rw-r--r--modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml23
2 files changed, 103 insertions, 3 deletions
diff --git a/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleFlashRecoveryAreaComponent.java b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleFlashRecoveryAreaComponent.java
new file mode 100644
index 0000000..0446d7f
--- /dev/null
+++ b/modules/plugins/oracle/src/main/java/org/rhq/plugins/oracle/OracleFlashRecoveryAreaComponent.java
@@ -0,0 +1,83 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.oracle;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.util.jdbc.JDBCUtil;
+import org.rhq.plugins.database.AbstractDatabaseComponent;
+import org.rhq.plugins.database.DatabaseQueryUtility;
+
+/**
+ * Oracle Flash Recovery Area Component.
+ *
+ * @author Richard Hensman
+ */
+public class OracleFlashRecoveryAreaComponent extends AbstractDatabaseComponent implements MeasurementFacet {
+
+ private static final String SQL_AVAILABLE = "SELECT COUNT(*) FROM v$recovery_file_dest WHERE name = ?";
+ private static final String SQL_VALUES =
+ "SELECT space_limit spaceLimit, space_used spaceUsed, space_reclaimable spaceReclaimable, number_of_files numberOfFiles, (space_used/space_limit) usedPercent " +
+ "FROM v$recovery_file_dest WHERE name = ?";
+
+
+ private static Log log = LogFactory.getLog(OracleFlashRecoveryAreaComponent.class);
+
+ public AvailabilityType getAvailability() {
+ PreparedStatement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = getConnection().prepareStatement(SQL_AVAILABLE);
+ statement.setString(1, this.resourceContext.getResourceKey());
+ resultSet = statement.executeQuery();
+ if (resultSet.next() && (resultSet.getInt(1) == 1)) {
+ return AvailabilityType.UP;
+ }
+ } catch (SQLException e) {
+ log.debug("unable to query", e);
+ } finally {
+ JDBCUtil.safeClose(statement, resultSet);
+ }
+
+ return AvailabilityType.DOWN;
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+ Map<String, Double> values = DatabaseQueryUtility.getNumericQueryValues(this, SQL_VALUES,
+ this.resourceContext.getResourceKey());
+ for (MeasurementScheduleRequest request : metrics) {
+ Double d = values.get(request.getName().toUpperCase(Locale.US));
+ if (d != null) {
+ report.addData(new MeasurementDataNumeric(request, d));
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
index 8ef56cb..d8606e1 100644
--- a/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/oracle/src/main/resources/META-INF/rhq-plugin.xml
@@ -610,14 +610,31 @@
<c:simple-property name="description" default="Oracle Tablespace"/>
</plugin-configuration>
- <!-- Space used in the tablespace (database blocks) -->
<metric property="usedSpace" displayName="Used Space" description="Space used in the tablespace (database blocks)" displayType="summary"/>
- <!-- Total size of the tablespace (database blocks) -->
<metric property="totalSize" displayName="Total Size" description="Total size of the tablespace (database blocks)" displayType="summary"/>
- <!-- Percentage of the tablespace used -->
<metric property="usedPercent" displayName="Used Percent" description="Percentage of the tablespace used" displayType="summary" units="percentage"/>
</service>
+
+ <service name="Oracle Flash Recovery Areas"
+ discovery="org.rhq.plugins.database.CustomTableRowDiscoveryComponent"
+ class="org.rhq.plugins.oracle.OracleFlashRecoveryAreaComponent">
+
+ <plugin-configuration>
+ <c:simple-property name="table" default="V$RECOVERY_FILE_DEST"/>
+ <c:simple-property name="metricQuery" default="SELECT {key} FROM V$RECOVERY_FILE_DEST"/>
+ <c:simple-property name="keyColumn" default="name"/>
+ <c:simple-property name="name" default="{key}"/>
+ <c:simple-property name="description" default="Oracle Flash Recovery Areas"/>
+ </plugin-configuration>
+
+ <metric property="spaceLimit" displayName="Space Limit" description="Flash Recovery Area space limit (database blocks)" displayType="summary"/>
+ <metric property="spaceUsed" displayName="Space Used" description="Space used in the Flash Recovery Area (database blocks)" displayType="summary"/>
+ <metric property="spaceReclaimable" displayName="Space Reclaimable" description="Space reclaimable in the Flash Recovery Area (database blocks)" displayType="summary"/>
+ <metric property="numberOfFiles" displayName="Number Of Files" description="Number of files in the Flash Recovery Area" displayType="summary"/>
+ <metric property="usedPercent" displayName="Used Percent" description="Percentage of the Flash Recovery Area used" displayType="summary" units="percentage"/>
+
+ </service>
</server>