?
Solved

How to get free disk space

Posted on 2007-12-06
3
Medium Priority
?
1,373 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
3 Comments
 
LVL 27

Accepted Solution

by:
sujith80 earned 1000 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 1000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

864 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