LOAD LINUX HPUX disk space info through ORACLE external table into SQL SERVER TABLE
I have exported all my Windows Disk info from SQL server views into my Metrics database, so that I can expect the disk growth and check if disk is going to full in how many days. (will introduce next time). But for my 10 oracle physical servers, I manually collect to Excel and import to SQL table, present in SSRS report. This is time consuming. Today I have create on external table in ORACLE and made it happen automatically, same like my other SQL night DBA, ORACLE night DBA (backup alert) etc. my Oracle servers on a few HP UX servers and a few LINUX servers, except some part (I listed two), most are same for both systems.
Thanks to https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5088536900346242095
----create directory
>mkdir -p /home/oracle/diskspace
--create run_df.sh
>
[9004] $ vi .bashrc
export PATH=$PATH:/home/oracle/diskspace
[9005] $ source .bashrc
[9007] $ vi run_df.sh
1 #!/bin/sh
2
3 /bin/df -kP
~
oracle@hpux:/home/oracle/diskspace> cat run_df.sh
#!/usr/bin/sh
/usr/bin/df -kP
or
/home/oracle/diskspace/run_df.sh
[2546] $ cat run_df.sh
#!/bin/sh
/bin/df
-----add x
oracle@hpux:/home/oracle/diskspace> chmod +x run_df.sh
oracle@hpux:/home/oracle/diskspace> run_df.sh
----create directory
create or replace directory EXEC_DIR as '/home/oracle/diskspace';
---grant permission to
grant read,write,execute on directory exec_dir to DBAREPORTER;
----create table
CREATE TABLE df
(
"FILESYSTEM" VARCHAR2(200),
"BLOCKS" NUMBER,
"USED" NUMBER,
"AVAILABLE" NUMBER,
"CAPACITY" VARCHAR2(10),
"MOUNT" VARCHAR2(100)
)
ORGANIZATION external
(
TYPE oracle_loader
DEFAULT DIRECTORY exec_dir
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCII
preprocessor exec_dir:'run_df.sh'
READSIZE 1048576
SKIP 1
FIELDS TERMINATED BY WHITESPACE LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
(
"FILESYSTEM" CHAR(255)
TERMINATED BY WHITESPACE,
"BLOCKS" CHAR(255)
TERMINATED BY WHITESPACE,
"USED" CHAR(255)
TERMINATED BY WHITESPACE,
"AVAILABLE" CHAR(255)
TERMINATED BY WHITESPACE,
"CAPACITY" CHAR(255)
TERMINATED BY WHITESPACE,
"MOUNT" CHAR(255)
TERMINATED BY WHITESPACE
)
)
location
(
exec_dir:'run_df.sh')
)
;
alter table df reject limit unlimited;
SQL> grant select on sys.df to DBAREPORTER;
--test
SELECT b.host_name,b.instance_name,TO_CHAR(SYSDATE, 'MM-DD-YYYY HH24:MI:SS') as Today, a.* from sys.df a, (select host_name,instance_name from v$instance) b ;
---------
I have exported all my Windows Disk info from SQL server views into my Metrics database, so that I can expect the disk growth and check if disk is going to full in how many days. (will introduce next time). But for my 10 oracle physical servers, I manually collect to Excel and import to SQL table, present in SSRS report. This is time consuming. Today I have create on external table in ORACLE and made it happen automatically, same like my other SQL night DBA, ORACLE night DBA (backup alert) etc. my Oracle servers on a few HP UX servers and a few LINUX servers, except some part (I listed two), most are same for both systems.
Thanks to https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5088536900346242095
----create directory
>mkdir -p /home/oracle/diskspace
--create run_df.sh
>
[9004] $ vi .bashrc
export PATH=$PATH:/home/oracle/diskspace
[9005] $ source .bashrc
[9007] $ vi run_df.sh
1 #!/bin/sh
2
3 /bin/df -kP
~
oracle@hpux:/home/oracle/diskspace> cat run_df.sh
#!/usr/bin/sh
/usr/bin/df -kP
or
/home/oracle/diskspace/run_df.sh
[2546] $ cat run_df.sh
#!/bin/sh
/bin/df
-----add x
oracle@hpux:/home/oracle/diskspace> chmod +x run_df.sh
oracle@hpux:/home/oracle/diskspace> run_df.sh
----create directory
create or replace directory EXEC_DIR as '/home/oracle/diskspace';
---grant permission to
grant read,write,execute on directory exec_dir to DBAREPORTER;
----create table
CREATE TABLE df
(
"FILESYSTEM" VARCHAR2(200),
"BLOCKS" NUMBER,
"USED" NUMBER,
"AVAILABLE" NUMBER,
"CAPACITY" VARCHAR2(10),
"MOUNT" VARCHAR2(100)
)
ORGANIZATION external
(
TYPE oracle_loader
DEFAULT DIRECTORY exec_dir
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCII
preprocessor exec_dir:'run_df.sh'
READSIZE 1048576
SKIP 1
FIELDS TERMINATED BY WHITESPACE LDRTRIM
REJECT ROWS WITH ALL NULL FIELDS
(
"FILESYSTEM" CHAR(255)
TERMINATED BY WHITESPACE,
"BLOCKS" CHAR(255)
TERMINATED BY WHITESPACE,
"USED" CHAR(255)
TERMINATED BY WHITESPACE,
"AVAILABLE" CHAR(255)
TERMINATED BY WHITESPACE,
"CAPACITY" CHAR(255)
TERMINATED BY WHITESPACE,
"MOUNT" CHAR(255)
TERMINATED BY WHITESPACE
)
)
location
(
exec_dir:'run_df.sh')
)
;
alter table df reject limit unlimited;
SQL> grant select on sys.df to DBAREPORTER;
--test
SELECT b.host_name,b.instance_name,TO_CHAR(SYSDATE, 'MM-DD-YYYY HH24:MI:SS') as Today, a.* from sys.df a, (select host_name,instance_name from v$instance) b ;
---------
Comments
Post a Comment