The Oracle Database Monitoring Tool is a utility designed to help database administrators (DBAs) and system administrators monitor and manage various aspects of an Oracle database. This tool supports multiple users, each monitoring their own set of Oracle databases, and provides insights into database health and performance.
The tool offers a range of monitoring capabilities, including:
- User Accounts: Secure registration and login for multiple users.
- Connection Management: Users can securely store and manage connection profiles for multiple Oracle databases. Oracle passwords are stored encrypted.
- SGA Monitoring: Track System Global Area (SGA) usage with graphical representation and alerts for high-consumption SQL.
- Tablespace Utilization: Monitor space usage, daily growth (average), and estimated remaining days for tablespaces, with charts.
- RMAN Backup Monitoring:
- View RMAN backup job history.
- Initiate RMAN backups (Full, Tablespace) through a secured mechanism using PL/SQL procedures.
- User SQL Monitoring: View SQL statements executed by database users.
- Logs Monitor: Check status of redo log groups, members, log mode, and average log switch time.
- Performance Dashboard:
- Key Performance Ratios (Buffer Cache Hit, Library Cache Hit, Dictionary Cache Hit, Latch Hit) with gauge charts.
- Call Rates (User Calls/sec, Commits/sec, Rollbacks/sec).
- Top N SQL Summary with bar chart (configurable metric and N).
- Top Sessions by Resource with bar chart and table (configurable resource and N).
- Active Session Monitoring: View currently active sessions in the selected Oracle database.
- System-Wide Wait Event Monitoring: Display top N non-idle system wait events by time waited and by number of waits, with charts and a table.
(The original deepwiki link may refer to an older, single-user version of this concept.)
This application is a PHP-based web tool that connects to Oracle databases. Here’s how to set it up:
Prerequisites:
- Web Server: A web server like Apache or Nginx with PHP support.
- PHP version 7.4 or higher recommended.
- Required PHP extensions:
pdo_sqlite(for the application's own user database).oci8(for connecting to Oracle databases).openssl(for encrypting/decrypting Oracle passwords).
- Oracle Instant Client (or full client): Must be installed on the server where the PHP application is hosted. Ensure its
PATHandLD_LIBRARY_PATH(on Linux) or systemPATH(on Windows) are configured correctly so PHP can find the OCI libraries. - Writable
app_datadirectory: The application needs to create an SQLite database file. Theapp_data/directory (in the project root) must be writable by the web server user. - Git: To clone the repository.
Installation Steps:
-
Clone the Repository:
git clone <repository_url> cd <repository_directory>
-
Configure Web Server:
- Point your web server's document root to the
Frontend/directory of the cloned repository. - Ensure appropriate permissions are set for the web server user to read files.
- For Apache, ensure
AllowOverride Allis set for the directory if using.htaccessfor security (e.g., to protectapp_data).
- Point your web server's document root to the
-
Initialize Application Database:
- The application uses an SQLite database to store user accounts and their encrypted Oracle database connection profiles.
- Run the initialization script from your server's command line:
php server/initialize_app_db.php
- This will create
app_data/monitoring_tool.sqliteand set up the necessary tables. - Security: Ensure the
app_data/directory and themonitoring_tool.sqlitefile are NOT directly accessible via the web. Theinitialize_app_db.phpscript attempts to create an.htaccessfile inapp_data/for Apache servers to deny direct access. Verify this or implement equivalent protection for your web server.
-
Configure Encryption Key:
- The application encrypts Oracle database passwords stored in its SQLite database. A secure encryption key is required.
- Rename
server/config.php.placeholdertoserver/config.php. - Edit
server/config.phpand set a strong, 32-byteENCRYPTION_KEY. You can generate one using:Place the non-base64 encoded 32-byte string in the// Run this PHP code snippet once to generate a key: // echo base64_encode(random_bytes(32));
define('ENCRYPTION_KEY', 'your-32-byte-secret-encryption-key');line. Alternatively, use the base64 encoded key withbase64_decode():define('ENCRYPTION_KEY', base64_decode('YOUR_BASE64_ENCODED_32_BYTE_KEY_HERE')); - CRITICAL: Protect
server/config.php. Do NOT commit it to version control if it contains the actual key. Ensure it's readable by the web server user but not publicly accessible. In a production cloud environment (like AWS), this key should be managed via a secrets manager (e.g., AWS Secrets Manager) and injected as an environment variable.
-
Prepare Target Oracle Databases:
- For each Oracle database you intend to monitor with this tool, you need to run the SQL scripts provided in
Database/Script.sql. - This script creates necessary PL/SQL functions, procedures, views, and one table (
job_SGA_Table) that the monitoring tool uses to query Oracle performance data. - Connect to your target Oracle database as a user with privileges to create these objects (e.g., a DBA account or a dedicated schema owner with appropriate grants).
- Execute all statements in
Database/Script.sql. - Note on Privileges: The Oracle user whose credentials will be used by the monitoring tool to connect to this target database needs
SELECTprivileges on theV$views,DBA_views, and other objects queried by the functions/views inScript.sql. It will also needEXECUTEprivileges on the created procedures (like RMAN backup procedures). For simplicity, the tool often assumes SYSDBA-like privileges for the monitoring connection, but a dedicated, less-privileged monitoring user is highly recommended for production use. You would need to grant specific privileges to such a user.
- For each Oracle database you intend to monitor with this tool, you need to run the SQL scripts provided in
-
Access the Application:
- Open your web browser and navigate to the URL where you've hosted the
Frontend/directory. You should see the application login page.
- Open your web browser and navigate to the URL where you've hosted the
-
Register an Application Account:
- Navigate to the application's main page (e.g.,
http://yourserver/path/to/Frontend/). - Click on "Create an Account" (or navigate to
register.php). - Fill in your desired username, email, and a strong password for the monitoring tool itself. This is NOT your Oracle database password.
- Click "Register".
- Navigate to the application's main page (e.g.,
-
Login to the Application:
- Go to the main page (
index.htmlorindex.php). - Enter the application username and password you just registered.
- Click "Login". You will be redirected to the Menu page.
- Go to the main page (
-
Manage Oracle Database Connection Profiles:
- On the Menu page, you'll see a link "Manage Connections" (usually in the bar at the top). Click it, or navigate directly to
manage_connections.php. - This page allows you to add connection profiles for each Oracle database you want to monitor.
- Add a Profile:
- Profile Name: A friendly name for your reference (e.g., "Production CRM DB", "Dev Test Instance").
- Hostname or IP Address: The server where your Oracle database is running.
- Port: The TNS listener port (usually 1521).
- Service Name (or SID): The service name or SID of your Oracle database.
- Oracle Username: The username for connecting to your Oracle database. This user needs the privileges mentioned in the "Prepare Target Oracle Databases" setup step.
- Oracle Password: The password for the Oracle username. This will be encrypted before being stored by the application.
- Click "Add Connection".
- You can add multiple profiles. They will be listed on this page. You can also delete profiles from here.
- On the Menu page, you'll see a link "Manage Connections" (usually in the bar at the top). Click it, or navigate directly to
-
Select Active Oracle Database for Monitoring:
- Go to the Menu page (
menu.php). - At the top, you'll see a dropdown labeled "Active Oracle DB:".
- Select one of your saved connection profiles from this dropdown.
- The "Currently Monitoring:" status will update. This selection is stored in your session and will be used by all monitoring pages.
- Go to the Menu page (
-
Use Monitoring Features:
- From the Menu page, click on any of the available monitoring sections (e.g., "SGA Monitor", "Tablespace", "Performance Dashboard", "RMAN", etc.).
- The data displayed will be fetched from the Oracle database profile you currently have selected as active.
- If no profile is selected, or if there's an issue connecting to the selected Oracle database, the monitoring pages will display an error message prompting you to select a valid profile.
-
Logout:
- When finished, click the "Logout" link (usually in the header on the Menu page or other pages) to securely end your application session.
This project includes PHPUnit tests for backend functionality.
Prerequisites for Testing:
- Composer: Ensure Composer is installed globally or available in your PHP environment.
- PHPUnit: Install project development dependencies, including PHPUnit, by running:
This command should be run in the root directory of the project (where
composer install
composer.jsonis located).
Test Configuration:
-
Encryption Key for Tests:
- The tests, especially those involving encryption or database interaction that might trigger encryption (like
ConnectionsHandlerTest), require an encryption key. - A placeholder environment variable
TEST_ENCRYPTION_KEYis defined inphpunit.xml.dist. - It is highly recommended to create a
phpunit.xmlfile (a copy ofphpunit.xml.dist) and set a specific, non-production 32-byte key forTEST_ENCRYPTION_KEYthere.phpunit.xmlis typically gitignored.<!-- phpunit.xml --> <php> <env name="TEST_ENCRYPTION_KEY" value="YourDedicated32ByteTestKey12345"/> </php>
- Alternatively, you can set this as an actual environment variable in your testing system.
- The
encryption_helper.phphas a development fallback key, but tests are more reliable if a specific test key is configured.
- The tests, especially those involving encryption or database interaction that might trigger encryption (like
-
Test Database (for Integration Tests):
- Integration tests (like
RegistrationHandlerTest,LoginHandlerTest,ConnectionsHandlerTest) are designed to run against an in-memory SQLite database to avoid affecting your development or production application database. - For these tests to correctly use the in-memory database, the
server/app_db_connection.phpscript needs to be aware of the testing environment. The tests attempt to use a global variable ($GLOBALS['TEST_PDO_OVERRIDE']) to inject the test PDO instance. This requires a modification toserver/app_db_connection.phpsimilar to this for the tests to fully work as intended with the database:// server/app_db_connection.php (modified for testability) function getAppDbConnection() { if (isset($GLOBALS['TEST_PDO_OVERRIDE']) && $GLOBALS['TEST_PDO_OVERRIDE'] instanceof \PDO) { return $GLOBALS['TEST_PDO_OVERRIDE']; } // ... original SQLite connection logic ... }
- Without this modification, the integration tests might attempt to use the actual
app_data/monitoring_tool.sqlitefile, which could lead to test failures or data contamination if not handled carefully. The current tests are written assuming they can control the PDO instance.
- Integration tests (like
Executing Tests:
- From the project root directory, run:
(This uses the script defined in
composer testcomposer.json) - Or directly using the PHPUnit executable (if in your PATH or from
vendor/bin):Or:./vendor/bin/phpunit
phpunit
Interpreting Test Results:
- PHPUnit will output the results of the tests, showing successes, failures, errors, and skipped tests.
- Skipped Tests: Some integration tests (for
RegistrationHandlerTestandLoginHandlerTest) are currently marked as skipped ($this->markTestSkipped(...)). This is because fully testing procedural scripts that involveheader()redirects andexit()calls directly within PHPUnit requires more advanced setup (like PHPUnit's@runInSeparateProcessannotation per test, or significant refactoring of those handler scripts into more testable units). The comments in those test files provide more details. TheConnectionsHandlerTestis more complete as it tests JSON API-like behavior.
Code Coverage (Optional):
- If you have Xdebug or PCOV installed and configured for PHP, you can generate a code coverage report. The
phpunit.xml.distis configured to include files from theserver/directory. - To generate an HTML coverage report, you might run:
The report will be generated in the
./vendor/bin/phpunit --coverage-html coverage-report
coverage-report/directory.
(Existing screenshots might be from an older version. New screenshots reflecting the multi-user interface and new features would be beneficial here.)

