[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to get free disk space

Posted on 2007-12-06
3
Medium Priority
?
1,363 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 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

Independent Software Vendors: 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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

650 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