Script to monitor standby
Hi.
I have the following script set up to monitor a standby, it then calls the second script to compare results:
standby_monitor.sh: (working):
sqlplus -L system/pwd@PROD<<END_SQL
spool standby_monitor.txt replace
select sysdate from dual;
select max(sequence#) from v\$log_history;
spool off
exit;
END_SQL
./standby_monitor.sql
===========================
standby_monitor.sql (working):
sqlplus -L sys/pwd@connect string as sysdba<<END_SQL
spool standby_monitor.txt append
select max(sequence#) STANDBY_DB_SEQUENCE_NUMBER from v\$log_history;
spool off
exit;
END_SQL
Both of these work fine - but I need now to compare both results, and if there is a difference have a mail program send the results to our helpdesk.
If there is any differenc between the two results (the max sequence number from Production and the STANDBY_DB_SEQUENCE_NUMBER from the standby , then send email to notify us.
mail ushere.com< standby_monitor.txt [RET]
Could somebody point me in the righrt direction for writing this final part? I do have some Windows scripts, but find it tricky converting to Linux version.
Thanks in advance..
DA
Oracle 10.2.0.2.0
Linux Red Hat 4.
Hi,
I think you can do it by running it from primary db
say your primary archive dest is 1 and standby dest_id is 2
<pre>
sqlplus -s "/ as sysdba" <<EOF
set head off
set feedb off
spool diff.log
select (select name from V\$DATABASE),(select max(sequence#) from v\$archived_log
where dest_id=1) Current_primary_seq,( select max(sequence#) from v$\archived_log
where to_date(next_time,'dd-mm-yyyy') > sysdate-1
and dest_id=2 ) max_stby,(select nvl((select max(sequence#) - min(sequence#) from v\$archived_log
where to_date(next_time,'dd-mm-yyyy') > sysdate-1 and dest_id=2 and applied='NO'),0) from
dual) "To be applied",((select max(sequence#) from v\$archived_log
where dest_id=1) - (select max(sequence#) from v\$archived_log
where dest_id=2)) "To be Shipped"
from dual
spool off
exit
EOF
diff=`awk '{print $5}' diff.log`
if [[ $diff -gt 0 ]];
then
mailx
fi
</pre>
I think this should do the work..Not tested the scripting part but the sql will give you the result. $4 gives the logs which need's to be applied on standby.
Cheers
Amit
http://askdba.org/weblog/
Edited by: Amit_DBA on Aug 20, 2009 5:32 PM
Similar Messages
-
Best Way to monitor standby, primary databases, including alert logs, etc.
Hi, Guys, I finally cutover the new environment to the new linux redhat and everything working great so far (the primary/standby).
Now I would like to setup monitoring scripts to monitor it automatically so I can let it run by itself.
What is the best way?
I talked to another dba friend outside of the company and he told me his shop not use any cron jobs to monitor, they use grid control.
We have no grid control. I would like to see what is the best option here? should we setup grid control?
And also for the meantime, I would appreciate any good ideas of any cronjob scripts.
ThanksHello;
I came up with this which I run on the Primary daily, Since its SQL you can add any extras you need.
SPOOL OFF
CLEAR SCREEN
SPOOL /tmp/quickaudit.lst
PROMPT
PROMPT -----------------------------------------------------------------------|
PROMPT
SET TERMOUT ON
SET VERIFY OFF
SET FEEDBACK ON
PROMPT
PROMPT Checking database name and archive mode
PROMPT
column NAME format A9
column LOG_MODE format A12
SELECT NAME,CREATED, LOG_MODE FROM V$DATABASE;
PROMPT
PROMPT -----------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking Tablespace name and status
PROMPT
column TABLESPACE_NAME format a30
column STATUS format a10
set pagesize 400
SELECT TABLESPACE_NAME, STATUS FROM DBA_TABLESPACES;
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking free space in tablespaces
PROMPT
column tablespace_name format a30
SELECT tablespace_name ,sum(bytes)/1024/1024 "MB Free" FROM dba_free_space WHERE
tablespace_name <>'TEMP' GROUP BY tablespace_name;
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking freespace by tablespace
PROMPT
column dummy noprint
column pct_used format 999.9 heading "%|Used"
column name format a16 heading "Tablespace Name"
column bytes format 9,999,999,999,999 heading "Total Bytes"
column used format 99,999,999,999 heading "Used"
column free format 999,999,999,999 heading "Free"
break on report
compute sum of bytes on report
compute sum of free on report
compute sum of used on report
set linesize 132
set termout off
select a.tablespace_name name,
b.tablespace_name dummy,
sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ) bytes,
sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ) -
sum(a.bytes)/count( distinct b.file_id ) used,
sum(a.bytes)/count( distinct b.file_id ) free,
100 * ( (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) -
(sum(a.bytes)/count( distinct b.file_id ) )) /
(sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) pct_used
from sys.dba_free_space a, sys.dba_data_files b
where a.tablespace_name = b.tablespace_name
group by a.tablespace_name, b.tablespace_name;
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking Size and usage in GB of Flash Recovery Area
PROMPT
SELECT
ROUND((A.SPACE_LIMIT / 1024 / 1024 / 1024), 2) AS FLASH_IN_GB,
ROUND((A.SPACE_USED / 1024 / 1024 / 1024), 2) AS FLASH_USED_IN_GB,
ROUND((A.SPACE_RECLAIMABLE / 1024 / 1024 / 1024), 2) AS FLASH_RECLAIMABLE_GB,
SUM(B.PERCENT_SPACE_USED) AS PERCENT_OF_SPACE_USED
FROM
V$RECOVERY_FILE_DEST A,
V$FLASH_RECOVERY_AREA_USAGE B
GROUP BY
SPACE_LIMIT,
SPACE_USED ,
SPACE_RECLAIMABLE ;
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking free space In Flash Recovery Area
PROMPT
column FILE_TYPE format a20
select * from v$flash_recovery_area_usage;
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking last sequence in v$archived_log
PROMPT
clear screen
set linesize 100
column STANDBY format a20
column applied format a10
--select max(sequence#), applied from v$archived_log where applied = 'YES' group by applied;
SELECT name as STANDBY, SEQUENCE#, applied, completion_time from v$archived_log WHERE DEST_ID = 2 AND NEXT_TIME > SYSDATE -1;
prompt
prompt----------------Last log on Primary--------------------------------------|
prompt
select max(sequence#) from v$archived_log where NEXT_TIME > sysdate -1;
PROMPT
PROMPT ------------------------------------------------------------------------|
PROMPT
PROMPT
PROMPT Checking switchover status
PROMPT
select switchover_status from v$database;I run it from a shell script and email myself quickaudit.lst
Alert logs are great source of information when you have an issue or just want to check something.
Best Regards
mseberg -
Shell scripts to monitor data guard
Hi All,
Please help me to have the shell scripts for monitoring the data guard.
Thanks,
Mahihere is the shell script we use to monitor dataguard, it sends mail if there is a gap for more than 20 archive logs..
#set Oracle environment for Sql*Plus
#ORACLE_BASE=/oracle/app/oracle ; export ORACLE_BASE
ORACLE_HOME=/oracle/app/oracle/product/10.2.0 ; export ORACLE_HOME
ORACLE_SID=usagedb ; export ORACLE_SID
PATH=$PATH:/oracle/app/oracle/product/10.2.0/bin
#set working directory. script is located here..
cd /oracle/scripts
#Problem statemnt is constructed in message variable
MESSAGE=""
#hostname of the primary DB.. used in messages..
HOST_NAME=`/usr/bin/hostname`
#who will receive problem messages.. DBAs e-mail addresses seperated with space
DBA_GROUP='[email protected] '
#SQL statements to extract Data Guard info from DB
LOCAL_ARC_SQL='select archived_seq# from V$ARCHIVE_DEST_STATUS where dest_id=1; \n exit \n'
STBY_ARC_SQL='select archived_seq# from V$ARCHIVE_DEST_STATUS where dest_id=2; \n exit \n'
STBY_APPLY_SQL='select applied_seq# from V$ARCHIVE_DEST_STATUS where dest_id=2; \n exit \n'
#Get Data guard information to Unix shell variables...
LOCAL_ARC=`echo $LOCAL_ARC_SQL | sqlplus -S / as sysdba | tail -2|head -1`
STBY_ARC=`echo $STBY_ARC_SQL | sqlplus -S / as sysdba | tail -2|head -1`
STBY_APPLY=`echo $STBY_APPLY_SQL | sqlplus -S / as sysdba | tail -2|head -1`
#Allow 20 archive logs for transport and Apply latencies...
let "STBY_ARC_MARK=${STBY_ARC}+20"
let "STBY_APPLY_MARK= ${STBY_APPLY}+20"
if [ $LOCAL_ARC -gt $STBY_ARC_MARK ] ; then
MESSAGE=${MESSAGE}"$HOST_NAME Standby -log TRANSPORT- error! \n local_Arc_No=$LOCAL_ARC but stby_Arc_No=$STBY_ARC \n"
fi
if [ $STBY_ARC -gt $STBY_APPLY_MARK ] ; then
MESSAGE=${MESSAGE}"$HOST_NAME Standby -log APPLY- error! \n stby_Arc_No=$STBY_ARC but stby_Apply_no=$STBY_APPLY \n"
fi
if [ -n "$MESSAGE" ] ; then
MESSAGE=${MESSAGE}"\nWarning: dataguard error!!! \n .\n "
echo $MESSAGE | mailx -s "$HOST_NAME DataGuard error" $DBA_GROUP
fi -
TSQL Script to monitor SQL Server transactional and snapshot replication
Hi Team,
Could you please let me know do you have any TSQL script to monitor replication(Transactional, Snapshot) with current status ? I have tried below script but it giving error. could you please have a look at the below script or do you have any other new TSQL
script to monitor the replication status ?
"Msg 8164, Level 16, State 1, Procedure sp_MSload_tmp_replication_status, Line 80
An INSERT EXEC statement cannot be nested."
DECLARE @srvname VARCHAR(100)
DECLARE @pub_db VARCHAR(100)
DECLARE @pubname VARCHAR(100)
CREATE TABLE #replmonitor(status INT NULL,warning INT NULL,subscriber sysname NULL,subscriber_db sysname NULL,publisher_db sysname NULL,
publication sysname NULL,publication_type INT NULL,subtype INT NULL,latency INT NULL,latencythreshold INT NULL,agentnotrunning INT NULL,
agentnotrunningthreshold INT NULL,timetoexpiration INT NULL,expirationthreshold INT NULL,last_distsync DATETIME,
distribution_agentname sysname NULL,mergeagentname sysname NULL,mergesubscriptionfriendlyname sysname NULL,mergeagentlocation sysname NULL,
mergeconnectiontype INT NULL,mergePerformance INT NULL,mergerunspeed FLOAT,mergerunduration INT NULL,monitorranking INT NULL,
distributionagentjobid BINARY(16),mergeagentjobid BINARY(16),distributionagentid INT NULL,distributionagentprofileid INT NULL,
mergeagentid INT NULL,mergeagentprofileid INT NULL,logreaderagentname VARCHAR(100),publisher varchar(100))
DECLARE replmonitor CURSOR FOR
SELECT b.srvname,a.publisher_db,a.publication
FROM distribution.dbo.MSpublications a, master.dbo.sysservers b
WHERE a.publisher_id=b.srvid
OPEN replmonitor
FETCH NEXT FROM replmonitor INTO @srvname,@pub_db,@pubname
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #replmonitor
EXEC distribution.dbo.sp_replmonitorhelpsubscription @publisher = @srvname
, @publisher_db = @pub_db
, @publication = @pubname
, @publication_type = 0
FETCH NEXT FROM replmonitor INTO @srvname,@pub_db,@pubname
END
CLOSE replmonitor
DEALLOCATE replmonitor
SELECT publication,publisher_db,subscriber,subscriber_db,
CASE publication_type WHEN 0 THEN 'Transactional publication'
WHEN 1 THEN 'Snapshot publication'
WHEN 2 THEN 'Merge publication'
ELSE 'Not Known' END,
CASE subtype WHEN 0 THEN 'Push'
WHEN 1 THEN 'Pull'
WHEN 2 THEN 'Anonymous'
ELSE 'Not Known' END,
CASE status WHEN 1 THEN 'Started'
WHEN 2 THEN 'Succeeded'
WHEN 3 THEN 'In progress'
WHEN 4 THEN 'Idle'
WHEN 5 THEN 'Retrying'
WHEN 6 THEN 'Failed'
ELSE 'Not Known' END,
CASE warning WHEN 0 THEN 'No Issues in Replication' ELSE 'Check Replication' END,
latency, latencythreshold,
'LatencyStatus'= CASE WHEN (latency > latencythreshold) THEN 'High Latency'
ELSE 'No Latency' END,
distribution_agentname,'DistributorStatus'= CASE WHEN (DATEDIFF(hh,last_distsync,GETDATE())>1) THEN 'Distributor has not executed more than n hour'
ELSE 'Distributor running fine' END
FROM #replmonitor
--DROP TABLE #replmonitor
Rajeev RINSERT INTO #replmonitor
Hi Rajeev,
Could you please use the following query and check if it is successful?
INSERT INTO #replmonitor
SELECT a.*
FROM OPENROWSET
('SQLNCLI', 'Server=DBServer;Trusted_Connection=yes;',
'SET FMTONLY OFF; exec distribution..sp_replmonitorhelpsubscription
@publisher = DBServer,
@publication_type = 0,
@publication=MyPublication') AS a;
There is a similar thread for your reference.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/634090bf-915e-4d97-b71a-58cf47d62a8a/msg-8164-level-16-state-1-procedure-spmsloadtmpreplicationstatus-line-80?forum=sqlreplication
Thanks,
Lydia Zhang
Lydia Zhang
TechNet Community Support -
Help in writing scripts for monitoring
Hi All,
I am in the position to write scripts for monitoring JVM and JDBC. I know the concept of confiuration MBean and run Time MBean.I planned to use WLShell scripting.In my organization using WLShell is not preferred by anyone. I
dont have any further idea about it. Any other possibilies are there to list the paramters of JVM and JDBC using any scripting.Please help me regrding this.
JasmineI solved that problem.Now i could enter into intractive mode.but couldnt connect to server using connect('weblogic','weblogic','t3://localhost:7001').The servers are up and running.
I am getting the following error.
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.StreamCorruptedException
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:138)
at weblogic.management.internal.RemoteMBeanServerImpl_812_WLStub.getServerName(Unknown Source)
at weblogic.management.scripting.WLScriptContext.connect(WLScriptContext.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
at org.python.core.PyMethod.__call__(PyMethod.java)
at org.python.core.PyObject.__call__(PyObject.java)
at org.python.core.PyObject.invoke(PyObject.java)
at org.python.pycode._pyx4.connect$2(<iostream>:68)
at org.python.pycode._pyx4.call_function(<iostream>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyFunction.__call__(PyFunction.java)
at org.python.pycode._pyx6.f$0(<input>:1)
at org.python.pycode._pyx6.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at org.python.core.Py.exec(Py.java)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java)
at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java)
at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java)
at weblogic.WLST.main(WLST.java:113)
Caused by: java.io.StreamCorruptedException
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1301)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:119)
at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:112)
at weblogic.management.internal.RemoteMBeanServerImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
--------------- nested within: ------------------
weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception - with nested exception:
<b>Please help me out.</b>
Jasmine -
Automatic scripts to monitor oracle performance
Hi,
I am in the process of developing standard scripts to monitor performance.Whenever I feel performance is not good I can run these to findout what is happening rather than going through each v$table.Please suggest me any links to these scripts.So that I can get good Idea about How to customize mine accroding to my environment
ThanksWhat is your database version? 9i or 10g.
There are plenty of information in AWR (automatic Workload Repository) in 10g that will help you detect/manage your performance problems and you won't need to write scripts. It will also allow you to define baselines/metrics and notification methods.
The beauty of the AWR is that you will be able to customize it based on your environment.
Doc URL:
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/autostat.htm -
Monitor standby database via OEM using non-sysdba account
Hi,
Is it at all possible to monitor a standby database via grid control using non-sysdba account so that targets are seen as up (green arrows visible etc)
We audit sys operations and as the SYS user is the account that currently monitors the standby we are seeing our audit file dest fill too quickly. We need to keep auditing on though.
I would like to do this using dbsnmp, though are there any roles or specific privs that need to be granted to do this? so far i am unable to do this.
Would welcome any advice on this one.
Thanks,
firefly.Thanks for reply robert.
we are using active for one standby but not using active for 2 other standby db's.
I just wondered what the SYSDBA priv used (what actual priv etc) to be able to monitor standby dbs effectively, whereas non-SYSDBA accounts are unable to.
Thanks,
firefly -
VB Scripting to monitor application event log based on specific words.
Hi All,
I Have written, vb script to monitor application event log based on specific word in the message. when I have included same script in monitor, after running this script at specific time once in day, I am getting run time error in the server, where it
supposed to run, could you please check the command where I have highlighted in below script.
Dim VarSize
Dim objMOMAPI
Dim objBag
Set objMOMAPI = CreateObject("MOM.ScriptAPI")
Set objBag = objMOMAPI.CreateTypedPropertyBag(StateDataType)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const CONVERT_TO_LOCAL_TIME = True
Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
dtmStartDate.SetVarDate dateadd("n", -1440, now)' CONVERT_TO_LOCAL_TIME
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND " _
& "EventCode = '100'")
For Each objEvent in colLoggedEvents
If InStr(LCase(colLoggedEvents.Message), "Message :Application A3 has been successfully processed for today") Then
X= "Success"
end if
Next
if X="Success" then
call objBag.AddValue("State","GOOD")
call objMOMAPI.Return(objBag)
wscript.quit()
Else
call objBag.AddValue("State","BAD")
call objMOMAPI.Return(objBag)
wscript.quit()
End IfBy programming standards since as long as I can remember the use of the value of a variable to detect its Boolean state has been used.
Cast your mind back to strongly typed languages, e.g. Pascal.
I'll cast back to the very early days of the "C" language where all variables could be treated as "bool" without a cast. The is no more strongly type language than "C". "C" practically invented the standards for all modern languages.
When I was writin machine language we also used zero as false but many machines only tested the high bit for truthieness. The HP machines and Intel allowed a test to aggregate to the sign bit. Adding that flag to the test alloed tru for
an numeric value that was non-zero. A boool test was also used for a negative e switch. If you study micro language implementation you will find that this hardware design and the companion compiler design is ... well... by design. It is a
way of improving the completeness and usefulness of an instruction set.
Other langauges may require further decoration due to some mistaken desire to be better than perfect. That is like trying to change number theory by renaming addition to be "gunking" and forcing everyone to use multiplication when adding the same number
more than once. A Boolean test os a test of the flag bit with to without aggregation. Even if we test a bit in a word we still mask and aggregate. It is always the most primitive operation. It is also the most useful
operation when you finally realize that it is like an identity in math.
Use the language features that are designed in. They can help to make code much more flexible and logical.
By the way, Pascal also treats everything as Boolean when asked to.
¯\_(ツ)_/¯ -
Need Help with EEM script for monitoring Rx and Tx load on Link
Hello,
I'm trying to implement a script, which monitors the Tx and Rx Load on the Link and sends a syslog in case the load is exceeded 200 mark (i.e If Rx or Tx load > 200)
I have implemented the following script. But it is not giving the required results.
event manager applet test
event interface name Tunnel111 parameter rxload entry-val 200 entry-op gt entry-val-is-increment true poll-interval 5000
action 1.0 syslog msg "Increase Load On the Link"
I'm trying to monitor the load on Tunnel 111 which is mapped to WAN interface.
Router (Cisco 2821) has following IOS
c2800nm-advipservicesk9-mz.124-25g.binHello Joseph,
As per your suggestion, we made some changes in our script and the following script is working fine. Its giving the required syslogs when the load is exceeded.
event manager applet test
event interface name Tunnel111 parameter txload entry-val 200 entry-op gt entry-val-is-increment false poll-interval 5
action 1.0 syslog msg "Increased Load On the Link"
Your prompt assistance is really appriciated. -
JMX script for monitoring JMS servers in a cluster
hi
I am new to writing scripts. I will appreciate if I can get some help in writing a JMX script for monitoring JMS Servers in a cluster a well as monitoring the distributed queues
thanksExact scenario is,
JMS Server
|
DistributedQueue
| |
JMSrvr1 JMSrvr2
Q1 Q3
Q2 Q4
Q1 and Q2 delegateing messages, and at the same time Q3,Q4 also delegating messages.
If JMSrvr1 down, we need to merge Q1 and Q2 with JMSrvr2. Here we cannot migrate as, JMSrvr already have queues. We need to merge all these queues.
Thanks and Regards,
Narayana Moorthy. -
Script to monitor oracle sessions
Hi i am looking for a script to monitor oracle sessions......which should find idle sessions which are idle for more than 25 mins and it should be killed...
is that possible.
Thanksuser11278505 wrote:
Hi i am looking for a script to monitor oracle sessions......which should find idle sessions which are idle for more than 25 mins and it should be killed...
is that possible.
ThanksYes it is, use Resource Manager to manage your users,
http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/dbrm.htm#ADMIN027
HTH
Aman.... -
Shell script to monitor the data guard
Hi,
Can any body please provide the shell scripts to monitor the data guard in all scenarios and to get the mail when problem occurs in dataguard.
Thanks,
MahipalSorry Mahi. Looks like all of the scripts i've got are for logical standbys and not physical. Have a look at the link ualual posted - easy enough to knock up a script from one or more of those data dictionary views. Just had a look on metalink and there's what looks to be a good script in note 241438.1. Its a good starting point definately.
regards,
Mark -
Hi guys.
On windows machine, I do have cron jobs that monitor tablespace usage and when a tbs reaches a machine, an alert is sent.
Now, I do have other dbs runing on windows and would like to do the same.
The problem is that am not use to windows and dont know how to do it! can any one help me automate this sql script??
select name, kbytes, used, free, pct_used
from (
select (select decode(extent_management,'LOCAL','*','') from dba_tablespaces
where tablespace_name =
b.tablespace_name) || nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/
kbytes_alloc)*100 pct_used,
nvl(largest,0) largest,
nvl(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from ( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_data_files
group by tablespace_name
union all
select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_temp_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by 1Eric has exactly the right idea. To monitor database performance or statistics or other database metrics in a cross-platform manner (that works the same across Windows, Linux, Solaris etc). You should definitely be using dbms_scheduler in 10g or up or dbms_job in 9i or below.
There are several examples in these forums of how to use these. You can use utl_smtp for sending e-mail notifications.
If you want help on using dbms_scheduler, there is a dedicated Scheduler forum here :
Scheduler
-Ravi -
Monitor_jdbc_conn.sql - Script to monitor JDBC connections
Hi
We are using oracle11 (11.5.10.2) on windows 2000 server
i need to monitor JDBC connections for that i want to schedule that script which runs every hour and after completion it creates output in a file with unique name.
How can i create such script?
Thanks
OHHi;
Please follow below for schedule script-task on windows platform:
How To Schedule Tasks in Windows
http://support.microsoft.com/kb/308569
How To Schedule Tasks in Windows
http://www.iopus.com/guides/winscheduler.htm
How do I schedule jobs on Win32 platforms?
http://docs.activestate.com/activeperl/5.10/faq/Windows/ActivePerl-Winfaq4.html#How_do_I_schedule_jobs_on_Win32_
Hope it helps
Regard
Helios -
Repcheck - A Simple Bash Script To Monitor Remote Repos Commits
Hello all,
I'm using a few git/svn packages from the AUR, and only recently realized that while to PKGBUILD itself is able to pull and build the latest version, the package version in the AUR will not update, unless a new PKGBUILD is pushed by the maintainer, and so my update monitor isn't aware of those remote updates.
I've looked for a convenient way to track such changes, but all I could find were "live" monitors that run constantly and check for updates in a given repo in a set interval.
It didn't fit my needs, so I wrote a script myself.
The script basically maintains a file containing repo address and current revision number (for SVN) or hash (for GIT).
Whenever an update operation is done, all remote hashes are compared to those stored in the file and if updates are found, a notification is sent.
In case of GIT repos, the script also tries to find corresponding AUR package (I couldn't find a standard for SVN addresses...).
It is up to the user to update currently installed version to latest remote version if he wants, script only displays notification.
Dependencies:
- bash
- git
- subversion
- libnotify
* EDIT *
Updated script in next post.
Last edited by adam777 (2013-06-14 11:55:29)#!/bin/bash
RepVersionsFile=~/repversions
TempRepVersionsFile=~/repversionsupd
TempRepUpdatesFile=~/repupdates
function add_to_list()
if [ -f $RepVersionsFile ]
then
tmp=$(cat $RepVersionsFile | grep $1)
if [ -n "$tmp" ]
then
exit
fi
fi
tmp=$(echo $2 | grep ".git")
if [ -z "$tmp" ]
then
current_hash=$(svn info $2 | grep Revision | awk '{ print $NF }')
else
current_hash=$(git ls-remote $2 | grep HEAD | awk '{ print $(NF-1) }')
fi
echo -e "$1 $2 $current_hash" >> $RepVersionsFile
function remove_from_list()
if [ ! -f $RepVersionsFile ]
then
exit
fi
tmp=$(cat $RepVersionsFile | grep -v $1)
if [ -z "$tmp" ]
then
rm $RepVersionsFile
exit
fi
echo -e "$tmp" > $RepVersionsFile
function check_all()
while read pkgname address hash
do
tmp=$(echo $address | grep ".git")
if [ -z "$tmp" ]
then
remote_hash=$(svn info $address | grep Revision | awk '{ print $NF }')
else
remote_hash=$(git ls-remote $address | grep HEAD | awk '{ print $(NF-1) }')
fi
if [ $remote_hash != $hash ]
then
echo -e "$pkgname" >> $TempRepUpdatesFile
fi
echo -e "$pkgname $address $remote_hash" >> $TempRepVersionsFile
done < $RepVersionsFile
if [ -f $TempRepUpdatesFile ]
then
notify-send "Updates Found On Remote Repos" "`cat $TempRepUpdatesFile`"
rm $TempRepUpdatesFile
fi
rm $RepVersionsFile
mv $TempRepVersionsFile $RepVersionsFile
case $1 in
add-address)
add_to_list $2 $3
remove-address)
remove_from_list $2
update)
check_all
echo "Enter Your Choice:";
echo "1 For Adding A Repository";
echo "2 For Removing A Repository";
read userchoice
if [ "$userchoice" == "1" ]
then
echo "Please Enter Package Name";
read pkgname
echo "Please Enter Repository Address";
read repaddress
repcheck add-address $pkgname $repaddress
fi
if [ "$userchoice" == "2" ]
then
echo "Please Enter Package Name";
read pkgname
repcheck remove-address $pkgname
fi
esac
Last edited by adam777 (2013-08-07 16:09:00)
Maybe you are looking for
-
Moved iTunes Library to external drive- now can't move iPad purchase to Mac
I moved my iTunes Library to an external drive because I didn't have enough internal HD space to move a movie purchased on the iPad to my Mac. Now iTunes won't sync my iPad - and wants to reformat it - because it says it was formatted on another Mac.
-
Link to a database... I think?!
Please have a look at this web page. As you can see at the bottom you type in your ID number and postcode and it tells you what your repair status is... http://www.gvs.co.uk/validation.php How would I even begin to attempt something similar to this?
-
My MacBook Air won't open any picture, please help
When i tried to open my pictures it shows me the file couldnt be opened because you dont have the permission to view it. please help
-
Greetings guru's, I would like to know the process, if there is one, of transporting my infosets/ad hoc queries from one client to another. Any help will be appreciated. Mark
-
1.Can I establish a general database and a data warehause at the same time under the same Oracle RDBMS of the same machine? (the data warehause draw out the data from the general database) 2.What is the difference between the process of establishing