Solved

How to get free disk space

Posted on 2007-12-06
3
1,346 Views
Last Modified: 2013-12-19
It is possible to get the total space used by the database by 'select sum(bytes) from dba_segments' but is it poosible to get the total free disk size on the computer/disk where the database works by using a command to the database?
0
Comment
Question by:gyrosab
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
sujith80 earned 250 total points
ID: 20419020
>> by using a command to the database?
No, there is no direct way of communicating with the OS.
What you can do is: to have a C/Java stored procedure that runs your command and returns the results.
0
 

Author Comment

by:gyrosab
ID: 20419092
The thing is that the database is put on a networked computer/disk and the client is on another computer. I don't want to create any new communication stuff. I only want to use the database communication. What could I do?
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 250 total points
ID: 20419579
As sujith80 said, the db doesn't have that ability.  You have to use something external to the db.

You could create a unix cron job or windows scheduler or vms batch queue, etc  (depending on your OS) to perform an OS command and send the data to your db.

Or you can use a C external procedure to invoke an OS command  or you can use a java stored procedure.

Here's a simple example of the latter.
It will read execute a command (you have to grant access to that command) on the os and capture the standard output and standard error text and return it in a table collection of varchar2.


CREATE OR REPLACE TYPE VCARRAY AS TABLE OF VARCHAR2(4000)

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "Run_Cmd" as
import java.io.*;
import java.sql.*;
import java.util.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;

public class Run_Cmd{

    public static oracle.sql.ARRAY run_it(java.lang.String p_cmd)
    throws java.sql.SQLException,IOException
    {
        Runtime v_rt = Runtime.getRuntime();
        ArrayList v_output = new ArrayList();

       
        try
        {
            Process v_proc = v_rt.exec(p_cmd);
           
            BufferedReader v_stdout = new BufferedReader(
                                            new InputStreamReader(
                                                    v_proc.getInputStream()
                                                )
                                          );
            String v_line;
            while ((v_line = v_stdout.readLine()) != null)
                v_output.add(v_line);

            BufferedReader v_stderr = new BufferedReader(
                                            new InputStreamReader(
                                                    v_proc.getErrorStream()
                                                )
                                          );
            while ((v_line = v_stderr.readLine()) != null)
                v_output.add(v_line);
 
               
            v_proc.waitFor();    
           
        }

        catch (Exception e)
        {
            e.printStackTrace();            
        }

        Connection v_conn = new OracleDriver().defaultConnection();            
        ArrayDescriptor v_descriptor = ArrayDescriptor.createDescriptor( "VCARRAY", v_conn );            
        return new ARRAY( v_descriptor, v_conn, v_output.toArray() );
    }
}
/


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question