Skip to main content
Sumo Logic

Set Up Oracle Performance Metrics Script on Linux

This page has instructions for setting up the performance metrics script on Linux for the Oracle app.

The script was developed and tested on:

  • Ubuntu OS (16.04.3 LTS), Python (2.7.12), Oracle Database 11g Enterprise Edition Release - 64bit Production

About the performance metric script

The Sumo app for Oracle uses a Python script to query database tables to collect Oracle server performance metrics.

The script connects the database using a database user account, runs a set of example SQL queries, and prints the query results in JSON format to the console. The account credentials and SQL queries are specified in the script configuration file, oracle-perf-monitor.cfg.

The SQL queries, in the “[queries]”  section of the configuration file are provided as examples. You can add, modify, and remove queries, as desired. We recommend having the queries you plan to use reviewed by your DBA.

The database user that you use to run the SQL queries should have permission to access and query specific databases, tables and views. The table below shows the SQL commands to grant the required permissions for each query.

Query  SQL Command to Grant Permissions
For Queries 1 through 3 SQL> grant select on sys.v_$tablespace to <username>;
SQL> grant select on sys.dba_free_space to <username>;
SQL> grant select on sys.v_$datafile to <username>;
SQL> grant select on v_$sysstat to <username>;
For Query 4 SQL> grant select on sys.v_$session to <username>;
SQL> grant select on sys.v_$process to <username>;
For Queries 5 and 6 SQL> grant select on sys.v_$session_wait to <username>;
SQL> grant select on sys.dba_jobs to <username>;

Step 1. Check Linux version

Check the version of Linux currently running on your machine to ensure compatibility with the script. 

$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:    xenial

Step 2. Install Python 2.7.12 for Linux

In this step you install Python 2.7.12 for Linux.

  1. Install Python using the following command.
    sudo apt install python

  2. To check the Python version:
    python --version
    Python 2.7.12

  3. In this step, you install pip if it’s not already installed.

  1. To determine whether pip is installed, run this command:
    $ pip -V
    If pip is not installed, you’ll see this message:
    The program 'pip' is currently not installed.
  2. To install pip, run this command
    sudo apt install python-pip
  3. To verify the installation, run this command:
    $ pip -V
    You should see this message:
    pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

Step 3. Install Oracle Instant Client on Linux 64bit OS

  1. Download Oracle Instant Client for Linux from:

  2. Copy these files into your system, for example to the ~/Application/oracle folder:

  3. Install alien package. (Alien is a program that converts between the rpm, dpkg, stampede slp, and slackware tgz file formats. If you want to use a package from another distribution than the one you have installed on your system, you can use alien to convert it to your preferred package format and install it.)
    sudo apt-get install alien

  4. Install downloaded Oracle Instant Client RPM packages.
    sudo alien -i oracle-instantclient12.2-basic-
    sudo alien -i oracle-instantclient12.2-devel-
    sudo alien -i oracle-instantclient12.2-sqlplus-

  5. Install the libaio1 and libaio-dev packages if they are not already installed. Typically, in standard Ubuntu, the libaio1 and libaio-dev are not pre-installed. These packages are required to start Oracle Instant Client.
    sudo apt-get install libaio1 libaio-dev

  6. If Instant Client is the only Oracle software installed on your system, update the runtime link path, for example:
    sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > \
    sudo ldconfig

    Alternatively, set the LD_LIBRARY_PATH environment variable before running applications. For example:
    Export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
    The variable can optionally be added to configuration files such as ~/.bash_profile and to application configuration files such as /etc/sysconfig/httpd.

  7. Test the client
    sqlplus64 username/password@//databasehost:1521/sidvalue
    SQL*Plus: Release Production on Tue Mar 20 08:39:20 2018
    Copyright (c) 1982, 2016, Oracle.  All rights reserved.

    Connected to:
    Oracle Database 11g Enterprise Edition Release - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

  8. Run a sample SQL query to test the connection.

    SQL> select * from v$version ;

    Oracle Database 11g Enterprise Edition Release - 64bit Production
    PL/SQL Release - Production
    CORE    Production
    TNS for Linux: Version - Production
    NLSRTL Version - Production

Step 4. Set up cx_Oracle on Linux

In this step, you set up cx_Oracle, an open source Python interface to Oracle.

  1. Install cx_Oracle.
    sudo pip install cx_Oracle

  2. Check the cx_oracle version.
    $ pip list | grep cx-Oracle
    cx-Oracle (6.2.1)

Step 5. Set up performance metrics script

In this step you set up the performance metrics script.

  1. Download the Sumo Python performance metrics script and configuration files:
    oracle-perf-monitor.cfg ( (

  2. Copy into a folder, for example,  /home/ubuntu/Application/sumo_OracleDB_Scripts.

  3. Make the following updates to the script configuration file (oracle-perf-monitor.cfg). In the [dbLogin] section, supply values for each parameter:

  • oraUser= database user id             example myuser123
  • oraPassword= user password        example mypwd123
  • oraHost=server name                     example ip-101-25-17-22
  • oraPort=port number                      example 1521
  • oraInstance=oracle instance SID (SID_NAME)           example XE
  1. Test the script.
    $ python

Step 6. Configure the Script Source

In this step, you configure a script source for the performance script in Sumo.

  1. In Sumo Logic, go to Manage Data > Collection > Collection.

  2. Find the name of the installed collector to which you'd like to add a Source. Click Add... then choose Add Source from the pop-up menu.

  3. Select Script for the Source type. Collectors using version 19.245-4 and later do not allow Script Sources to run by default. To allow Script Sources you need to set the Collector parameter enableScriptSource in to true and restart the Collector.

    1. For Name enter any name you like, for instance Oracle Server Script
    2. The Description is optional.
    3. For Source Category, enter the desired category. It can be any value you like, for example: DB/Oracle/DBQueryScript
    4. For Frequency, select desired frequency, for instance 5 minutes
    5. For Specify a timeout for your command, select a value that is long enough that long-running queries can complete, for instance 30 seconds.
    6. For Command, select /usr/bin/python.
    7. For Script, enter a path to the script, for example:/home/ubuntu/Application/sumo_OracleDB_Scripts/
    8. For Working Directory, enter a dirctory, for example, 
    9. Click Save.