Oracle database experiences

Oracle database blog

Plotting graph with SQL*Plus – Part IX

Horizontal bar graph

Up to now, we have seen how to display vertical graph. It is also possible to display horizontal graph using the RPAD function. You will find below a query that displays the history system metrics for the metric “Host CPU Utilization (%)”:

SELECT TO_CHAR(begin_time,'YYYY.MM.DD HH24:MI') begin_time
,      SUBSTR(RPAD('.',CEIL(value),'*'),2) h_graph
FROM v$sysmetric_history
WHERE metric_id = 2057
  AND group_id = 2
ORDER BY 1;

Result:

SQL> @horizontal_graph.sql
2014.02.25 05:45
2014.02.25 05:46
2014.02.25 05:47
2014.02.25 05:48
2014.02.25 05:49
2014.02.25 05:50
2014.02.25 05:51
2014.02.25 05:52 ********
2014.02.25 05:53 **
2014.02.25 05:54 **
2014.02.25 05:55 *******
2014.02.25 05:56 ********
2014.02.25 05:57 ****
2014.02.25 05:58 ***
2014.02.25 05:59 *
2014.02.25 06:00 **
2014.02.25 06:01 ***
2014.02.25 06:02 ***
2014.02.25 06:03 ***
2014.02.25 06:04 ***
2014.02.25 06:05 **
2014.02.25 06:06 *
2014.02.25 06:07 **
2014.02.25 06:08 **
2014.02.25 06:09 ********
2014.02.25 06:10 **********
2014.02.25 06:11 *********************
2014.02.25 06:12 ***********
2014.02.25 06:13 **
2014.02.25 06:14
2014.02.25 06:15
2014.02.25 06:16
2014.02.25 06:17 **
2014.02.25 06:18 *
2014.02.25 06:19
2014.02.25 06:20 **
2014.02.25 06:21 *****
2014.02.25 06:22 *************
2014.02.25 06:23 **
2014.02.25 06:24 **********
2014.02.25 06:25 *****
2014.02.25 06:26 *******
2014.02.25 06:28 *******
2014.02.25 06:29 ****
2014.02.25 06:31 ******
2014.02.25 06:32 *******************
2014.02.25 06:34 ********
2014.02.25 06:35 **********
2014.02.25 06:37 *******
2014.02.25 06:38 ****
2014.02.25 06:40 *****
2014.02.25 06:41 ******
2014.02.25 06:43 ******
2014.02.25 06:44 *****
2014.02.25 06:45 *
2014.02.25 06:46 *****
2014.02.25 06:47 *
2014.02.25 06:48 **
2014.02.25 06:49 **
2014.02.25 06:50 **
2014.02.25 06:51 *****

61 rows selected.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: