Solved

How to get free disk space

Posted on 2007-12-06
3
1,331 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 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 73

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now