├── orabbix
├── uninstall.cmd
├── orabbix.exe
├── orabbixw.exe
├── lib
│ ├── hsqldb.jar
│ ├── ojdbc6.jar
│ ├── log4j-1.2.15.jar
│ ├── commons-codec-1.4.jar
│ ├── commons-dbcp-1.4.jar
│ ├── commons-lang-2.5.jar
│ ├── commons-pool-1.5.4.jar
│ └── commons-logging-1.1.1.jar
├── doc
│ ├── CHANGELOG.txt
│ └── Orabbix_Install_v0.6.pdf
├── orabbix-1.2.3.jar
├── run.bat
├── conf
│ ├── log4j.properties
│ ├── log4j.properties.sample
│ ├── config.props
│ ├── config.props.sample
│ ├── query.props.sample
│ ├── query_a_1.props
│ ├── query.props
│ ├── query - Copy.props
│ ├── query_b.props
│ └── query_a.props
├── install.cmd
├── run.sh
├── init.d
│ └── orabbix
└── template
│ ├── Orabbix_export_triggers.xml
│ └── Orabbix_export_graphs.xml
├── .gitignore
├── dist
└── orabbix-1.2.3-origin.jar
├── Dockerfile
├── README.md
└── src
└── com
└── smartmarmot
├── common
├── SmartLogger.java
└── db
│ ├── DBConn.java
│ ├── DBJob.java
│ └── DBEnquiry.java
├── orabbix
├── bootstrap.java
├── Utility.java
├── Constants.java
├── Querybox.java
├── Query.java
├── Orabbixmon.java
├── Sender.java
└── Configurator.java
└── zabbix
└── ZabbixItem.java
/orabbix/uninstall.cmd:
--------------------------------------------------------------------------------
1 | orabbix.exe //DS//Orabbix
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist/com/*
2 | dist/orabbix-1.2.3.jar
3 |
--------------------------------------------------------------------------------
/orabbix/orabbix.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/orabbix.exe
--------------------------------------------------------------------------------
/orabbix/orabbixw.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/orabbixw.exe
--------------------------------------------------------------------------------
/orabbix/lib/hsqldb.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/hsqldb.jar
--------------------------------------------------------------------------------
/orabbix/lib/ojdbc6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/ojdbc6.jar
--------------------------------------------------------------------------------
/orabbix/doc/CHANGELOG.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/doc/CHANGELOG.txt
--------------------------------------------------------------------------------
/orabbix/orabbix-1.2.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/orabbix-1.2.3.jar
--------------------------------------------------------------------------------
/orabbix/lib/log4j-1.2.15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/log4j-1.2.15.jar
--------------------------------------------------------------------------------
/dist/orabbix-1.2.3-origin.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/dist/orabbix-1.2.3-origin.jar
--------------------------------------------------------------------------------
/orabbix/lib/commons-codec-1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/commons-codec-1.4.jar
--------------------------------------------------------------------------------
/orabbix/lib/commons-dbcp-1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/commons-dbcp-1.4.jar
--------------------------------------------------------------------------------
/orabbix/lib/commons-lang-2.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/commons-lang-2.5.jar
--------------------------------------------------------------------------------
/orabbix/lib/commons-pool-1.5.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/commons-pool-1.5.4.jar
--------------------------------------------------------------------------------
/orabbix/doc/Orabbix_Install_v0.6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/doc/Orabbix_Install_v0.6.pdf
--------------------------------------------------------------------------------
/orabbix/lib/commons-logging-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hsnotebook/orabbix4zabbix4/HEAD/orabbix/lib/commons-logging-1.1.1.jar
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jre-alpine
2 |
3 | COPY orabbix/ /opt/orabbix/
4 |
5 | WORKDIR /opt/orabbix
6 |
7 | CMD ["sh", "/opt/orabbix/run.sh"]
8 |
--------------------------------------------------------------------------------
/orabbix/run.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | setLocal EnableDelayedExpansion
3 | set CLASSPATH="
4 | for /R ./lib %%a in (*.jar) do (
5 | set CLASSPATH=!CLASSPATH!;%%a
6 | )
7 | set CLASSPATH=!CLASSPATH!"
8 |
9 | java -Duser.language=en -Duser.country=US -Dlog4j.configuration=./conf/log4j.properties -cp %CLASSPATH%;orabbix-1.2.3.jar com.smartmarmot.orabbix.bootstrap start ./conf/config.props &
--------------------------------------------------------------------------------
/orabbix/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG and its only appender to Orabbix.
2 | log4j.rootLogger=INFO , Orabbix
3 |
4 | # Orabbix is set to be a ConsoleAppender.
5 | log4j.appender.Orabbix=org.apache.log4j.RollingFileAppender
6 | log4j.appender.Orabbix.File=./logs/orabbix.log
7 |
8 | # Orabbix uses PatternLayout.
9 | log4j.appender.Orabbix.layout=org.apache.log4j.PatternLayout
10 | log4j.appender.Orabbix.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
11 |
12 |
--------------------------------------------------------------------------------
/orabbix/conf/log4j.properties.sample:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG and its only appender to Orabbix.
2 | log4j.rootLogger=INFO , Orabbix
3 |
4 | # Orabbix is set to be a ConsoleAppender.
5 | log4j.appender.Orabbix=org.apache.log4j.RollingFileAppender
6 | log4j.appender.Orabbix.File=./logs/orabbix.log
7 |
8 | # Orabbix uses PatternLayout.
9 | log4j.appender.Orabbix.layout=org.apache.log4j.PatternLayout
10 | log4j.appender.Orabbix.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 在使用 zabbix 4 时, orabbix 会报错:
2 |
3 | Orabbix - received unexpected response ' ' for key 'alive'
4 |
5 | 根据这个 [issue](https://github.com/smartmarmot/DBforBIX/issues/62),
6 | 修改了 `Sender.java`, 并把编译好的 class 文件, 添加到 orabbix-1.2.3.jar 中.
7 | 并打成了个 image.
8 |
9 | ## 使用方式
10 |
11 | 首先执行 `build.sh`, 这个脚本会编译 `Sender.java`, 并把 class 文件,添加到原来的
12 | jar 包中, 放到 orabbix 目录下, 再打成一个 image `zabbix-agent-oralce`.
13 |
14 | ## Docker Environment Variables
15 |
16 | - ZBX_SERVER_HOST zabbix server 地址, 默认为 127.0.0.1
17 | - ZBX_SERVER_PORT zabbix server 端口, 默认为 10051
18 | - ORACLE_HOST oralce 地址, 默认为 127.0.0.1
19 | - ORACLE_PORT oralce 端口, 默认为 1521
20 | - ORACLE_USER oralce 用户, 默认为 zabbix
21 | - ORACLE_PASSWORD oralce 用户密码, 默认为 zabbix
22 | - ORACLE_INSTANCE oralce 实例, 默认为 orcl
23 |
--------------------------------------------------------------------------------
/orabbix/install.cmd:
--------------------------------------------------------------------------------
1 | orabbix.exe //IS//Orabbix --DisplayName="Orabbix Oracle DataBase Monitor for Zabbix" --JvmOptions=-Duser.language=en ++JvmOptions=-Duser.country=US ++JvmOptions=-Dlog4j.configuration=file:/c:/orabbix/conf/log4j.properties --LogPrefix="orabbix" --StartPath="C:\orabbix" --LogPath="c:\orabbix\logs" --Classpath="lib/commons-codec-1.4.jar;lib/commons-daemon-1.0.5.jar;lib/commons-dbcp-1.4.jar;lib/commons-lang-2.5.jar;lib/commons-logging-1.1.1.jar;lib/commons-pool-1.5.4.jar;lib/log4j-1.2.15.jar;lib/mysql-connector-java-5.1.14-bin.jar;lib/ojdbc6.jar;orabbix-1.2.3.jar" --Install="C:\orabbix\orabbix.exe" --Jvm=auto --StartMode=jvm --StartClass=com.smartmarmot.orabbix.bootstrap --StartParams=start ++StartParams=./conf/config.props --StopMode=jvm --StopClass=com.smartmarmot.orabbix.bootstrap --StopParams=stop
--------------------------------------------------------------------------------
/orabbix/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CONFIG_FILE="/opt/orabbix/conf/config.props"
4 |
5 | sed -i "s/ZBX_SERVER_HOST/${ZBX_SERVER_HOST:-127.0.0.1}/g" ${CONFIG_FILE}
6 | sed -i "s/ZBX_SERVER_PORT/${ZBX_SERVER_PORT:-10051}/g" ${CONFIG_FILE}
7 | sed -i "s/ORACLE_HOST/${ORACLE_HOST:-127.0.0.1}/g" ${CONFIG_FILE}
8 | sed -i "s/ORACLE_PORT/${ORACLE_PORT:-1521}/g" ${CONFIG_FILE}
9 | sed -i "s/ORACLE_USER/${ORACLE_USER:-zabbix}/g" ${CONFIG_FILE}
10 | sed -i "s/ORACLE_PASSWORD/${ORACLE_PASSWORD:-zabbix}/g" ${CONFIG_FILE}
11 | sed -i "s/ORACLE_INSTANCE/${ORACLE_INSTANCE:-orcl}/g" ${CONFIG_FILE}
12 |
13 | java \
14 | -Duser.timezone=Asia/Shanghai \
15 | -Dlog4j.configuration=./conf/log4j.properties \
16 | -cp $(for i in lib/*.jar ; do echo -n $i: ; done).:./orabbix-1.2.3.jar \
17 | com.smartmarmot.orabbix.bootstrap \
18 | start ./conf/config.props
19 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/common/SmartLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.common;
21 |
22 | import org.apache.log4j.Level;
23 |
24 | import org.apache.log4j.Logger;
25 |
26 | import com.smartmarmot.orabbix.Constants;
27 |
28 |
29 | public class SmartLogger {
30 | public static void logThis(Level level, String message) {
31 | Logger logger = Logger.getLogger(Constants.PROJECT_NAME);
32 | if (message == null) {
33 | message = new String("");
34 | }
35 | logger.log(level, message);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/orabbix/conf/config.props:
--------------------------------------------------------------------------------
1 | #comma separed list of Zabbix servers
2 | ZabbixServerList=ZabbixServer
3 |
4 | ZabbixServer.Address=ZBX_SERVER_HOST
5 | ZabbixServer.Port=ZBX_SERVER_PORT
6 |
7 | #pidFile
8 | OrabbixDaemon.PidFile=./logs/orabbix.pid
9 | #frequency of item's refresh
10 | OrabbixDaemon.Sleep=300
11 | #MaxThreadNumber should be >= than the number of your databases
12 | OrabbixDaemon.MaxThreadNumber=100
13 |
14 | #put here your databases in a comma separated list
15 | DatabaseList=ORACLE_HOST
16 |
17 | #Configuration of Connection pool
18 | #if not specified Orabbis is going to use default values (hardcoded)
19 | #Maximum number of active connection inside pool
20 | DatabaseList.MaxActive=10
21 | #The maximum number of milliseconds that the pool will wait
22 | #(when there are no available connections) for a connection to be returned
23 | #before throwing an exception, or <= 0 to wait indefinitely.
24 | DatabaseList.MaxWait=100
25 | DatabaseList.MaxIdle=1
26 |
27 | #define here your connection string for each database
28 | ORACLE_HOST.Url=jdbc:oracle:thin:@ORACLE_HOST:ORACLE_PORT:ORACLE_INSTANCE
29 | ORACLE_HOST.User=ORACLE_USER
30 | ORACLE_HOST.Password=ORACLE_PASSWORD
31 | ###Those values are optionals if not specified Orabbix is going to use the general values
32 | ORACLE_HOST.MaxActive=10
33 | ORACLE_HOST.MaxWait=100
34 | ORACLE_HOST.MaxIdle=1
35 | ORACLE_HOST.QueryListFile=./conf/query.props
36 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/common/db/DBConn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.common.db;
21 |
22 | import org.apache.commons.dbcp.datasources.SharedPoolDataSource;
23 |
24 | public class DBConn {
25 | private SharedPoolDataSource spds;
26 | private String dbaname;
27 |
28 | public DBConn(SharedPoolDataSource _spds, String _name) {
29 | if (_spds == null)
30 | throw new RuntimeException("empty datasource");
31 | this.spds = _spds;
32 | if (_name != null && _name.length() > 0)
33 | this.dbaname = _name;
34 | else
35 | this.dbaname = "undefined";
36 | }
37 |
38 | public String getName() {
39 | return this.dbaname;
40 | }
41 |
42 | public SharedPoolDataSource getSPDS() {
43 | return this.spds;
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/orabbix/conf/config.props.sample:
--------------------------------------------------------------------------------
1 | #comma separed list of Zabbix servers
2 | ZabbixServerList=ZabbixServer1,ZabbixServer2
3 |
4 | ZabbixServer1.Address=IP_ADDRESS_OF_ZABBIX_SERVER
5 | ZabbixServer1.Port=PORT_OF_ZABBIX_SERVER
6 |
7 | ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER
8 | ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER
9 |
10 | #pidFile
11 | OrabbixDaemon.PidFile=./logs/orabbix.pid
12 | #frequency of item's refresh
13 | OrabbixDaemon.Sleep=300
14 | #MaxThreadNumber should be >= than the number of your databases
15 | OrabbixDaemon.MaxThreadNumber=100
16 |
17 | #put here your databases in a comma separated list
18 | DatabaseList=DB1,DB2,DB3
19 |
20 | #Configuration of Connection pool
21 | #if not specified Orabbis is going to use default values (hardcoded)
22 | #Maximum number of active connection inside pool
23 | DatabaseList.MaxActive=10
24 | #The maximum number of milliseconds that the pool will wait
25 | #(when there are no available connections) for a connection to be returned
26 | #before throwing an exception, or <= 0 to wait indefinitely.
27 | DatabaseList.MaxWait=100
28 | DatabaseList.MaxIdle=1
29 |
30 | #define here your connection string for each database
31 | DB1.Url=jdbc:oracle:thin:@server.domain.example.com::DB1
32 | DB1.User=zabbix
33 | DB1.Password=zabbix_password
34 | #Those values are optionals if not specified Orabbix is going to use the general values
35 | DB1.MaxActive=10
36 | DB1.MaxWait=100
37 | DB1.MaxIdle=1
38 | DB1.QueryListFile=./conf/query.props
39 |
40 | DB2.Url=jdbc:oracle:thin:@server2.domain.example.com::DB2
41 | DB2.User=zabbix
42 | DB2.Password=zabbix_password
43 | DB2.QueryListFile=./conf/query.props
44 |
45 | DB3.Url=jdbc:oracle:thin:@server3.domain.example.com::DB3
46 | DB3.User=zabbix
47 | DB3.Password=zabbix_password
48 | DB3.QueryListFile=./conf/query.props
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/orabbix/init.d/orabbix:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # This is the init script for starting up the
3 | # Orabbix daemon
4 | #
5 | # chkconfig: 345 91 10
6 | # description: Starts and stops the orabbix daemon.
7 | # processname: orabbix
8 | #
9 | # Source function library.
10 | . /etc/rc.d/init.d/functions
11 |
12 | # Get config.
13 | . /etc/sysconfig/network
14 |
15 | # Check that networking is up.
16 | [ "${NETWORKING}" = "no" ] && exit 0
17 |
18 | orabbix=/opt/orabbix
19 | pidfile=`cat $orabbix/conf/config.props |grep -i pidfile |sed 's/.*PidFile=//'`
20 | startup=$orabbix/run.sh
21 |
22 | start(){
23 | echo -n "Starting Orabbix service:"
24 | cd $orabbix
25 | $startup
26 | RETVAL=$?
27 | echo
28 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/orabbix
29 | return $RETVAL
30 | }
31 |
32 | stop(){
33 | echo -n "Stopping Orabbix service:"
34 | pid=`ps -ef |grep java |grep orabbix | awk '{ print $2 }'`
35 | kill `cat $orabbix/logs/orabbix.pid`
36 | RETVAL=$?
37 | echo
38 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/orabbix
39 | return $RETVAL
40 | }
41 |
42 | restart(){
43 | stop
44 | start
45 | }
46 |
47 | status(){
48 | numproc=`ps -ef | grep java | grep orabbix | grep -v grep | wc -l`
49 | if [ "$numproc" -gt 0 ]; then
50 | echo "Orabbix is running"
51 | else
52 | echo "Orabbix is stopped"
53 | fi
54 | }
55 |
56 | # See how we were called.
57 | case "$1" in
58 | start)
59 | start
60 | ;;
61 | stop)
62 | stop
63 | ;;
64 | status)
65 | status
66 | ;;
67 | restart)
68 | restart
69 | ;;
70 | *)
71 | echo "Usage: $0 {start|stop|status|restart}"
72 | exit 1
73 | esac
74 | exit $RETVAL
75 |
76 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/bootstrap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | * @author Andrea Dalle Vacche
4 | *
5 | * This file is part of DBforBIX.
6 | *
7 | * Orabbix is free software: you can redistribute it and/or modify it under the
8 | * terms of the GNU General Public License as published by the Free Software
9 | * Foundation, either version 3 of the License, or (at your option) any later
10 | * version.
11 | *
12 | * Orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 | * details.
16 | *
17 | * You should have received a copy of the GNU General Public License along with
18 | * Orabbix. If not, see .
19 | */
20 |
21 | package com.smartmarmot.orabbix;
22 | import com.smartmarmot.orabbix.Constants;
23 |
24 | public class bootstrap {
25 |
26 |
27 | private static Orabbixmon runner;
28 | public static void printUsage() {
29 | System.out.println(Constants.BANNER);
30 | }
31 |
32 | /**
33 | * @param args
34 | * @throws Exception
35 | */
36 | public static void main(final String[] args) {
37 | try {
38 | if (args.length > 2) {
39 | printUsage();
40 | System.exit(0);
41 | }
42 |
43 | String cmd = new String(args[0].toString());
44 | String configFile = new String(args[1].toString());
45 |
46 |
47 | if (cmd.equalsIgnoreCase("start")) {
48 | runner = new Orabbixmon(configFile);
49 | new Thread(runner);
50 | runner.run();
51 | }
52 | else if (args[0].equalsIgnoreCase("stop")) {
53 | if (runner != null) {
54 | runner.terminate();
55 | System.err.println("Runner terminated");
56 | }
57 | else
58 | System.err.println("No daemon running");
59 | } else{
60 | printUsage();
61 | }
62 | } catch (Exception ex) {
63 | ex.printStackTrace();
64 | }
65 |
66 | }
67 |
68 |
69 |
70 | }
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Utility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.orabbix;
21 |
22 | import java.io.File;
23 | import java.io.FileOutputStream;
24 | import java.io.IOException;
25 | import java.io.PrintStream;
26 |
27 | import org.apache.log4j.Level;
28 |
29 | import com.smartmarmot.common.SmartLogger;
30 |
31 | public class Utility {
32 |
33 | public static void writePid(String _pid, String _pidfile) throws Exception {
34 | try {
35 |
36 | // Open an output stream
37 |
38 | File target = new File(_pidfile);
39 |
40 | File newTarget = new File(target.getAbsoluteFile()
41 | .getCanonicalPath());
42 | target = null;
43 |
44 | if (newTarget.exists()) {
45 | boolean success = newTarget.delete();
46 | if (!success) {
47 | SmartLogger.logThis(Level.ERROR,
48 | "Delete: deletion failed "
49 | + newTarget.getAbsolutePath());
50 | }
51 | }
52 | if (!newTarget.exists()) {
53 | FileOutputStream fout = new FileOutputStream(newTarget);
54 | new PrintStream(fout).print(_pid);
55 | // Close our output stream
56 | fout.close();
57 | }
58 |
59 | }
60 | // Catches any error conditions
61 | catch (IOException e) {
62 | SmartLogger.logThis(Level.ERROR, "Unable to write to file "
63 | + _pidfile + " error:" + e);
64 | }
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/zabbix/ZabbixItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 |
21 |
22 | package com.smartmarmot.zabbix;
23 |
24 | public final class ZabbixItem {
25 |
26 | private final String key;
27 | private final String value;
28 | private final String hostname;
29 |
30 | /**
31 | * Create a literal value item.
32 | *
33 | * @param key
34 | * The monitoring server's key for this statistic.
35 | * @param value
36 | * The literal value.
37 | */
38 |
39 | /*public ZabbixItem(final String key, final String value) {
40 | if (key == null || "".equals(key.trim())) {
41 | throw new IllegalArgumentException("empty key");
42 | }
43 | if (value == null) {
44 | throw new IllegalArgumentException("null value for key '" + key
45 | + "'");
46 | }
47 |
48 | this.key = key;
49 | this.value = value;
50 | this.hostname = null;
51 | }
52 | */
53 | public ZabbixItem(final String key, final String value,
54 | final String hostname) {
55 | if (key == null || "".equals(key.trim())) {
56 | throw new IllegalArgumentException("empty key");
57 | }
58 | if (value == null) {
59 | throw new IllegalArgumentException("null value for key '" + key
60 | + "'");
61 | }
62 | if (hostname == null) {
63 | throw new IllegalArgumentException("null value for hostname '"
64 | + hostname + "'");
65 | }
66 |
67 | this.key = key;
68 | this.value = value;
69 | this.hostname = hostname;
70 | }
71 |
72 | /**
73 | * @return The current hostname for this item.
74 | * @throws Exception
75 | */
76 | public String getHostName() throws Exception {
77 | return hostname;
78 | // return JMXHelper.Query(value, attribute);
79 | }
80 |
81 | /**
82 | * Find the item's key.
83 | *
84 | * @return The monitoring server's key for this item.
85 | */
86 | public String getKey() {
87 | return key;
88 | }
89 |
90 | /**
91 | * @return The current value for this item.
92 | * @throws Exception
93 | * When the item could not be queried in the platform's mbean
94 | * server.
95 | */
96 | public String getValue() throws Exception {
97 | return value;
98 | // return JMXHelper.Query(value, attribute);
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.orabbix;
21 |
22 |
23 | public class Constants {
24 | public static final String VERSION = "Version 1.2.3 ";
25 | public static final String BANNER = Constants.PROJECT_NAME + " " + VERSION;
26 | public static final String PROJECT_NAME = "Orabbix";
27 | public static final String DATABASES_LIST = "DatabaseList";
28 | public static final String DELIMITER = ",";
29 | public static final String QUERY_LIST = "QueryList";
30 | public static final String QUERY_LIST_FILE = "QueryListFile";
31 | public static final String EXTRA_QUERY_LIST_FILE = "ExtraQueryListFile";
32 | public static final String QUERY_POSTFIX = "Query";
33 | public static final String QUERY_NO_DATA_FOUND = "NoDataFound";
34 | public static final String CONN_URL = "Url";
35 | public static final String CONN_USERNAME = "User";
36 | public static final String CONN_PASSWORD = "Password";
37 | public static final String CONN_DEFAULT_USERNAME = "DefaultUser";
38 | public static final String CONN_DEFAULT_PASSWORD = "DefaultPassword";
39 | public static final String CONN_MAX_ACTIVE = "MaxActive";
40 | public static final String CONN_MAX_IDLE = "MaxIdle";
41 | public static final String CONN_MAX_WAIT = "MaxWait";
42 | public static final String ORACLE = "Oracle";
43 | public static final String ORACLE_VALIDATION_QUERY = "SELECT SYSDATE FROM DUAL";
44 | public static final String ORACLE_DRIVER = "oracle.jdbc.OracleDriver";
45 | public static final String ORACLE_WHOAMI_QUERY = "SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER') FROM DUAL";
46 | public static final String ORACLE_DBNAME_QUERY = "SELECT SYS_CONTEXT ('USERENV', 'DB_NAME') FROM DUAL";
47 | public static final String RACE_CONDITION_QUERY = "RaceConditionQuery";
48 | public static final String RACE_CONDITION_EXCLUDE_COLUMNS = "RaceConditionQueryExcludeColumnsList";
49 | public static final String RACE_CONDITION_VALUE = "RaceConditionValue";
50 | public static final String QUERY_PERIOD = "Period";
51 | public static final String QUERY_DEFAULT_PERIOD = "DefaultQueryPeriod";
52 | public static final String QUERY_ACTIVE = "Active";
53 | public static final String ZABBIX_SERVER_LIST = "ZabbixServerList";
54 | public static final String ZABBIX_SERVER_PORT = "Port";
55 | public static final String ZABBIX_SERVER_HOST = "Address";
56 | public static final String ORABBIX_PIDFILE = "OrabbixDaemon.PidFile";
57 | public static final String ORABBIX_DAEMON_SLEEP = "OrabbixDaemon.Sleep";
58 | public static final String ORABBIX_DAEMON_THREAD = "OrabbixDaemon.MaxThreadNumber";
59 | public static final int ZABBIX_SERVER_DEFAULT_PORT = 10051;
60 | public static final String QUERY_TRIM = "Trim";
61 | public static final String QUERY_SPACE = "AddSpaces";
62 | public static final String QUERY_EXCLUDE_COLUMNS = "ExcludeColumnsList";
63 | }
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Querybox.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.orabbix;
21 |
22 | import java.util.ArrayList;
23 | import java.util.Arrays;
24 | import java.util.Date;
25 | import java.util.Properties;
26 |
27 | import org.apache.log4j.Level;
28 |
29 | import com.smartmarmot.common.SmartLogger;
30 | import com.smartmarmot.orabbix.Configurator;
31 |
32 | public class Querybox {
33 | private Query[] _query;
34 | private String _dbname;
35 | private String _queriesfile;
36 | private String _extraqueriesfile;
37 |
38 | public Querybox(String _localdbname, String _prp,String _extraprp) {
39 | try {
40 | if (Configurator.propVerify(_prp)){
41 | this.setQueriesFile(_prp);
42 | }
43 | if (Configurator.propVerify(_extraprp)){
44 | this.setExtraQueriesFile(_extraprp);
45 | }
46 |
47 | if (_localdbname.length() > 0 && _localdbname != null) {
48 | this.setDBName(_localdbname);
49 | }
50 | refresh();
51 |
52 | } catch (Exception e) {
53 | // TODO Auto-generated catch block
54 | SmartLogger.logThis(Level.ERROR, "Error on QueryBox "
55 | + e.getMessage());
56 | }
57 |
58 | }
59 |
60 | public String getDBName() {
61 | return _dbname;
62 | }
63 |
64 | public Query[] getQueries() {
65 | return _query;
66 | }
67 |
68 |
69 | public String getQueriesFile() {
70 | return _queriesfile;
71 | }
72 |
73 |
74 | public void refresh() {
75 | try {
76 | Query[] firstq=null;
77 | Query[] extraq=null;
78 |
79 | if (_queriesfile != null){
80 | Properties prp = Configurator.getPropsFromFile(_queriesfile);
81 | firstq =Configurator.getQueries(prp);
82 | //this.setQueries(q);
83 | }
84 | if (_extraqueriesfile != null){
85 | Properties prp = Configurator.getPropsFromFile(_extraqueriesfile);
86 | extraq =Configurator.getQueries(prp);
87 | }
88 |
89 | Query[] refreshedq = addQueries(firstq,extraq);
90 | if (this._query==null){
91 | this.setQueries(refreshedq);
92 | } else {
93 | for (int i = 0; i tempOriginalArray = new ArrayList(Arrays.asList(_originalquery));
124 | ArrayList tempNewArray = new ArrayList(Arrays.asList(_newquery));
125 | for (int i = 0; i < _originalquery.length; i++){
126 | for (int j = 0; j < _newquery.length; j++){
127 | if (_originalquery[i].getName().equals(_newquery[j].getName())){
128 | tempOriginalArray.remove(_originalquery[i]);
129 | tempOriginalArray.add(_newquery[j]);
130 | tempNewArray.remove(_newquery[j]);
131 | }
132 | }
133 | }
134 | tempOriginalArray.addAll(tempNewArray);
135 | Query[] queries = (Query[]) tempOriginalArray.toArray(new Query[0]);
136 | //this.setQueries(queries);
137 | return queries;
138 | }
139 |
140 | public void setQueriesFile(String _queriesfile) {
141 | this._queriesfile = _queriesfile;
142 | }
143 |
144 | public void setExtraQueriesFile(String _extraqueriesfile) {
145 | this._extraqueriesfile = _extraqueriesfile;
146 | }
147 |
148 | }
149 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Query.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.orabbix;
21 |
22 |
23 | import java.util.List;
24 | import java.util.Date;
25 |
26 | public class Query {
27 |
28 | private String sql;
29 | private String name;
30 | private String nodata;
31 | private String racequery;
32 | private String racevalue;
33 | private List raceExcludeColumns = null;
34 | private int period = -1;
35 | private Date nextrun;
36 | private Boolean active = true;
37 | private List excludeColumns = null;
38 | private Boolean space = false;
39 | private Boolean trim = true;
40 |
41 | public Query(String _query, String _name, String _nodata, String _rccondq,
42 | String _rccondval, int _period, Boolean _active, Boolean _trim,
43 | Boolean _space, List _excludeColumns,
44 | List _raceExcludeColumns) {
45 | if (_query == null || _query.length() == 0)
46 | throw new RuntimeException("empty query");
47 | this.sql = _query;
48 | if (_name != null && _name.length() > 0)
49 | this.name = _name;
50 | else
51 | this.name = _query;
52 | if (_nodata != null && _nodata.length() > 0) {
53 | this.nodata = _nodata;
54 | } else
55 | this.nodata = "";
56 | this.racequery = "";
57 | this.racevalue = "";
58 | if (_rccondq != null && _rccondq.length() > 0) {
59 | if (_rccondval != null && _rccondval.length() > 0) {
60 | this.racequery = _rccondq;
61 | this.racevalue = _rccondval;
62 | }
63 | }
64 | if (_period != 0) {
65 | this.period = _period;
66 | if (period > 0) {
67 | Date newNextRun = new Date(System.currentTimeMillis());
68 | // Date now =new Date(System.currentTimeMillis());
69 | // Date newNextRun=new Date(now.getTime()+(period*1000*60));
70 | this.nextrun = newNextRun;
71 | }
72 | }
73 | if (_trim != null) {
74 | this.setTrim(_trim);
75 | }
76 | if (_space != null) {
77 | this.setSpace(_space);
78 | }
79 | if (_active != null) {
80 | this.setActive(_active);
81 | }
82 | if (_excludeColumns != null) {
83 | this.setExcludeColumnsList(_excludeColumns);
84 | }
85 | if (_raceExcludeColumns != null) {
86 | this.setRaceExcludeColumnsList(_raceExcludeColumns);
87 | }
88 | }
89 |
90 | public Boolean getActive() {
91 | return active.booleanValue();
92 | }
93 |
94 | public String getName() {
95 | return this.name;
96 | }
97 |
98 | public Date getNextrun() {
99 | return nextrun;
100 | }
101 |
102 | public String getNoData() {
103 | return this.nodata;
104 | }
105 |
106 | public int getPeriod() {
107 | return period;
108 | }
109 |
110 | public String getRaceQuery() {
111 | return this.racequery;
112 | }
113 |
114 | public String getRaceValue() {
115 | return this.racevalue;
116 | }
117 |
118 | public String getSQL() {
119 | return this.sql;
120 | }
121 |
122 | public void setActive(Boolean active) {
123 | this.active = active;
124 | }
125 |
126 | public void setNextrun(Date nextrun) {
127 | this.nextrun = nextrun;
128 | }
129 |
130 | public void setPeriod(int period) {
131 | this.period = period;
132 |
133 | }
134 |
135 | public void setRaceQuery(String _raceQuery) {
136 | this.racequery = _raceQuery;
137 | }
138 |
139 | public void setSql(String _sql) {
140 | this.sql = _sql;
141 | // TODO Auto-generated method stub
142 |
143 | }
144 |
145 | public void setTrim(Boolean trim) {
146 | this.trim = trim;
147 | }
148 | public Boolean getTrim() {
149 | return trim;
150 | }
151 | public void setSpace(Boolean space) {
152 | this.space = space;
153 | }
154 | public Boolean getSpace() {
155 | return space;
156 | }
157 | public List getExcludeColumnsList() {
158 | return this.excludeColumns;
159 | }
160 | public void setExcludeColumnsList(List excludeList) {
161 | if (excludeList != null) {
162 | this.excludeColumns = excludeList;
163 | }
164 | }
165 | public void setRaceExcludeColumnsList(List raceExcludeColumns) {
166 | this.raceExcludeColumns = raceExcludeColumns;
167 | }
168 | public List getRaceExcludeColumnsList() {
169 | return raceExcludeColumns;
170 | }
171 | }
--------------------------------------------------------------------------------
/orabbix/template/Orabbix_export_triggers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 0
6 | 0
7 |
8 | 0.0.0.0
9 | 10050
10 | 3
11 | 0
12 | 127.0.0.1
13 | 623
14 | -1
15 | 2
16 |
17 |
18 |
19 | TEMPLATES
20 |
21 |
22 |
23 | Alive {HOSTNAME}
24 | 0
25 | {Template_Oracle:alive.last(0)}#1
26 |
27 | 0
28 | 4
29 |
30 |
31 |
32 | No data received from Orabbix
33 | 0
34 | {Template_Oracle:alive.sum(600)}<1
35 |
36 | 0
37 | 4
38 | No data retrieved from Orabbix for database
39 |
40 |
41 | Archivelog
42 | 0
43 | {Template_Oracle:archive.last(0)}>100
44 |
45 | 0
46 | 2
47 | HIGH Archivelog generation
48 |
49 |
50 | Audit on {HOSTNAME}
51 | 0
52 | {Template_Oracle:audit.str(none)}=0
53 |
54 | 0
55 | 4
56 |
57 |
58 |
59 | Hit Ratio on {HOSTNAME}
60 | 0
61 | {Template_Oracle:hitratio_table_proc.avg(60)}<50|{Template_Oracle:hitratio_trigger.avg(60)}<50|{Template_Oracle:hitratio_sqlarea.avg(60)}<50|{Template_Oracle:hitratio_body.avg(60)}<50
62 |
63 | 0
64 | 4
65 |
66 |
67 |
68 | Locks on {HOSTNAME}
69 | 0
70 | {Template_Oracle:locks.str(none)}=0
71 |
72 | 0
73 | 4
74 |
75 |
76 |
77 | Process Alarm on {HOSTNAME}
78 | 0
79 | ({Template_Oracle:procnum.last(0)}*100/{Template_Oracle:maxprocs.last(0)})>80
80 |
81 | 0
82 | 4
83 |
84 |
85 |
86 | Session Alarm on {HOSTNAME}
87 | 0
88 | ({Template_Oracle:session.last(0)}*100/{Template_Oracle:maxsession.last(0)})>80
89 | http://10.10.64.93/overview.php
90 | 0
91 | 4
92 |
93 |
94 |
95 | PGA Alarm on {HOSTNAME}
96 | 0
97 | ({Template_Oracle:pga.last(0)}*100/{Template_Oracle:pga_aggregate_target.last(0)})>90
98 | http://10.10.64.93/overview.php
99 | 0
100 | 4
101 |
102 |
103 |
104 | Active Session {HOSTNAME}
105 | 0
106 | {Template_Oracle:session_active.last(0)}>10
107 |
108 | 0
109 | 4
110 | DANGER
111 |
112 |
113 | Active Session {HOSTNAME}
114 | 0
115 | {Template_Oracle:session_active.last(0)}>20
116 |
117 | 0
118 | 4
119 | DANGER
120 |
121 |
122 | Tablespaces on {HOSTNAME}
123 | 0
124 | {Template_Oracle:tbl_space.str(none)}=0
125 |
126 | 0
127 | 4
128 |
129 |
130 |
131 | Uptime on {HOSTNAME}
132 | 0
133 | {Template_Oracle:uptime.last(0)}<1
134 |
135 | 0
136 | 4
137 |
138 |
139 |
140 | User Locked on {HOSTNAME}
141 | 0
142 | {Template_Oracle:users_locked.str(none)}=0
143 |
144 | 0
145 | 4
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/common/db/DBJob.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.common.db;
21 |
22 | import java.sql.Connection;
23 | import java.sql.PreparedStatement;
24 | import java.sql.ResultSet;
25 |
26 | import java.util.Hashtable;
27 | import java.util.concurrent.BlockingQueue;
28 | import java.util.concurrent.LinkedBlockingQueue;
29 |
30 | import org.apache.commons.dbcp.datasources.SharedPoolDataSource;
31 | import org.apache.log4j.Level;
32 |
33 | import com.smartmarmot.common.SmartLogger;
34 | import com.smartmarmot.orabbix.Constants;
35 | import com.smartmarmot.orabbix.Query;
36 | import com.smartmarmot.orabbix.Sender;
37 | import com.smartmarmot.zabbix.ZabbixItem;
38 |
39 | public class DBJob implements Runnable {
40 | private final SharedPoolDataSource _spds;
41 | private Query[] _queries;
42 | private final BlockingQueue _queue = new LinkedBlockingQueue();
43 | private final String _dbname;
44 | private final String _queriesGroup;
45 | private final int _dgNum;
46 | private final Hashtable _zabbixServers;
47 |
48 | public DBJob(SharedPoolDataSource spds, Query[] queries, String queriesGroup,
49 | Hashtable zabbixServers, String dbname) {
50 | this._spds = spds;
51 | this._queries = queries;
52 | this._queriesGroup = queriesGroup;
53 | this._zabbixServers = zabbixServers;
54 | this._dbname = dbname;
55 | this._dgNum = 0;
56 | }
57 |
58 | public DBJob(SharedPoolDataSource spds, Query[] queries, String queriesGroup,
59 | Hashtable zabbixServers, String dbname, int dgNum) {
60 | this._spds = spds;
61 | this._queries = queries;
62 | this._zabbixServers = zabbixServers;
63 | this._queriesGroup = queriesGroup;
64 | this._dbname = dbname;
65 | if (dgNum > 0) {
66 | this._dgNum = dgNum;
67 | } else {
68 | this._dgNum = 0;
69 | }
70 | }
71 |
72 | private boolean Alive(Connection _conn){
73 | try {
74 | PreparedStatement p_stmt = null;
75 | p_stmt = _conn
76 | .prepareStatement(Constants.ORACLE_VALIDATION_QUERY);
77 | ResultSet rs = null;
78 | rs = p_stmt.executeQuery();
79 | rs.next();
80 | //_conn.close();
81 | return true;
82 | } catch (Exception e) {
83 | // TODO Auto-generated catch block
84 | e.printStackTrace();
85 | SmartLogger.logThis(Level.DEBUG, "Database "
86 | + this._dbname + " is not alive");
87 | return false;
88 | }
89 | }
90 |
91 | @Override
92 | public void run() {
93 |
94 | SmartLogger.logThis(Level.DEBUG, "Starting dbJob on database "
95 | + _dbname + " " + _queriesGroup);
96 | final long start = System.currentTimeMillis();
97 |
98 | try {
99 | Connection dbConn=this._spds.getConnection();
100 | /* if (dbConn.isClosed()){
101 | dbConn = this._spds.getConnection();
102 | }*/
103 | if (Alive(dbConn)){
104 | _queue.offer(new ZabbixItem("alive", "1",this._dbname));
105 | _queue.offer(new ZabbixItem(Constants.PROJECT_NAME+"."+"Version", Constants.BANNER,this._dbname));
106 | ZabbixItem[] zitems = DBEnquiry.execute(this._queries,
107 | dbConn, this._dbname);
108 | if (zitems != null && zitems.length > 0) {
109 | SmartLogger.logThis(Level.DEBUG, "Item retrieved "
110 | + zitems.length + " on database " + this._dbname);
111 | for (int cnt = 0; cnt < zitems.length; cnt++) {
112 | String zItemName = zitems[cnt].getKey();
113 | if (this._dgNum > 0) {
114 | zItemName = zItemName + "_" + _dgNum;
115 | }
116 | SmartLogger.logThis(Level.DEBUG, "dbname " + this._dbname
117 | + " sending item " + zitems[cnt].getKey()
118 | + " value " + zitems[cnt].getValue());
119 | _queue.offer(new ZabbixItem(zItemName, zitems[cnt]
120 | .getValue(),
121 | _dbname));
122 | }
123 |
124 | }
125 | dbConn.close();
126 | Sender sender = new Sender(_queue, _zabbixServers, this._dbname);
127 | sender.run();
128 | } else{
129 | BlockingQueue _queue = new LinkedBlockingQueue();
130 | _queue.offer(new ZabbixItem("alive", "0",this._dbname));
131 | _queue.offer(new ZabbixItem(Constants.PROJECT_NAME+"."+"Version", Constants.BANNER,this._dbname));
132 | for (int cnt = 0; cnt < this._queries.length; cnt++) {
133 | _queue.offer(new ZabbixItem(_queries[cnt].getName(),
134 | _queries[cnt].getNoData(),_dbname));
135 |
136 | }
137 | Sender sender = new Sender(_queue, _zabbixServers,
138 | _dbname);
139 | sender.run();
140 | }
141 | } catch (Exception e) {
142 | SmartLogger.logThis(Level.ERROR, "Error on dbJob for database "
143 | + _dbname + " " + _queriesGroup + " error: " + e);
144 | } finally {
145 | if (_queries != null)
146 | _queries = null;
147 | }
148 | SmartLogger.logThis(Level.INFO, "Done with dbJob on database "
149 | + _dbname + " " + _queriesGroup + " elapsed time "
150 | + (System.currentTimeMillis() - start) + " ms");
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Orabbixmon.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of DBforBIX.
5 | *
6 | * Orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * Orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * Orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.orabbix;
21 |
22 | import java.lang.management.ManagementFactory;
23 | import java.lang.management.RuntimeMXBean;
24 | import java.util.Hashtable;
25 | import java.util.Locale;
26 | import java.util.concurrent.ExecutorService;
27 | import java.util.concurrent.Executors;
28 |
29 | import org.apache.commons.dbcp.datasources.SharedPoolDataSource;
30 | import org.apache.log4j.Level;
31 |
32 | import com.smartmarmot.common.SmartLogger;
33 | import com.smartmarmot.common.db.DBConn;
34 | import com.smartmarmot.common.db.DBJob;
35 |
36 | public class Orabbixmon implements Runnable {
37 |
38 | private boolean running = true;
39 | private boolean stopped = false;
40 |
41 | private static String configFile;
42 |
43 | public Orabbixmon(String _cfgfile) {
44 | try {
45 | configFile = _cfgfile;
46 | SmartLogger.logThis(Level.INFO, "Starting " + Constants.BANNER);
47 | } catch (Exception ex) {
48 | ex.printStackTrace();
49 | }
50 |
51 | // TODO Auto-generated constructor stub
52 | }
53 |
54 | public void terminate() {
55 | running = false;
56 | while (!stopped)
57 | try {
58 | Thread.sleep(1000);
59 | } catch (InterruptedException e) {
60 | e.printStackTrace();
61 | }
62 | System.out.println("Stopped");
63 | }
64 |
65 | @Override
66 | public void run() {
67 | try {
68 | Configurator cfg = null;
69 | try {
70 | cfg = new Configurator(configFile);
71 | } catch (Exception e) {
72 | SmartLogger.logThis(Level.ERROR,
73 | "Error while creating configurator with " + configFile
74 | + " " + e);
75 | }
76 | RuntimeMXBean rmxb = ManagementFactory.getRuntimeMXBean();
77 | String pid = rmxb.getName();
78 | SmartLogger.logThis(Level.INFO, Constants.PROJECT_NAME
79 | + " started with pid:" + pid.split("@")[0].toString());
80 | // System.out.print("pid: "+pid.split("@")[0].toString());
81 | String pidfile = cfg.getPidFile();
82 | try {
83 | Utility.writePid(pid.split("@")[0].toString(), pidfile);
84 | } catch (Exception e) {
85 | SmartLogger.logThis(Level.ERROR,
86 | "Error while trying to write pidfile " + e);
87 | }
88 |
89 | Locale.setDefault(Locale.US);
90 |
91 | DBConn[] myDBConn = cfg.getConnections();
92 |
93 | if (myDBConn == null) {
94 | SmartLogger.logThis(Level.ERROR,
95 | "ERROR on main - Connections is null");
96 | throw new Exception("ERROR on main - Connections is null");
97 |
98 | } else if (myDBConn.length == 0) {
99 | SmartLogger.logThis(Level.ERROR,
100 | "ERROR on main - Connections is empty");
101 | throw new Exception("ERROR on main - Connections is empty");
102 | }
103 |
104 | /**
105 | * retrieve maxThread
106 | */
107 | Integer maxThread = 0;
108 | try {
109 | maxThread = cfg.getMaxThread();
110 | } catch (Exception e) {
111 | SmartLogger.logThis(Level.WARN,
112 | "MaxThread not defined calculated maxThread = "
113 | + myDBConn.length * 3);
114 | }
115 | if (maxThread == null)
116 | maxThread = 0;
117 | if (maxThread == 0) {
118 | maxThread = myDBConn.length * 3;
119 | }
120 |
121 | ExecutorService executor = Executors.newFixedThreadPool(maxThread.intValue());
122 | /**
123 | * populate qbox
124 | */
125 | Hashtable qbox = new Hashtable();
126 | for (int i = 0; i < myDBConn.length; i++) {
127 | Querybox qboxtmp = Configurator.buildQueryBoxbyDBName(myDBConn[i].getName());
128 | qbox.put(myDBConn[i].getName(), qboxtmp);
129 | }// for (int i = 0; i < myDBConn.length; i++) {
130 |
131 | cfg = null;
132 | /**
133 | * daemon begin here
134 | */
135 | while (running) {
136 | /**
137 | * istantiate a new configurator
138 | */
139 | Configurator c = new Configurator(configFile);
140 |
141 | /*
142 | * here i rebuild DB's List
143 | */
144 | if (!c.isEqualsDBList(myDBConn)) {
145 |
146 | // rebuild connections DBConn[]
147 |
148 | myDBConn = c.rebuildDBList(myDBConn);
149 | for (int i = 1; i < myDBConn.length; i++) {
150 | if (!qbox.containsKey(myDBConn[i].getName())) {
151 | Querybox qboxtmp = Configurator.buildQueryBoxbyDBName(myDBConn[i].getName());
152 | qbox.put(myDBConn[i].getName(), qboxtmp);
153 | }
154 | }
155 | }// if (!c.isEqualsDBList(myDBConn)) {
156 |
157 | /*
158 | * ready to run query
159 | */
160 |
161 | for (int i = 0; i < myDBConn.length; i++) {
162 | Querybox actqb = qbox.get(myDBConn[i].getName());
163 | actqb.refresh();
164 | Query[] q = actqb.getQueries();
165 |
166 | SharedPoolDataSource spds = myDBConn[i].getSPDS();
167 |
168 | Hashtable zabbixServers = c.getZabbixServers();
169 | SmartLogger.logThis(
170 | Level.DEBUG,
171 | "Ready to run DBJob for dbname ->"
172 | + myDBConn[i].getName());
173 | Runnable runner = new DBJob(spds, q, Constants.QUERY_LIST,
174 | zabbixServers, myDBConn[i].getName());
175 | executor.execute(runner);
176 |
177 | }// for (int i = 0; i < myDBConn.length; i++) {
178 | Thread.sleep(60 * 1000);
179 | SmartLogger.logThis(Level.DEBUG, "Waking up Goood Morning");
180 | }
181 | } catch (Exception e1) {
182 | // TODO Auto-generated catch block
183 | System.out.println("Stopping");
184 | e1.printStackTrace();
185 | stopped = true;
186 | }
187 |
188 | }
189 |
190 | }
--------------------------------------------------------------------------------
/src/com/smartmarmot/common/db/DBEnquiry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 | package com.smartmarmot.common.db;
21 |
22 | import java.sql.Connection;
23 | import java.sql.PreparedStatement;
24 | import java.sql.ResultSet;
25 | import java.sql.ResultSetMetaData;
26 | import java.text.DateFormat;
27 | import java.text.SimpleDateFormat;
28 | import java.util.ArrayList;
29 | import java.util.Collection;
30 | import java.util.Date;
31 | import java.util.List;
32 |
33 | import org.apache.log4j.Level;
34 |
35 | import com.smartmarmot.common.SmartLogger;
36 | import com.smartmarmot.orabbix.Constants;
37 | import com.smartmarmot.orabbix.Query;
38 | import com.smartmarmot.zabbix.ZabbixItem;
39 |
40 |
41 |
42 | public class DBEnquiry {
43 |
44 |
45 |
46 | public static String ask(String _query, Connection _con, String queryName,
47 | String dbName, Boolean trim, Boolean space,
48 | List _excludeColumns) {
49 | String tempStr="";
50 | try{
51 | ResultSet rs = null;
52 | PreparedStatement p_stmt = _con.prepareStatement(_query);
53 | rs = p_stmt.executeQuery();
54 | ResultSetMetaData rsmd = rs.getMetaData();
55 | int numColumns = rsmd.getColumnCount();
56 | while (rs.next()) {
57 | for (int r = 1; r < numColumns + 1; r++) {
58 | Integer tmpInteger = new Integer(r);
59 | if (!_excludeColumns.contains(tmpInteger)) {
60 | if (trim) {
61 | tempStr = tempStr
62 | + rs.getObject(r).toString().trim();
63 | } else {
64 | tempStr = tempStr + rs.getObject(r).toString();
65 | }
66 | if (space && (r < numColumns)) {
67 | tempStr = tempStr + ' ';
68 | }
69 | }
70 | }
71 | }
72 | try{
73 | if (rs != null)
74 | rs.close();
75 | } catch (Exception ex) {
76 | SmartLogger.logThis(Level.ERROR,
77 | "Error on DBEnquiry while closing resultset "
78 | + ex.getMessage() + " on database=" + dbName);
79 | }
80 | } catch (Exception ex) {
81 | SmartLogger.logThis(Level.WARN,
82 | "Error while executing ->"
83 | + queryName
84 | + "- on database ->"
85 | + dbName
86 | + "- Exception received "
87 | + ex.getMessage());
88 | tempStr = null;
89 | }
90 | return tempStr;
91 | }
92 |
93 |
94 |
95 |
96 | public static ZabbixItem[] execute(Query[] _queries, Connection _conn,
97 | String dbname) {
98 | if (_queries == null || _queries.length < 1) {
99 | throw new IllegalArgumentException("Query's array is empty or null");
100 | }
101 | Connection con = _conn;
102 |
103 | Collection SZItems = new ArrayList();
104 | for (int i = 0; i < _queries.length; i++) {
105 | // System.out.println(queries[i].getSQL());
106 | DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
107 | String datetime = dateFormat.format(_queries[i].getNextrun());
108 |
109 | // Configurator.logThis(Level.DEBUG,"Actual query is "+_queries[i].getName()+" on database="+
110 | // dbname+" Period="+_queries[i].getPeriod()+" nextRun="+datetime);
111 | // System.out.println(queries[i].getName());
112 | String tempStr = new String("");
113 | // check if is the right time to execute the statements
114 | try {
115 |
116 | if (_queries[i].getActive()) {
117 | // if item is active
118 | Date now = new Date(System.currentTimeMillis());
119 | Date nextRun = _queries[i].getNextrun();
120 | if (now.after(nextRun)) {
121 |
122 | Date newNextRun = new Date(nextRun.getTime()
123 | + (_queries[i].getPeriod() * 1000 * 60));
124 | _queries[i].setNextrun(newNextRun);
125 |
126 | datetime = dateFormat.format(_queries[i].getNextrun());
127 | SmartLogger.logThis(Level.DEBUG, "Actual query is "
128 | + _queries[i].getName() + "Nextrun " + datetime
129 | + " on database=" + dbname + " Period="
130 | + _queries[i].getPeriod());
131 |
132 | /*
133 | * execute RaceConditionQuery
134 | */
135 | boolean racecond = true;
136 | String result = "";
137 | if (_queries[i].getRaceQuery() != null) {
138 | if (_queries[i].getRaceQuery().length() > 0) {
139 | SmartLogger.logThis(Level.DEBUG, "INFO:"
140 | + _queries[i].getName()
141 | + " RaceCondiftionQuery ->"
142 | + _queries[i].getRaceQuery());
143 | result = ask(
144 | _queries[i].getRaceQuery(),
145 | _conn,
146 | _queries[i].getName()
147 | + Constants.RACE_CONDITION_QUERY,
148 | dbname, _queries[i].getTrim(),
149 | _queries[i].getSpace(),
150 | _queries[i]
151 | .getRaceExcludeColumnsList());
152 | if (result != null) {
153 | if (_queries[i].getRaceValue() != null) {
154 | if (!result.equalsIgnoreCase(_queries[i]
155 | .getRaceValue())) {
156 | racecond = false;
157 | }
158 | }
159 | }
160 | }
161 | }
162 | result = "";
163 | if (racecond) {
164 | result = ask(_queries[i].getSQL().toString(),
165 | _conn, _queries[i].getName(), dbname,
166 | _queries[i].getTrim(), _queries[i]
167 | .getSpace(),
168 | _queries[i]
169 | .getExcludeColumnsList());
170 | if (result == null) {
171 | if (_queries[i].getNoData().length() > 0
172 | && _queries[i].getNoData() != null) {
173 | result = _queries[i].getNoData();
174 | }
175 | } else if (result.length() == 0) {
176 | if (_queries[i].getNoData().length() > 0
177 | && _queries[i].getNoData() != null) {
178 | result = _queries[i].getNoData();
179 | }
180 | }
181 |
182 | ZabbixItem zitem = new ZabbixItem(_queries[i]
183 | .getName(), result,dbname);
184 | SZItems.add(zitem);
185 | SmartLogger.logThis(Level.DEBUG,
186 | "I'm going to return " + result
187 | + " for query "
188 | + _queries[i].getName()
189 | + " on database=" + dbname);
190 | }
191 | }
192 |
193 | }
194 | } catch (Exception ex) {
195 | SmartLogger.logThis(Level.ERROR,
196 | "Error on DBEnquiry on query=" + _queries[i].getName()
197 | + " on database=" + dbname
198 | + " Error returned is " + ex);
199 | if (_queries[i].getNoData() != null)
200 | {
201 | if (_queries[i].getNoData().length() > 0)
202 | tempStr = _queries[i].getNoData();
203 | } else {
204 | tempStr = "";
205 | }
206 | ZabbixItem zitem = new ZabbixItem(_queries[i].getName(),
207 | tempStr , dbname);
208 | SZItems.add(zitem);
209 | SmartLogger.logThis(Level.DEBUG, "I'm going to return "
210 | + tempStr + " for query " + _queries[i].getName()
211 | + " on database=" + dbname);
212 | }
213 |
214 | }
215 | try {
216 | if (!con.isClosed())
217 | con.close();
218 | } catch (Exception ex) {
219 | SmartLogger.logThis(Level.ERROR,
220 | "Error on DBEnquiry while closing connection "
221 | + ex.getMessage() + " on database=" + dbname);
222 | }
223 | ZabbixItem[] items = SZItems.toArray(new ZabbixItem[0]);
224 | return items;
225 | }
226 | }
227 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Sender.java:
--------------------------------------------------------------------------------
1 | package com.smartmarmot.orabbix;
2 |
3 |
4 |
5 | /* This file is part of Zapcat.
6 | *
7 | * Zapcat is free software: you can redistribute it and/or modify it under the
8 | * terms of the GNU General Public License as published by the Free Software
9 | * Foundation, either version 3 of the License, or (at your option) any later
10 | * version.
11 | *
12 | * Zapcat is distributed in the hope that it will be useful, but WITHOUT ANY
13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 | * details.
16 | *
17 | * You should have received a copy of the GNU General Public License along with
18 | * Zapcat. If not, see .
19 | */
20 |
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 | import java.io.OutputStream;
24 | import java.io.UnsupportedEncodingException;
25 | import java.net.Socket;
26 | import java.util.Enumeration;
27 | import java.util.Hashtable;
28 | import java.util.concurrent.BlockingQueue;
29 |
30 | import org.apache.log4j.Level;
31 | import org.apache.log4j.Logger;
32 |
33 | import org.apache.commons.codec.binary.Base64;
34 |
35 | import com.smartmarmot.common.SmartLogger;
36 | import com.smartmarmot.zabbix.ZabbixItem;
37 | /**
38 | * A daemon thread that waits for and forwards data items to a Zabbix server.
39 | *
40 | * @author Kees Jan Koster Completely modified by
41 | * Andrea Dalle Vacche
42 | */
43 | public final class Sender implements Runnable {
44 | private static final Logger log = Logger.getLogger("Orabbix");
45 |
46 | private final BlockingQueue queue;
47 |
48 | private final Hashtable zabbixServers;
49 |
50 |
51 |
52 | private final String head;
53 |
54 | private final String host;
55 |
56 | private static final String middle = "";
57 |
58 | private static final String tail = "";
59 |
60 | private final byte[] response = new byte[1024];
61 |
62 | private boolean stopping = false;
63 |
64 | private static final int retryNumber = 10;
65 |
66 | private static final int TIMEOUT = 30 * 1000;
67 |
68 | /**
69 | * Create a new background sender.
70 | *
71 | * @param queue
72 | * The queue to get data items from.
73 | * @param zabbixServer
74 | * The name or IP of the machine to send the data to.
75 | * @param zabbixPort
76 | * The port number on that machine.
77 | * @param host
78 | * The host name, as defined in the host definition in Zabbix.
79 | *
80 | */
81 | public Sender(final BlockingQueue queue,
82 | Hashtable ZabbixServers,
83 |
84 | final String host) {
85 | /* super("Zabbix-sender");
86 | setDaemon(true);
87 | */
88 | this.queue = queue;
89 | this.zabbixServers = ZabbixServers;
90 | this.host = host;
91 | this.head = "" + base64Encode(host) + "";
92 | }
93 |
94 | /**
95 | * Indicate that we are about to stop.
96 | */
97 | public void stopping() {
98 | stopping = true;
99 | /*interrupt();*/
100 | }
101 |
102 | /**
103 | * @see java.lang.Thread#run()
104 | */
105 | @Override
106 | public void run() {
107 | try {
108 | final ZabbixItem item = queue.take();
109 | int retryCount = 0;
110 | trysend1:
111 | while (retryCount<= retryNumber){
112 | try{
113 | send(item.getKey(), item.getValue());
114 | break;
115 | }catch (Exception e){
116 | SmartLogger.logThis(Level.WARN,
117 | "Warning while sending item " + item.getKey()
118 | + " value " + item.getValue() + " on host "
119 | + host + " retry number " + retryCount
120 | + " error:" + e);
121 | Thread.sleep(1000);
122 | retryCount++;
123 | if (retryCount==retryNumber){
124 | SmartLogger.logThis(Level.WARN,
125 | "Error i didn't sent item " + item.getKey()
126 | + " on Zabbix server " + " on host "
127 | + host + " tried " + retryCount
128 | + " times");
129 | }
130 | continue trysend1;
131 | }
132 | }
133 |
134 |
135 | } catch (InterruptedException e) {
136 | if (!stopping) {
137 | log.warn("ignoring exception", e);
138 | }
139 |
140 | } catch (Exception e) {
141 | log.warn("ignoring exception", e);
142 | }
143 |
144 |
145 | // drain the queue
146 | while (queue.size() > 0) {
147 | final ZabbixItem item = queue.remove();
148 | int retryCount = 0;
149 | trysend2:
150 | while (retryCount<= retryNumber){
151 | try {
152 | send(item.getKey(), item.getValue());
153 | break;
154 | } catch (Exception e) {
155 | SmartLogger.logThis(Level.WARN,
156 | "Warning while sending item " + item.getKey()
157 | + " on host " + host + " retry number "
158 | + retryCount + " error:" + e);
159 | retryCount++;
160 | continue trysend2;
161 | }
162 |
163 | }
164 | if (retryCount==retryNumber){
165 | SmartLogger.logThis(Level.WARN, "Error i didn't sent item "
166 | + item.getKey() + " on host " + host + " tried "
167 | + retryCount);
168 | }
169 | }
170 | }
171 |
172 | /**
173 | * Encodes data for transmission to the server.
174 | *
175 | * This method encodes the data in the ASCII encoding, defaulting to
176 | * the platform default encoding if that is somehow unavailable.
177 | *
178 | * @param data
179 | * @return byte[] containing the encoded data
180 | */
181 | protected byte[] encodeString(String data) {
182 | try {
183 | return data.getBytes("ASCII");
184 | } catch (UnsupportedEncodingException e) {
185 | return data.getBytes();
186 | }
187 | }
188 |
189 | protected String base64Encode(String data) {
190 | return new String(Base64.encodeBase64(encodeString(data)));
191 | }
192 |
193 | private void send(final String key, final String value) throws IOException {
194 | final StringBuilder message = new StringBuilder(head);
195 | //message.append(Base64.encode(key));
196 | message.append(base64Encode(key));
197 | message.append(middle);
198 | //message.append(Base64.encode(value == null ? "" : value));
199 | message.append(base64Encode(value == null ? "" : value));
200 | message.append(tail);
201 |
202 | if (log.isDebugEnabled()) {
203 | SmartLogger.logThis(Level.DEBUG,"sending " + message);
204 | }
205 |
206 | Socket zabbix = null;
207 | OutputStream out = null;
208 | InputStream in = null;
209 | Enumeration serverlist = zabbixServers.keys();
210 |
211 | while (serverlist.hasMoreElements()){
212 | String zabbixServer = serverlist.nextElement();
213 | try {
214 | zabbix = new Socket(zabbixServer, zabbixServers.get(
215 | zabbixServer).intValue());
216 | zabbix.setSoTimeout(TIMEOUT);
217 |
218 | byte[] data = message.toString().getBytes("UTF-8");
219 |
220 | byte[] header = new byte[] {
221 | 'Z', 'B', 'X', 'D', '\1',
222 | (byte)(data.length & 0xFF),
223 | (byte)((data.length >> 8) & 0xFF),
224 | (byte)((data.length >> 16) & 0xFF),
225 | (byte)((data.length >> 24) & 0xFF),
226 | '\0', '\0', '\0', '\0'
227 | };
228 |
229 | byte[] packet = new byte[header.length + data.length];
230 | System.arraycopy(header, 0, packet, 0, header.length);
231 | System.arraycopy(data, 0, packet, header.length, data.length);
232 |
233 | out = zabbix.getOutputStream();
234 | out.write(packet);
235 | out.flush();
236 |
237 | in = zabbix.getInputStream();
238 | final int read = in.read(response);
239 | if (log.isDebugEnabled()) {
240 | SmartLogger.logThis(Level.DEBUG, "received "
241 | + new String(response));
242 | }
243 | if (read != 2 || response[0] != 'O' || response[1] != 'K') {
244 | SmartLogger.logThis(Level.WARN,
245 | "received unexpected response '"
246 | + new String(response) + "' for key '"
247 | + key + "'");
248 | }
249 | } catch (Exception ex){
250 | SmartLogger.logThis(Level.ERROR,
251 | "Error contacting Zabbix server " + zabbixServer
252 | + " on port "
253 | + zabbixServers.get(zabbixServer));
254 | }
255 |
256 | finally {
257 | if (in != null) {
258 | in.close();
259 | }
260 | if (out != null) {
261 | out.close();
262 | }
263 | if (zabbix != null) {
264 | zabbix.close();
265 | }
266 |
267 | }
268 | }
269 | }
270 | }
271 |
--------------------------------------------------------------------------------
/orabbix/conf/query.props.sample:
--------------------------------------------------------------------------------
1 | DefaultQueryPeriod=2
2 |
3 | QueryList=archive,audit,dbblockgets,dbconsistentgets,dbhitratio,dbphysicalread,dbversion,hitratio_body,hitratio_sqlarea,hitratio_table_proc, \
4 | lio_current_read,locks,maxprocs,maxsession,miss_latch,pga_aggregate_target, pga,phio_datafile_reads,phio_datafile_writes,phio_redo_writes,pinhitratio_body,pinhitratio_sqlarea,pinhitratio_table-proc,pinhitratio_trigger, \
5 | pool_dict_cache,pool_free_mem,pool_lib_cache,pool_misc,pool_sql_area,procnum,session_active,session_inactive,session,session_system,sga_buffer_cache, \
6 | sga_fixed,sga_java_pool,sga_large_pool,sga_log_buffer,sga_shared_pool,tbl_space,userconn,waits_controfileio,waits_directpath_read, \
7 | waits_file_io,waits_latch,waits_logwrite,waits_multiblock_read,waits_singleblock_read,hitratio_trigger,lio_block_changes,lio_consistent_read,waits_other,waits_sqlnet,users_locked,uptime,dbfilesize,dbsize
8 |
9 | dbfilesize.Query=select to_char(sum(bytes/1024/1024), 'FM99999999999999990') retvalue from dba_data_files
10 |
11 | dbsize.Query=SELECT to_char(sum( NVL(a.bytes/1024/1024 - NVL(f.bytes/1024/1024, 0), 0)), 'FM99999999999999990') retvalue \
12 | FROM sys.dba_tablespaces d, \
13 | (select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) a, \
14 | (select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) f \
15 | WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) \
16 | AND NOT (d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY')
17 |
18 | uptime.Query=select to_char((sysdate-startup_time)*86400, 'FM99999999999999990') retvalue from v$instance
19 |
20 | users_locked.Query=SELECT username||' '|| lock_date ||' '|| account_status FROM dba_users where ACCOUNT_STATUS like 'EXPIRED(GRACE)' or ACCOUNT_STATUS like 'LOCKED(TIMED)'
21 | users_locked.NoDataFound=none
22 |
23 |
24 | archive.Query=select round(A.LOGS*B.AVG/1024/1024/10) from ( SELECT COUNT (*) LOGS FROM V$LOG_HISTORY WHERE FIRST_TIME >= (sysdate -10/60/24)) A, ( SELECT Avg(BYTES) AVG, Count(1), Max(BYTES) Max_Bytes, Min(BYTES) Min_Bytes FROM v$log) B
25 | archive.RaceConditionQuery=select value from v$parameter where name='log_archive_start'
26 | archive.RaceConditionValue=FALSE
27 |
28 |
29 |
30 | audit.Query=select username "username", \
31 | to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "time_stamp", \
32 | action_name "statement", \
33 | os_username "os_username", \
34 | userhost "userhost", \
35 | returncode||decode(returncode,'1004','-Wrong Connection','1005','-NULL Password','1017','-Wrong Password','1045','-Insufficient Priviledge','0','-Login Accepted','--') "returncode" \
36 | from sys.dba_audit_session \
37 | where (sysdate - timestamp)*24 < 1 and returncode <> 0 \
38 | order by timestamp
39 | audit.NoDataFound=none
40 |
41 | dbblockgets.Query=select to_char(sum(decode(name,'db block gets', value,0))) "block_gets" \
42 | FROM v$sysstat
43 |
44 | dbconsistentgets.Query=select to_char(sum(decode(name,'consistent gets', value,0))) "consistent_gets" \
45 | FROM v$sysstat
46 |
47 | dbhitratio.Query=select ( \
48 | sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) - sum(decode(name,'physical reads', value,0))) / (sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) ) * 100 "hit_ratio" \
49 | FROM v$sysstat
50 | dbphysicalread.Query=select sum(decode(name,'physical reads', value,0)) "phys_reads" FROM v$sysstat
51 |
52 | dbversion.Query=select COMP_ID||' '||COMP_NAME||' '||VERSION||' '||STATUS||'
' from dba_registry union SELECT ' - SERVERNAME = '||UTL_INADDR.get_host_name ||' - SERVERADDRESS = '||UTL_INADDR.get_host_address||'
'from dual union SELECT ' - DB_NAME = '||SYS_CONTEXT ('USERENV', 'DB_NAME') ||' - INSTANCE_NAME = ' ||SYS_CONTEXT ('USERENV', 'INSTANCE_NAME')||'
' FROM dual
53 |
54 | sqlnotindexed.Query=SELECT SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))/ (SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))+SUM(DECODE(NAME, 'table scans (short tables)', VALUE, 0)))*100 SQL_NOT_INDEXED FROM V$SYSSTAT WHERE 1=1 AND ( NAME IN ('table scans (long tables)','table scans (short tables)') )
55 |
56 | hitratio_body.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='BODY'
57 | hitratio_sqlarea.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='SQL AREA'
58 | hitratio_trigger.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='TRIGGER'
59 | hitratio_table_proc.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace = 'TABLE/PROCEDURE'
60 |
61 | lio_block_changes.Query=SELECT to_char(SUM(DECODE(NAME,'db block changes',VALUE,0))) \
62 | FROM V$SYSSTAT \
63 | WHERE NAME ='db block changes'
64 |
65 | lio_consistent_read.Query=SELECT to_char(sum(decode(name,'consistent gets',value,0))) FROM V$SYSSTAT WHERE NAME ='consistent gets'
66 | lio_current_read.Query=SELECT to_char(sum(decode(name,'db block gets',value,0))) FROM V$SYSSTAT WHERE NAME ='db block gets'
67 |
68 | locks.Query=SELECT b.session_id AS sid, \
69 | NVL(b.oracle_username, '(oracle)') AS username, \
70 | a.owner AS object_owner, \
71 | a.object_name, \
72 | Decode(b.locked_mode, 0, 'None', \
73 | 1, 'Null (NULL)', \
74 | 2, 'Row-S (SS)', \
75 | 3, 'Row-X (SX)', \
76 | 4, 'Share (S)', \
77 | 5, 'S/Row-X (SSX)', \
78 | 6, 'Exclusive (X)', \
79 | b.locked_mode) locked_mode, \
80 | b.os_user_name \
81 | FROM dba_objects a, \
82 | v$locked_object b \
83 | WHERE a.object_id = b.object_id \
84 | ORDER BY 1, 2, 3, 4
85 |
86 | #locks.Query=select sn.USERNAME ||'@'||sn.machine, \
87 | '|SID->' || m.SID, \
88 | '|Serial->'|| sn.SERIAL#, \
89 | '|Lock Type->'||m.TYPE, \
90 | decode(LMODE, \
91 | 1, 'Null', \
92 | 2, 'Row-S (SS)', \
93 | 3, 'Row-X (SX)', \
94 | 4, 'Share', \
95 | 5, 'S/Row-X (SSX)', \
96 | 6, 'Exclusive') lock_type, \
97 | decode(REQUEST, \
98 | 0, 'None', \
99 | 1, 'Null', \
100 | 2, 'Row-S (SS)', \
101 | 3, 'Row-X (SX)', \
102 | 4, 'Share', \
103 | 5, 'S/Row-X (SSX)', \
104 | 6, 'Exclusive') lock_requested, \
105 | '|Time (Sec)->'||m.CTIME "Time(sec)", \
106 | '|ID1->'||m.ID1, \
107 | '|ID2->'||m.ID2, \
108 | '|SQL Text->'||t.SQL_TEXT \
109 | from v$session sn, \
110 | v$lock m , \
111 | v$sqltext t \
112 | where t.ADDRESS =sn.SQL_ADDRESS \
113 | and t.HASH_VALUE =sn.SQL_HASH_VALUE \
114 | and ((sn.SID =m.SID and m.REQUEST !=0) \
115 | or (sn.SID =m.SID and m.REQUEST =0 and LMODE !=4 and (ID1, ID2) in \
116 | (select s.ID1, s.ID2 \
117 | from v$lock S \
118 | where REQUEST !=0 \
119 | and s.ctime > 5 \
120 | and s.ID1 =m.ID1 \
121 | and s.ID2 =m.ID2))) \
122 | order by sn.USERNAME, sn.SID, t.PIECE
123 | locks.NoDataFound=none
124 |
125 |
126 | maxprocs.Query=select value "maxprocs" from v$parameter where name ='processes'
127 | maxsession.Query=select value "maxsess" from v$parameter where name ='sessions'
128 | miss_latch.Query=SELECT SUM(misses) FROM V$LATCH
129 | pga_aggregate_target.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'aggregate PGA target parameter'
130 | pga.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'total PGA inuse'
131 | phio_datafile_reads.Query=select to_char(sum(decode(name,'physical reads direct',value,0))) FROM V$SYSSTAT where name ='physical reads direct'
132 | phio_datafile_writes.Query=select to_char(sum(decode(name,'physical writes direct',value,0))) FROM V$SYSSTAT where name ='physical writes direct'
133 | phio_redo_writes.Query=select to_char(sum(decode(name,'redo writes',value,0))) FROM V$SYSSTAT where name ='redo writes'
134 | pinhitratio_body.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='BODY'
135 | pinhitratio_sqlarea.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='SQL AREA'
136 | pinhitratio_table-proc.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TABLE/PROCEDURE'
137 | pinhitratio_trigger.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TRIGGER'
138 | pool_dict_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'dictionary cache',(bytes)/(1024*1024),0),0)),2)) pool_dict_cache FROM V$SGASTAT
139 | pool_free_mem.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'free memory',(bytes)/(1024*1024),0),0)),2)) pool_free_mem FROM V$SGASTAT
140 | pool_lib_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',(bytes)/(1024*1024),0),0)),2)) pool_lib_cache FROM V$SGASTAT
141 | pool_misc.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area', 0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
142 | pool_sql_area.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'sql area',(bytes)/(1024*1024),0),0)),2)) pool_sql_area FROM V$SGASTAT
143 | procnum.Query=select count(*) "procnum" from v$process
144 | session_active.Query=select count(*) from v$session where TYPE!='BACKGROUND' and status='ACTIVE'
145 | session_inactive.Query=select SUM(Decode(Type, 'BACKGROUND', 0, Decode(Status, 'ACTIVE', 0, 1))) FROM V$SESSION
146 | session.Query=select count(*) from v$session
147 | session_system.Query=select SUM(Decode(Type, 'BACKGROUND', 1, 0)) system_sessions FROM V$SESSION
148 | sga_buffer_cache.Query=SELECT to_char(ROUND(SUM(decode(pool,NULL,decode(name,'db_block_buffers',(bytes)/(1024*1024),'buffer_cache',(bytes)/(1024*1024),0),0)),2)) sga_bufcache FROM V$SGASTAT
149 | sga_fixed.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'fixed_sga',(bytes)/(1024*1024),0),0)),2)) sga_fixed FROM V$SGASTAT
150 | sga_java_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'java pool',(bytes)/(1024*1024),0)),2)) sga_jpool FROM V$SGASTAT
151 | sga_large_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'large pool',(bytes)/(1024*1024),0)),2)) sga_lpool FROM V$SGASTAT
152 | sga_log_buffer.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'log_buffer',(bytes)/(1024*1024),0),0)),2)) sga_lbuffer FROM V$SGASTAT
153 | sga_shared_pool.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area',0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
154 |
155 | tbl_space.Query=SELECT * FROM ( \
156 | select '- Tablespace ->',t.tablespace_name ktablespace, \
157 | '- Type->',substr(t.contents, 1, 1) tipo, \
158 | '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
159 | '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
160 | '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
161 | '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
162 | '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
163 | '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
164 | from \
165 | ( select SUM(bytes) tbs_size, \
166 | SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
167 | from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
168 | from dba_data_files \
169 | union all \
170 | select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
171 | from dba_temp_files \
172 | ) \
173 | group by tablespace_name \
174 | ) d, \
175 | ( select SUM(bytes) free_space, \
176 | tablespace_name tablespace \
177 | from dba_free_space \
178 | group by tablespace_name \
179 | ) s, \
180 | dba_tablespaces t \
181 | where t.tablespace_name = d.tablespace(+) and \
182 | t.tablespace_name = s.tablespace(+) \
183 | order by 8) \
184 | where kperc > 93 \
185 | and tipo <>'T' \
186 | and tipo <>'U'
187 | tbl_space.NoDataFound=none
188 |
189 |
190 | userconn.Query=select count(username) from v$session where username is not null
191 | waits_controfileio.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
192 |
193 | waits_directpath_read.Query=SELECT to_char(sum(decode(event,'direct path read',total_waits,0))) DirectPathRead FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from ', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
194 |
195 | waits_file_io.Query=SELECT to_char(sum(decode(event,'file identify',total_waits, 'file open',total_waits,0))) FileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
196 |
197 | waits_latch.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, \
198 | 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO \
199 | FROM V$system_event WHERE 1=1 AND event not in ( \
200 | 'SQL*Net message from client', \
201 | 'SQL*Net more data from client', \
202 | 'pmon timer', 'rdbms ipc message', \
203 | 'rdbms ipc reply', 'smon timer')
204 |
205 | waits_logwrite.Query=SELECT to_char(sum(decode(event,'log file single write',total_waits, 'log file parallel write',total_waits,0))) LogWrite \
206 | FROM V$system_event WHERE 1=1 AND event not in ( \
207 | 'SQL*Net message from client', \
208 | 'SQL*Net more data from client', \
209 | 'pmon timer', 'rdbms ipc message', \
210 | 'rdbms ipc reply', 'smon timer')
211 |
212 | waits_multiblock_read.Query=SELECT to_char(sum(decode(event,'db file scattered read',total_waits,0))) MultiBlockRead \
213 | FROM V$system_event WHERE 1=1 AND event not in ( \
214 | 'SQL*Net message from client', \
215 | 'SQL*Net more data from client', \
216 | 'pmon timer', 'rdbms ipc message', \
217 | 'rdbms ipc reply', 'smon timer')
218 |
219 | waits_other.Query=SELECT to_char(sum(decode(event,'control file sequential read',0,'control file single write',0,'control file parallel write',0,'db file sequential read',0,'db file scattered read',0,'direct path read',0,'file identify',0,'file open',0,'SQL*Net message to client',0,'SQL*Net message to dblink',0, 'SQL*Net more data to client',0,'SQL*Net more data to dblink',0, 'SQL*Net break/reset to client',0,'SQL*Net break/reset to dblink',0, 'log file single write',0,'log file parallel write',0,total_waits))) Other FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
220 |
221 |
222 | waits_singleblock_read.Query=SELECT to_char(sum(decode(event,'db file sequential read',total_waits,0))) SingleBlockRead \
223 | FROM V$system_event WHERE 1=1 AND event not in ( \
224 | 'SQL*Net message from client', \
225 | 'SQL*Net more data from client', \
226 | 'pmon timer', 'rdbms ipc message', \
227 | 'rdbms ipc reply', 'smon timer')
228 |
229 | waits_sqlnet.Query=SELECT to_char(sum(decode(event,'SQL*Net message to client',total_waits,'SQL*Net message to dblink',total_waits,'SQL*Net more data to client',total_waits,'SQL*Net more data to dblink',total_waits,'SQL*Net break/reset to client',total_waits,'SQL*Net break/reset to dblink',total_waits,0))) SQLNET FROM V$system_event WHERE 1=1 \
230 | AND event not in ( 'SQL*Net message from client','SQL*Net more data from client','pmon timer','rdbms ipc message','rdbms ipc reply', 'smon timer')
231 |
232 |
--------------------------------------------------------------------------------
/orabbix/conf/query_a_1.props:
--------------------------------------------------------------------------------
1 | DefaultQueryPeriod=2
2 |
3 | QueryList=archive
4 | ,audit,dbblockgets,dbconsistentgets,dbhitratio,dbphysicalread,dbversion,hitratio_body,hitratio_sqlarea,hitratio_table_proc, \
5 | lio_current_read,locks,maxprocs,maxsession,miss_latch,pga_aggregate_target, pga,phio_datafile_reads,phio_datafile_writes,phio_redo_writes,pinhitratio_body,pinhitratio_sqlarea,pinhitratio_table-proc,pinhitratio_trigger, \
6 | pool_dict_cache,pool_free_mem,pool_lib_cache,pool_misc,pool_sql_area,procnum,session_active,session_inactive,session,session_system,sga_buffer_cache
7 |
8 | sga_fixed,sga_java_pool,sga_large_pool,sga_log_buffer,sga_shared_pool,tbl_space,userconn,waits_controfileio,waits_directpath_read, \
9 | waits_file_io,waits_latch,waits_logwrite,waits_multiblock_read,waits_singleblock_read,hitratio_trigger,lio_block_changes,lio_consistent_read,waits_other,waits_sqlnet,users_locked,uptime
10 |
11 | DataGuardPrimaryQueryList=dg_error,dg_sequence_number
12 | DataGuardStandbyQueryList=dg_sequence_number_stby
13 | RmanQueryList=rman_check_status
14 |
15 |
16 | rman_check_status.Query=select ' DB NAME->'||DB_NAME||'- ROW TYPE->'||ROW_TYPE||'- START TIME->'||to_char(start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') ||'- END TIME->'||to_char(end_time, 'Dy DD-Mon-YYYY HH24:MI:SS')||'- MBYTES PROCESSED->'||MBYTES_PROCESSED||'- OBJECT TYPE->'||OBJECT_TYPE||'- STATUS->'||STATUS||'- OUTPUT DEVICE->'||OUTPUT_DEVICE_TYPE||'- INPUT MB->'||INPUT_BYTES/1048576||'- OUT MB'||OUTPUT_BYTES/1048576 \
17 | FROM rc_rman_status \
18 | WHERE start_time > SYSDATE - 1 \
19 | AND ( STATUS like '%FAILED%' \
20 | OR STATUS like '%ERROR%') \
21 | ORDER BY END_TIME
22 |
23 | rman_check_status.NoDataFound=none
24 |
25 | uptime.Query=select to_char((sysdate-startup_time)*86400, 'FM99999999999999990') retvalue from v$instance
26 |
27 | users_locked.Query=SELECT username||' '|| lock_date ||' '|| account_status FROM dba_users where ACCOUNT_STATUS like 'EXPIRED(GRACE)' or ACCOUNT_STATUS like 'LOCKED(TIMED)'
28 | users_locked.NoDataFound=none
29 |
30 |
31 | archive.Query=AAAAAAAAAAA
32 | archive.Period=30
33 | archive.RaceConditionQuery=select value from v$parameter where name='log_archive_start'
34 | archive.RaceConditionValue=FALSE
35 |
36 |
37 |
38 | audit.Query=select username "username", \
39 | to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "time_stamp", \
40 | action_name "statement", \
41 | os_username "os_username", \
42 | userhost "userhost", \
43 | returncode||decode(returncode,'1004','-Wrong Connection','1005','-NULL Password','1017','-Wrong Password','1045','-Insufficient Priviledge','0','-Login Accepted','--') "returncode" \
44 | from sys.dba_audit_session \
45 | where (sysdate - timestamp)*24 < 1 and returncode <> 0 \
46 | order by timestamp
47 | audit.NoDataFound=none
48 |
49 | dbblockgets.Query=select to_char(sum(decode(name,'db block gets', value,0))) "block_gets" \
50 | FROM v$sysstat
51 |
52 | dbconsistentgets.Query=select to_char(sum(decode(name,'consistent gets', value,0))) "consistent_gets" \
53 | FROM v$sysstat
54 |
55 | dbhitratio.Query=select ( \
56 | sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) - sum(decode(name,'physical reads', value,0))) / (sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) ) * 100 "hit_ratio" \
57 | FROM v$sysstat
58 | dbphysicalread.Query=select sum(decode(name,'physical reads', value,0)) "phys_reads" FROM v$sysstat
59 |
60 | dbversion.Query=select COMP_ID||' '||COMP_NAME||' '||VERSION||' '||STATUS||'
' from dba_registry union SELECT ' - SERVERNAME = '||UTL_INADDR.get_host_name ||' - SERVERADDRESS = '||UTL_INADDR.get_host_address||'
'from dual union SELECT ' - DB_NAME = '||SYS_CONTEXT ('USERENV', 'DB_NAME') ||' - INSTANCE_NAME = ' ||SYS_CONTEXT ('USERENV', 'INSTANCE_NAME')||'
' FROM dual
61 |
62 | sqlnotindexed.Query=SELECT SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))/ (SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))+SUM(DECODE(NAME, 'table scans (short tables)', VALUE, 0)))*100 SQL_NOT_INDEXED FROM V$SYSSTAT WHERE 1=1 AND ( NAME IN ('table scans (long tables)','table scans (short tables)') )
63 |
64 | hitratio_body.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='BODY'
65 | hitratio_sqlarea.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='SQL AREA'
66 | hitratio_trigger.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='TRIGGER'
67 | hitratio_table_proc.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace = 'TABLE/PROCEDURE'
68 |
69 | lio_block_changes.Query=SELECT to_char(SUM(DECODE(NAME,'db block changes',VALUE,0))) \
70 | FROM V$SYSSTAT \
71 | WHERE NAME ='db block changes'
72 |
73 | lio_consistent_read.Query=SELECT to_char(sum(decode(name,'consistent gets',value,0))) FROM V$SYSSTAT WHERE NAME ='consistent gets'
74 | lio_current_read.Query=SELECT to_char(sum(decode(name,'db block gets',value,0))) FROM V$SYSSTAT WHERE NAME ='db block gets'
75 |
76 | locks.Query=SELECT b.session_id AS sid, \
77 | NVL(b.oracle_username, '(oracle)') AS username, \
78 | a.owner AS object_owner, \
79 | a.object_name, \
80 | Decode(b.locked_mode, 0, 'None', \
81 | 1, 'Null (NULL)', \
82 | 2, 'Row-S (SS)', \
83 | 3, 'Row-X (SX)', \
84 | 4, 'Share (S)', \
85 | 5, 'S/Row-X (SSX)', \
86 | 6, 'Exclusive (X)', \
87 | b.locked_mode) locked_mode, \
88 | b.os_user_name \
89 | FROM dba_objects a, \
90 | v$locked_object b \
91 | WHERE a.object_id = b.object_id \
92 | ORDER BY 1, 2, 3, 4
93 |
94 | #locks.Query=select sn.USERNAME ||'@'||sn.machine, \
95 | '|SID->' || m.SID, \
96 | '|Serial->'|| sn.SERIAL#, \
97 | '|Lock Type->'||m.TYPE, \
98 | decode(LMODE, \
99 | 1, 'Null', \
100 | 2, 'Row-S (SS)', \
101 | 3, 'Row-X (SX)', \
102 | 4, 'Share', \
103 | 5, 'S/Row-X (SSX)', \
104 | 6, 'Exclusive') lock_type, \
105 | decode(REQUEST, \
106 | 0, 'None', \
107 | 1, 'Null', \
108 | 2, 'Row-S (SS)', \
109 | 3, 'Row-X (SX)', \
110 | 4, 'Share', \
111 | 5, 'S/Row-X (SSX)', \
112 | 6, 'Exclusive') lock_requested, \
113 | '|Time (Sec)->'||m.CTIME "Time(sec)", \
114 | '|ID1->'||m.ID1, \
115 | '|ID2->'||m.ID2, \
116 | '|SQL Text->'||t.SQL_TEXT \
117 | from v$session sn, \
118 | v$lock m , \
119 | v$sqltext t \
120 | where t.ADDRESS =sn.SQL_ADDRESS \
121 | and t.HASH_VALUE =sn.SQL_HASH_VALUE \
122 | and ((sn.SID =m.SID and m.REQUEST !=0) \
123 | or (sn.SID =m.SID and m.REQUEST =0 and LMODE !=4 and (ID1, ID2) in \
124 | (select s.ID1, s.ID2 \
125 | from v$lock S \
126 | where REQUEST !=0 \
127 | and s.ctime > 5 \
128 | and s.ID1 =m.ID1 \
129 | and s.ID2 =m.ID2))) \
130 | order by sn.USERNAME, sn.SID, t.PIECE
131 | locks.NoDataFound=none
132 |
133 |
134 | maxprocs.Query=select value "maxprocs" from v$parameter where name ='processes'
135 | maxsession.Query=select value "maxsess" from v$parameter where name ='sessions'
136 | miss_latch.Query=SELECT SUM(misses) FROM V$LATCH
137 | pga_aggregate_target.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'aggregate PGA target parameter'
138 | pga.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'total PGA inuse'
139 | phio_datafile_reads.Query=select to_char(sum(decode(name,'physical reads direct',value,0))) FROM V$SYSSTAT where name ='physical reads direct'
140 | phio_datafile_writes.Query=select to_char(sum(decode(name,'physical writes direct',value,0))) FROM V$SYSSTAT where name ='physical writes direct'
141 | phio_redo_writes.Query=select to_char(sum(decode(name,'redo writes',value,0))) FROM V$SYSSTAT where name ='redo writes'
142 | pinhitratio_body.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='BODY'
143 | pinhitratio_sqlarea.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='SQL AREA'
144 | pinhitratio_table-proc.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TABLE/PROCEDURE'
145 | pinhitratio_trigger.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TRIGGER'
146 | pool_dict_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'dictionary cache',(bytes)/(1024*1024),0),0)),2)) pool_dict_cache FROM V$SGASTAT
147 | pool_free_mem.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'free memory',(bytes)/(1024*1024),0),0)),2)) pool_free_mem FROM V$SGASTAT
148 | pool_lib_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',(bytes)/(1024*1024),0),0)),2)) pool_lib_cache FROM V$SGASTAT
149 | pool_misc.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area', 0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
150 | pool_sql_area.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'sql area',(bytes)/(1024*1024),0),0)),2)) pool_sql_area FROM V$SGASTAT
151 | procnum.Query=select count(*) "procnum" from v$process
152 | session_active.Query=select count(*) from v$session where TYPE!='BACKGROUND' and status='ACTIVE'
153 | session_inactive.Query=select SUM(Decode(Type, 'BACKGROUND', 0, Decode(Status, 'ACTIVE', 0, 1))) FROM V$SESSION
154 | session.Query=select count(*) from v$session
155 | session_system.Query=select SUM(Decode(Type, 'BACKGROUND', 1, 0)) system_sessions FROM V$SESSION
156 | sga_buffer_cache.Query=SELECT to_char(ROUND(SUM(decode(pool,NULL,decode(name,'db_block_buffers',(bytes)/(1024*1024),'buffer_cache',(bytes)/(1024*1024),0),0)),2)) sga_bufcache FROM V$SGASTAT
157 | sga_fixed.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'fixed_sga',(bytes)/(1024*1024),0),0)),2)) sga_fixed FROM V$SGASTAT
158 | sga_java_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'java pool',(bytes)/(1024*1024),0)),2)) sga_jpool FROM V$SGASTAT
159 | sga_large_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'large pool',(bytes)/(1024*1024),0)),2)) sga_lpool FROM V$SGASTAT
160 | sga_log_buffer.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'log_buffer',(bytes)/(1024*1024),0),0)),2)) sga_lbuffer FROM V$SGASTAT
161 | sga_shared_pool.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area',0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
162 |
163 | tbl_space.Query=SELECT * FROM ( \
164 | select '- Tablespace ->',t.tablespace_name ktablespace, \
165 | '- Type->',substr(t.contents, 1, 1) tipo, \
166 | '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
167 | '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
168 | '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
169 | '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
170 | '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
171 | '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
172 | from \
173 | ( select SUM(bytes) tbs_size, \
174 | SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
175 | from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
176 | from dba_data_files \
177 | union all \
178 | select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
179 | from dba_temp_files \
180 | ) \
181 | group by tablespace_name \
182 | ) d, \
183 | ( select SUM(bytes) free_space, \
184 | tablespace_name tablespace \
185 | from dba_free_space \
186 | group by tablespace_name \
187 | ) s, \
188 | dba_tablespaces t \
189 | where t.tablespace_name = d.tablespace(+) and \
190 | t.tablespace_name = s.tablespace(+) \
191 | order by 8) \
192 | where kperc > 93 \
193 | and tipo <>'T' \
194 | and tipo <>'U'
195 | tbl_space.NoDataFound=none
196 |
197 |
198 | userconn.Query=select count(username) from v$session where username is not null
199 | waits_controfileio.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
200 |
201 | waits_directpath_read.Query=SELECT to_char(sum(decode(event,'direct path read',total_waits,0))) DirectPathRead FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from ', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
202 |
203 | waits_file_io.Query=SELECT to_char(sum(decode(event,'file identify',total_waits, 'file open',total_waits,0))) FileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
204 |
205 | waits_latch.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, \
206 | 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO \
207 | FROM V$system_event WHERE 1=1 AND event not in ( \
208 | 'SQL*Net message from client', \
209 | 'SQL*Net more data from client', \
210 | 'pmon timer', 'rdbms ipc message', \
211 | 'rdbms ipc reply', 'smon timer')
212 |
213 | waits_logwrite.Query=SELECT to_char(sum(decode(event,'log file single write',total_waits, 'log file parallel write',total_waits,0))) LogWrite \
214 | FROM V$system_event WHERE 1=1 AND event not in ( \
215 | 'SQL*Net message from client', \
216 | 'SQL*Net more data from client', \
217 | 'pmon timer', 'rdbms ipc message', \
218 | 'rdbms ipc reply', 'smon timer')
219 |
220 | waits_multiblock_read.Query=SELECT to_char(sum(decode(event,'db file scattered read',total_waits,0))) MultiBlockRead \
221 | FROM V$system_event WHERE 1=1 AND event not in ( \
222 | 'SQL*Net message from client', \
223 | 'SQL*Net more data from client', \
224 | 'pmon timer', 'rdbms ipc message', \
225 | 'rdbms ipc reply', 'smon timer')
226 |
227 | waits_other.Query=SELECT to_char(sum(decode(event,'control file sequential read',0,'control file single write',0,'control file parallel write',0,'db file sequential read',0,'db file scattered read',0,'direct path read',0,'file identify',0,'file open',0,'SQL*Net message to client',0,'SQL*Net message to dblink',0, 'SQL*Net more data to client',0,'SQL*Net more data to dblink',0, 'SQL*Net break/reset to client',0,'SQL*Net break/reset to dblink',0, 'log file single write',0,'log file parallel write',0,total_waits))) Other FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
228 |
229 |
230 | waits_singleblock_read.Query=SELECT to_char(sum(decode(event,'db file sequential read',total_waits,0))) SingleBlockRead \
231 | FROM V$system_event WHERE 1=1 AND event not in ( \
232 | 'SQL*Net message from client', \
233 | 'SQL*Net more data from client', \
234 | 'pmon timer', 'rdbms ipc message', \
235 | 'rdbms ipc reply', 'smon timer')
236 |
237 | waits_sqlnet.Query=SELECT to_char(sum(decode(event,'SQL*Net message to client',total_waits,'SQL*Net message to dblink',total_waits,'SQL*Net more data to client',total_waits,'SQL*Net more data to dblink',total_waits,'SQL*Net break/reset to client',total_waits,'SQL*Net break/reset to dblink',total_waits,0))) SQLNET FROM V$system_event WHERE 1=1 \
238 | AND event not in ( 'SQL*Net message from client','SQL*Net more data from client','pmon timer','rdbms ipc message','rdbms ipc reply', 'smon timer')
239 |
240 |
241 | dg_error.Query=SELECT ERROR_CODE, SEVERITY, MESSAGE, TO_CHAR(TIMESTAMP, 'DD-MON-RR HH24:MI:SS') TIMESTAMP FROM V$DATAGUARD_STATUS WHERE CALLOUT='YES' AND TIMESTAMP > SYSDATE-1
242 | dg_error.NoDataFound=none
243 |
244 | dg_sequence_number.Query=SELECT MAX (sequence#) FROM v$log_history
245 |
246 | #dg_sequence_number_stby.Query=SELECT MAX (sequence#) last_log_applied FROM v$log_history
247 | dg_sequence_number_stby.Query= select max(sequence#) from v$archived_log
248 |
--------------------------------------------------------------------------------
/orabbix/conf/query.props:
--------------------------------------------------------------------------------
1 | DefaultQueryPeriod=2
2 |
3 | QueryList=archive,audit,dbblockgets,dbconsistentgets,dbhitratio,dbphysicalread,dbversion,hitratio_body,hitratio_sqlarea,hitratio_table_proc, \
4 | lio_current_read,locks,maxprocs,maxsession,miss_latch,pga_aggregate_target, pga,phio_datafile_reads,phio_datafile_writes,phio_redo_writes,pinhitratio_body,pinhitratio_sqlarea,pinhitratio_table-proc,pinhitratio_trigger, \
5 | pool_dict_cache,pool_free_mem,pool_lib_cache,pool_misc,pool_sql_area,procnum,session_active,session_inactive,session,session_system,sga_buffer_cache, \
6 | sga_fixed,sga_java_pool,sga_large_pool,sga_log_buffer,sga_shared_pool,tbl_space,userconn,waits_controfileio,waits_directpath_read, \
7 | waits_file_io,waits_latch,waits_logwrite,waits_multiblock_read,waits_singleblock_read,hitratio_trigger,lio_block_changes,lio_consistent_read,waits_other,waits_sqlnet,users_locked,uptime
8 |
9 | DataGuardPrimaryQueryList=dg_error,dg_sequence_number
10 | DataGuardStandbyQueryList=dg_sequence_number_stby
11 | RmanQueryList=rman_check_status
12 |
13 |
14 | rman_check_status.Query=select ' DB NAME->'||DB_NAME||'- ROW TYPE->'||ROW_TYPE||'- START TIME->'||to_char(start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') ||'- END TIME->'||to_char(end_time, 'Dy DD-Mon-YYYY HH24:MI:SS')||'- MBYTES PROCESSED->'||MBYTES_PROCESSED||'- OBJECT TYPE->'||OBJECT_TYPE||'- STATUS->'||STATUS||'- OUTPUT DEVICE->'||OUTPUT_DEVICE_TYPE||'- INPUT MB->'||INPUT_BYTES/1048576||'- OUT MB'||OUTPUT_BYTES/1048576 \
15 | FROM rc_rman_status \
16 | WHERE start_time > SYSDATE - 1 \
17 | AND ( STATUS like '%FAILED%' \
18 | OR STATUS like '%ERROR%') \
19 | ORDER BY END_TIME
20 |
21 | rman_check_status.NoDataFound=none
22 |
23 | uptime.Query=select to_char((sysdate-startup_time)*86400, 'FM99999999999999990') retvalue from v$instance
24 |
25 | users_locked.Query=SELECT username||' '|| lock_date ||' '|| account_status FROM dba_users where ACCOUNT_STATUS like 'EXPIRED(GRACE)' or ACCOUNT_STATUS like 'LOCKED(TIMED)'
26 | users_locked.NoDataFound=none
27 |
28 |
29 | archive.Query=select round(A.LOGS*B.AVG/1024/1024/10) from ( SELECT COUNT (*) LOGS FROM V$LOG_HISTORY WHERE FIRST_TIME >= (sysdate -10/60/24)) A, ( SELECT Avg(BYTES) AVG, Count(1), Max(BYTES) Max_Bytes, Min(BYTES) Min_Bytes FROM v$log) B
30 | archive.RaceConditionQuery=select value from v$parameter where name='log_archive_start'
31 | archive.RaceConditionValue=FALSE
32 |
33 |
34 |
35 | audit.Query=select username "username", \
36 | to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "time_stamp", \
37 | action_name "statement", \
38 | os_username "os_username", \
39 | userhost "userhost", \
40 | returncode||decode(returncode,'1004','-Wrong Connection','1005','-NULL Password','1017','-Wrong Password','1045','-Insufficient Priviledge','0','-Login Accepted','--') "returncode" \
41 | from sys.dba_audit_session \
42 | where (sysdate - timestamp)*24 < 1 and returncode <> 0 \
43 | order by timestamp
44 | audit.NoDataFound=none
45 |
46 | dbblockgets.Query=select to_char(sum(decode(name,'db block gets', value,0))) "block_gets" \
47 | FROM v$sysstat
48 |
49 | dbconsistentgets.Query=select to_char(sum(decode(name,'consistent gets', value,0))) "consistent_gets" \
50 | FROM v$sysstat
51 |
52 | dbhitratio.Query=select ( \
53 | sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) - sum(decode(name,'physical reads', value,0))) / (sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) ) * 100 "hit_ratio" \
54 | FROM v$sysstat
55 | dbphysicalread.Query=select sum(decode(name,'physical reads', value,0)) "phys_reads" FROM v$sysstat
56 |
57 | dbversion.Query=select COMP_ID||' '||COMP_NAME||' '||VERSION||' '||STATUS||'
' from dba_registry union SELECT ' - SERVERNAME = '||UTL_INADDR.get_host_name ||' - SERVERADDRESS = '||UTL_INADDR.get_host_address||'
'from dual union SELECT ' - DB_NAME = '||SYS_CONTEXT ('USERENV', 'DB_NAME') ||' - INSTANCE_NAME = ' ||SYS_CONTEXT ('USERENV', 'INSTANCE_NAME')||'
' FROM dual
58 |
59 | sqlnotindexed.Query=SELECT SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))/ (SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))+SUM(DECODE(NAME, 'table scans (short tables)', VALUE, 0)))*100 SQL_NOT_INDEXED FROM V$SYSSTAT WHERE 1=1 AND ( NAME IN ('table scans (long tables)','table scans (short tables)') )
60 |
61 | hitratio_body.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='BODY'
62 | hitratio_sqlarea.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='SQL AREA'
63 | hitratio_trigger.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='TRIGGER'
64 | hitratio_table_proc.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace = 'TABLE/PROCEDURE'
65 |
66 | lio_block_changes.Query=SELECT to_char(SUM(DECODE(NAME,'db block changes',VALUE,0))) \
67 | FROM V$SYSSTAT \
68 | WHERE NAME ='db block changes'
69 |
70 | lio_consistent_read.Query=SELECT to_char(sum(decode(name,'consistent gets',value,0))) FROM V$SYSSTAT WHERE NAME ='consistent gets'
71 | lio_current_read.Query=SELECT to_char(sum(decode(name,'db block gets',value,0))) FROM V$SYSSTAT WHERE NAME ='db block gets'
72 |
73 | locks.Query=SELECT b.session_id AS sid, \
74 | NVL(b.oracle_username, '(oracle)') AS username, \
75 | a.owner AS object_owner, \
76 | a.object_name, \
77 | Decode(b.locked_mode, 0, 'None', \
78 | 1, 'Null (NULL)', \
79 | 2, 'Row-S (SS)', \
80 | 3, 'Row-X (SX)', \
81 | 4, 'Share (S)', \
82 | 5, 'S/Row-X (SSX)', \
83 | 6, 'Exclusive (X)', \
84 | b.locked_mode) locked_mode, \
85 | b.os_user_name \
86 | FROM dba_objects a, \
87 | v$locked_object b \
88 | WHERE a.object_id = b.object_id \
89 | ORDER BY 1, 2, 3, 4
90 |
91 | #locks.Query=select sn.USERNAME ||'@'||sn.machine, \
92 | '|SID->' || m.SID, \
93 | '|Serial->'|| sn.SERIAL#, \
94 | '|Lock Type->'||m.TYPE, \
95 | decode(LMODE, \
96 | 1, 'Null', \
97 | 2, 'Row-S (SS)', \
98 | 3, 'Row-X (SX)', \
99 | 4, 'Share', \
100 | 5, 'S/Row-X (SSX)', \
101 | 6, 'Exclusive') lock_type, \
102 | decode(REQUEST, \
103 | 0, 'None', \
104 | 1, 'Null', \
105 | 2, 'Row-S (SS)', \
106 | 3, 'Row-X (SX)', \
107 | 4, 'Share', \
108 | 5, 'S/Row-X (SSX)', \
109 | 6, 'Exclusive') lock_requested, \
110 | '|Time (Sec)->'||m.CTIME "Time(sec)", \
111 | '|ID1->'||m.ID1, \
112 | '|ID2->'||m.ID2, \
113 | '|SQL Text->'||t.SQL_TEXT \
114 | from v$session sn, \
115 | v$lock m , \
116 | v$sqltext t \
117 | where t.ADDRESS =sn.SQL_ADDRESS \
118 | and t.HASH_VALUE =sn.SQL_HASH_VALUE \
119 | and ((sn.SID =m.SID and m.REQUEST !=0) \
120 | or (sn.SID =m.SID and m.REQUEST =0 and LMODE !=4 and (ID1, ID2) in \
121 | (select s.ID1, s.ID2 \
122 | from v$lock S \
123 | where REQUEST !=0 \
124 | and s.ctime > 5 \
125 | and s.ID1 =m.ID1 \
126 | and s.ID2 =m.ID2))) \
127 | order by sn.USERNAME, sn.SID, t.PIECE
128 | locks.NoDataFound=none
129 |
130 |
131 | maxprocs.Query=select value "maxprocs" from v$parameter where name ='processes'
132 | maxsession.Query=select value "maxsess" from v$parameter where name ='sessions'
133 | miss_latch.Query=SELECT SUM(misses) FROM V$LATCH
134 | pga_aggregate_target.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'aggregate PGA target parameter'
135 | pga.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'total PGA inuse'
136 | phio_datafile_reads.Query=select to_char(sum(decode(name,'physical reads direct',value,0))) FROM V$SYSSTAT where name ='physical reads direct'
137 | phio_datafile_writes.Query=select to_char(sum(decode(name,'physical writes direct',value,0))) FROM V$SYSSTAT where name ='physical writes direct'
138 | phio_redo_writes.Query=select to_char(sum(decode(name,'redo writes',value,0))) FROM V$SYSSTAT where name ='redo writes'
139 | pinhitratio_body.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='BODY'
140 | pinhitratio_sqlarea.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='SQL AREA'
141 | pinhitratio_table-proc.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TABLE/PROCEDURE'
142 | pinhitratio_trigger.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TRIGGER'
143 | pool_dict_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'dictionary cache',(bytes)/(1024*1024),0),0)),2)) pool_dict_cache FROM V$SGASTAT
144 | pool_free_mem.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'free memory',(bytes)/(1024*1024),0),0)),2)) pool_free_mem FROM V$SGASTAT
145 | pool_lib_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',(bytes)/(1024*1024),0),0)),2)) pool_lib_cache FROM V$SGASTAT
146 | pool_misc.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area', 0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
147 | pool_sql_area.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'sql area',(bytes)/(1024*1024),0),0)),2)) pool_sql_area FROM V$SGASTAT
148 | procnum.Query=select count(*) "procnum" from v$process
149 | session_active.Query=select count(*) from v$session where TYPE!='BACKGROUND' and status='ACTIVE'
150 | session_inactive.Query=select SUM(Decode(Type, 'BACKGROUND', 0, Decode(Status, 'ACTIVE', 0, 1))) FROM V$SESSION
151 | session.Query=select count(*) from v$session
152 | session_system.Query=select SUM(Decode(Type, 'BACKGROUND', 1, 0)) system_sessions FROM V$SESSION
153 | sga_buffer_cache.Query=SELECT to_char(ROUND(SUM(decode(pool,NULL,decode(name,'db_block_buffers',(bytes)/(1024*1024),'buffer_cache',(bytes)/(1024*1024),0),0)),2)) sga_bufcache FROM V$SGASTAT
154 | sga_fixed.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'fixed_sga',(bytes)/(1024*1024),0),0)),2)) sga_fixed FROM V$SGASTAT
155 | sga_java_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'java pool',(bytes)/(1024*1024),0)),2)) sga_jpool FROM V$SGASTAT
156 | sga_large_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'large pool',(bytes)/(1024*1024),0)),2)) sga_lpool FROM V$SGASTAT
157 | sga_log_buffer.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'log_buffer',(bytes)/(1024*1024),0),0)),2)) sga_lbuffer FROM V$SGASTAT
158 | sga_shared_pool.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area',0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
159 |
160 | tbl_space.Query=SELECT * FROM ( \
161 | select '- Tablespace ->',t.tablespace_name ktablespace, \
162 | '- Type->',substr(t.contents, 1, 1) tipo, \
163 | '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
164 | '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
165 | '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
166 | '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
167 | '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
168 | '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
169 | from \
170 | ( select SUM(bytes) tbs_size, \
171 | SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
172 | from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
173 | from dba_data_files \
174 | union all \
175 | select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
176 | from dba_temp_files \
177 | ) \
178 | group by tablespace_name \
179 | ) d, \
180 | ( select SUM(bytes) free_space, \
181 | tablespace_name tablespace \
182 | from dba_free_space \
183 | group by tablespace_name \
184 | ) s, \
185 | dba_tablespaces t \
186 | where t.tablespace_name = d.tablespace(+) and \
187 | t.tablespace_name = s.tablespace(+) \
188 | order by 8) \
189 | where kperc > 93 \
190 | and tipo <>'T' \
191 | and tipo <>'U'
192 | tbl_space.NoDataFound=none
193 |
194 |
195 | userconn.Query=select count(username) from v$session where username is not null
196 | waits_controfileio.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
197 |
198 | waits_directpath_read.Query=SELECT to_char(sum(decode(event,'direct path read',total_waits,0))) DirectPathRead FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from ', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
199 |
200 | waits_file_io.Query=SELECT to_char(sum(decode(event,'file identify',total_waits, 'file open',total_waits,0))) FileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
201 |
202 | waits_latch.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, \
203 | 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO \
204 | FROM V$system_event WHERE 1=1 AND event not in ( \
205 | 'SQL*Net message from client', \
206 | 'SQL*Net more data from client', \
207 | 'pmon timer', 'rdbms ipc message', \
208 | 'rdbms ipc reply', 'smon timer')
209 |
210 | waits_logwrite.Query=SELECT to_char(sum(decode(event,'log file single write',total_waits, 'log file parallel write',total_waits,0))) LogWrite \
211 | FROM V$system_event WHERE 1=1 AND event not in ( \
212 | 'SQL*Net message from client', \
213 | 'SQL*Net more data from client', \
214 | 'pmon timer', 'rdbms ipc message', \
215 | 'rdbms ipc reply', 'smon timer')
216 |
217 | waits_multiblock_read.Query=SELECT to_char(sum(decode(event,'db file scattered read',total_waits,0))) MultiBlockRead \
218 | FROM V$system_event WHERE 1=1 AND event not in ( \
219 | 'SQL*Net message from client', \
220 | 'SQL*Net more data from client', \
221 | 'pmon timer', 'rdbms ipc message', \
222 | 'rdbms ipc reply', 'smon timer')
223 |
224 | waits_other.Query=SELECT to_char(sum(decode(event,'control file sequential read',0,'control file single write',0,'control file parallel write',0,'db file sequential read',0,'db file scattered read',0,'direct path read',0,'file identify',0,'file open',0,'SQL*Net message to client',0,'SQL*Net message to dblink',0, 'SQL*Net more data to client',0,'SQL*Net more data to dblink',0, 'SQL*Net break/reset to client',0,'SQL*Net break/reset to dblink',0, 'log file single write',0,'log file parallel write',0,total_waits))) Other FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
225 |
226 |
227 | waits_singleblock_read.Query=SELECT to_char(sum(decode(event,'db file sequential read',total_waits,0))) SingleBlockRead \
228 | FROM V$system_event WHERE 1=1 AND event not in ( \
229 | 'SQL*Net message from client', \
230 | 'SQL*Net more data from client', \
231 | 'pmon timer', 'rdbms ipc message', \
232 | 'rdbms ipc reply', 'smon timer')
233 |
234 | waits_sqlnet.Query=SELECT to_char(sum(decode(event,'SQL*Net message to client',total_waits,'SQL*Net message to dblink',total_waits,'SQL*Net more data to client',total_waits,'SQL*Net more data to dblink',total_waits,'SQL*Net break/reset to client',total_waits,'SQL*Net break/reset to dblink',total_waits,0))) SQLNET FROM V$system_event WHERE 1=1 \
235 | AND event not in ( 'SQL*Net message from client','SQL*Net more data from client','pmon timer','rdbms ipc message','rdbms ipc reply', 'smon timer')
236 |
237 |
238 | dg_error.Query=SELECT ERROR_CODE, SEVERITY, MESSAGE, TO_CHAR(TIMESTAMP, 'DD-MON-RR HH24:MI:SS') TIMESTAMP FROM V$DATAGUARD_STATUS WHERE CALLOUT='YES' AND TIMESTAMP > SYSDATE-1
239 | dg_error.NoDataFound=none
240 |
241 | dg_sequence_number.Query=SELECT MAX (sequence#) FROM v$log_history
242 |
243 | #dg_sequence_number_stby.Query=SELECT MAX (sequence#) last_log_applied FROM v$log_history
244 | dg_sequence_number_stby.Query= select max(sequence#) from v$archived_log
245 |
--------------------------------------------------------------------------------
/orabbix/conf/query - Copy.props:
--------------------------------------------------------------------------------
1 | DefaultQueryPeriod=2
2 |
3 | QueryList=archive,audit,dbblockgets,dbconsistentgets,dbhitratio,dbphysicalread,dbversion,hitratio_body,hitratio_sqlarea,hitratio_table_proc, \
4 | lio_current_read,locks,maxprocs,maxsession,miss_latch,pga_aggregate_target, pga,phio_datafile_reads,phio_datafile_writes,phio_redo_writes,pinhitratio_body,pinhitratio_sqlarea,pinhitratio_table-proc,pinhitratio_trigger, \
5 | pool_dict_cache,pool_free_mem,pool_lib_cache,pool_misc,pool_sql_area,procnum,session_active,session_inactive,session,session_system,sga_buffer_cache, \
6 | sga_fixed,sga_java_pool,sga_large_pool,sga_log_buffer,sga_shared_pool,tbl_space,userconn,waits_controfileio,waits_directpath_read, \
7 | waits_file_io,waits_latch,waits_logwrite,waits_multiblock_read,waits_singleblock_read,hitratio_trigger,lio_block_changes,lio_consistent_read,waits_other,waits_sqlnet,users_locked,uptime
8 |
9 | DataGuardPrimaryQueryList=dg_error,dg_sequence_number
10 | DataGuardStandbyQueryList=dg_sequence_number_stby
11 | RmanQueryList=rman_check_status
12 |
13 |
14 | rman_check_status.Query=select ' DB NAME->'||DB_NAME||'- ROW TYPE->'||ROW_TYPE||'- START TIME->'||to_char(start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') ||'- END TIME->'||to_char(end_time, 'Dy DD-Mon-YYYY HH24:MI:SS')||'- MBYTES PROCESSED->'||MBYTES_PROCESSED||'- OBJECT TYPE->'||OBJECT_TYPE||'- STATUS->'||STATUS||'- OUTPUT DEVICE->'||OUTPUT_DEVICE_TYPE||'- INPUT MB->'||INPUT_BYTES/1048576||'- OUT MB'||OUTPUT_BYTES/1048576 \
15 | FROM rc_rman_status \
16 | WHERE start_time > SYSDATE - 1 \
17 | AND ( STATUS like '%FAILED%' \
18 | OR STATUS like '%ERROR%') \
19 | ORDER BY END_TIME
20 |
21 | rman_check_status.NoDataFound=none
22 |
23 | uptime.Query=select to_char((sysdate-startup_time)*86400, 'FM99999999999999990') retvalue from v$instance
24 |
25 | users_locked.Query=SELECT username||' '|| lock_date ||' '|| account_status FROM dba_users where ACCOUNT_STATUS like 'EXPIRED(GRACE)' or ACCOUNT_STATUS like 'LOCKED(TIMED)'
26 | users_locked.NoDataFound=none
27 |
28 |
29 | archive.Query=select round(A.LOGS*B.AVG/1024/1024/10) from ( SELECT COUNT (*) LOGS FROM V$LOG_HISTORY WHERE FIRST_TIME >= (sysdate -10/60/24)) A, ( SELECT Avg(BYTES) AVG, Count(1), Max(BYTES) Max_Bytes, Min(BYTES) Min_Bytes FROM v$log) B
30 | archive.RaceConditionQuery=select value from v$parameter where name='log_archive_start'
31 | archive.RaceConditionValue=FALSE
32 |
33 |
34 |
35 | audit.Query=select username "username", \
36 | to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "time_stamp", \
37 | action_name "statement", \
38 | os_username "os_username", \
39 | userhost "userhost", \
40 | returncode||decode(returncode,'1004','-Wrong Connection','1005','-NULL Password','1017','-Wrong Password','1045','-Insufficient Priviledge','0','-Login Accepted','--') "returncode" \
41 | from sys.dba_audit_session \
42 | where (sysdate - timestamp)*24 < 1 and returncode <> 0 \
43 | order by timestamp
44 | audit.NoDataFound=none
45 |
46 | dbblockgets.Query=select to_char(sum(decode(name,'db block gets', value,0))) "block_gets" \
47 | FROM v$sysstat
48 |
49 | dbconsistentgets.Query=select to_char(sum(decode(name,'consistent gets', value,0))) "consistent_gets" \
50 | FROM v$sysstat
51 |
52 | dbhitratio.Query=select ( \
53 | sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) - sum(decode(name,'physical reads', value,0))) / (sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) ) * 100 "hit_ratio" \
54 | FROM v$sysstat
55 | dbphysicalread.Query=select sum(decode(name,'physical reads', value,0)) "phys_reads" FROM v$sysstat
56 |
57 | dbversion.Query=select COMP_ID||' '||COMP_NAME||' '||VERSION||' '||STATUS||'
' from dba_registry union SELECT ' - SERVERNAME = '||UTL_INADDR.get_host_name ||' - SERVERADDRESS = '||UTL_INADDR.get_host_address||'
'from dual union SELECT ' - DB_NAME = '||SYS_CONTEXT ('USERENV', 'DB_NAME') ||' - INSTANCE_NAME = ' ||SYS_CONTEXT ('USERENV', 'INSTANCE_NAME')||'
' FROM dual
58 |
59 | sqlnotindexed.Query=SELECT SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))/ (SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))+SUM(DECODE(NAME, 'table scans (short tables)', VALUE, 0)))*100 SQL_NOT_INDEXED FROM V$SYSSTAT WHERE 1=1 AND ( NAME IN ('table scans (long tables)','table scans (short tables)') )
60 |
61 | hitratio_body.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='BODY'
62 | hitratio_sqlarea.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='SQL AREA'
63 | hitratio_trigger.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='TRIGGER'
64 | hitratio_table_proc.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace = 'TABLE/PROCEDURE'
65 |
66 | lio_block_changes.Query=SELECT to_char(SUM(DECODE(NAME,'db block changes',VALUE,0))) \
67 | FROM V$SYSSTAT \
68 | WHERE NAME ='db block changes'
69 |
70 | lio_consistent_read.Query=SELECT to_char(sum(decode(name,'consistent gets',value,0))) FROM V$SYSSTAT WHERE NAME ='consistent gets'
71 | lio_current_read.Query=SELECT to_char(sum(decode(name,'db block gets',value,0))) FROM V$SYSSTAT WHERE NAME ='db block gets'
72 |
73 | locks.Query=SELECT b.session_id AS sid, \
74 | NVL(b.oracle_username, '(oracle)') AS username, \
75 | a.owner AS object_owner, \
76 | a.object_name, \
77 | Decode(b.locked_mode, 0, 'None', \
78 | 1, 'Null (NULL)', \
79 | 2, 'Row-S (SS)', \
80 | 3, 'Row-X (SX)', \
81 | 4, 'Share (S)', \
82 | 5, 'S/Row-X (SSX)', \
83 | 6, 'Exclusive (X)', \
84 | b.locked_mode) locked_mode, \
85 | b.os_user_name \
86 | FROM dba_objects a, \
87 | v$locked_object b \
88 | WHERE a.object_id = b.object_id \
89 | ORDER BY 1, 2, 3, 4
90 |
91 | #locks.Query=select sn.USERNAME ||'@'||sn.machine, \
92 | '|SID->' || m.SID, \
93 | '|Serial->'|| sn.SERIAL#, \
94 | '|Lock Type->'||m.TYPE, \
95 | decode(LMODE, \
96 | 1, 'Null', \
97 | 2, 'Row-S (SS)', \
98 | 3, 'Row-X (SX)', \
99 | 4, 'Share', \
100 | 5, 'S/Row-X (SSX)', \
101 | 6, 'Exclusive') lock_type, \
102 | decode(REQUEST, \
103 | 0, 'None', \
104 | 1, 'Null', \
105 | 2, 'Row-S (SS)', \
106 | 3, 'Row-X (SX)', \
107 | 4, 'Share', \
108 | 5, 'S/Row-X (SSX)', \
109 | 6, 'Exclusive') lock_requested, \
110 | '|Time (Sec)->'||m.CTIME "Time(sec)", \
111 | '|ID1->'||m.ID1, \
112 | '|ID2->'||m.ID2, \
113 | '|SQL Text->'||t.SQL_TEXT \
114 | from v$session sn, \
115 | v$lock m , \
116 | v$sqltext t \
117 | where t.ADDRESS =sn.SQL_ADDRESS \
118 | and t.HASH_VALUE =sn.SQL_HASH_VALUE \
119 | and ((sn.SID =m.SID and m.REQUEST !=0) \
120 | or (sn.SID =m.SID and m.REQUEST =0 and LMODE !=4 and (ID1, ID2) in \
121 | (select s.ID1, s.ID2 \
122 | from v$lock S \
123 | where REQUEST !=0 \
124 | and s.ctime > 5 \
125 | and s.ID1 =m.ID1 \
126 | and s.ID2 =m.ID2))) \
127 | order by sn.USERNAME, sn.SID, t.PIECE
128 | locks.NoDataFound=none
129 |
130 |
131 | maxprocs.Query=select value "maxprocs" from v$parameter where name ='processes'
132 | maxsession.Query=select value "maxsess" from v$parameter where name ='sessions'
133 | miss_latch.Query=SELECT SUM(misses) FROM V$LATCH
134 | pga_aggregate_target.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'aggregate PGA target parameter'
135 | pga.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'total PGA inuse'
136 | phio_datafile_reads.Query=select to_char(sum(decode(name,'physical reads direct',value,0))) FROM V$SYSSTAT where name ='physical reads direct'
137 | phio_datafile_writes.Query=select to_char(sum(decode(name,'physical writes direct',value,0))) FROM V$SYSSTAT where name ='physical writes direct'
138 | phio_redo_writes.Query=select to_char(sum(decode(name,'redo writes',value,0))) FROM V$SYSSTAT where name ='redo writes'
139 | pinhitratio_body.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='BODY'
140 | pinhitratio_sqlarea.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='SQL AREA'
141 | pinhitratio_table-proc.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TABLE/PROCEDURE'
142 | pinhitratio_trigger.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TRIGGER'
143 | pool_dict_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'dictionary cache',(bytes)/(1024*1024),0),0)),2)) pool_dict_cache FROM V$SGASTAT
144 | pool_free_mem.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'free memory',(bytes)/(1024*1024),0),0)),2)) pool_free_mem FROM V$SGASTAT
145 | pool_lib_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',(bytes)/(1024*1024),0),0)),2)) pool_lib_cache FROM V$SGASTAT
146 | pool_misc.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area', 0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
147 | pool_sql_area.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'sql area',(bytes)/(1024*1024),0),0)),2)) pool_sql_area FROM V$SGASTAT
148 | procnum.Query=select count(*) "procnum" from v$process
149 | session_active.Query=select count(*) from v$session where TYPE!='BACKGROUND' and status='ACTIVE'
150 | session_inactive.Query=select SUM(Decode(Type, 'BACKGROUND', 0, Decode(Status, 'ACTIVE', 0, 1))) FROM V$SESSION
151 | session.Query=select count(*) from v$session
152 | session_system.Query=select SUM(Decode(Type, 'BACKGROUND', 1, 0)) system_sessions FROM V$SESSION
153 | sga_buffer_cache.Query=SELECT to_char(ROUND(SUM(decode(pool,NULL,decode(name,'db_block_buffers',(bytes)/(1024*1024),'buffer_cache',(bytes)/(1024*1024),0),0)),2)) sga_bufcache FROM V$SGASTAT
154 | sga_fixed.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'fixed_sga',(bytes)/(1024*1024),0),0)),2)) sga_fixed FROM V$SGASTAT
155 | sga_java_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'java pool',(bytes)/(1024*1024),0)),2)) sga_jpool FROM V$SGASTAT
156 | sga_large_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'large pool',(bytes)/(1024*1024),0)),2)) sga_lpool FROM V$SGASTAT
157 | sga_log_buffer.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'log_buffer',(bytes)/(1024*1024),0),0)),2)) sga_lbuffer FROM V$SGASTAT
158 | sga_shared_pool.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area',0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
159 |
160 | tbl_space.Query=SELECT * FROM ( \
161 | select '- Tablespace ->',t.tablespace_name ktablespace, \
162 | '- Type->',substr(t.contents, 1, 1) tipo, \
163 | '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
164 | '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
165 | '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
166 | '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
167 | '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
168 | '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
169 | from \
170 | ( select SUM(bytes) tbs_size, \
171 | SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
172 | from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
173 | from dba_data_files \
174 | union all \
175 | select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
176 | from dba_temp_files \
177 | ) \
178 | group by tablespace_name \
179 | ) d, \
180 | ( select SUM(bytes) free_space, \
181 | tablespace_name tablespace \
182 | from dba_free_space \
183 | group by tablespace_name \
184 | ) s, \
185 | dba_tablespaces t \
186 | where t.tablespace_name = d.tablespace(+) and \
187 | t.tablespace_name = s.tablespace(+) \
188 | order by 8) \
189 | where kperc > 93 \
190 | and tipo <>'T' \
191 | and tipo <>'U'
192 | tbl_space.NoDataFound=none
193 |
194 |
195 | userconn.Query=select count(username) from v$session where username is not null
196 | waits_controfileio.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
197 |
198 | waits_directpath_read.Query=SELECT to_char(sum(decode(event,'direct path read',total_waits,0))) DirectPathRead FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from ', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
199 |
200 | waits_file_io.Query=SELECT to_char(sum(decode(event,'file identify',total_waits, 'file open',total_waits,0))) FileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
201 |
202 | waits_latch.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, \
203 | 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO \
204 | FROM V$system_event WHERE 1=1 AND event not in ( \
205 | 'SQL*Net message from client', \
206 | 'SQL*Net more data from client', \
207 | 'pmon timer', 'rdbms ipc message', \
208 | 'rdbms ipc reply', 'smon timer')
209 |
210 | waits_logwrite.Query=SELECT to_char(sum(decode(event,'log file single write',total_waits, 'log file parallel write',total_waits,0))) LogWrite \
211 | FROM V$system_event WHERE 1=1 AND event not in ( \
212 | 'SQL*Net message from client', \
213 | 'SQL*Net more data from client', \
214 | 'pmon timer', 'rdbms ipc message', \
215 | 'rdbms ipc reply', 'smon timer')
216 |
217 | waits_multiblock_read.Query=SELECT to_char(sum(decode(event,'db file scattered read',total_waits,0))) MultiBlockRead \
218 | FROM V$system_event WHERE 1=1 AND event not in ( \
219 | 'SQL*Net message from client', \
220 | 'SQL*Net more data from client', \
221 | 'pmon timer', 'rdbms ipc message', \
222 | 'rdbms ipc reply', 'smon timer')
223 |
224 | waits_other.Query=SELECT to_char(sum(decode(event,'control file sequential read',0,'control file single write',0,'control file parallel write',0,'db file sequential read',0,'db file scattered read',0,'direct path read',0,'file identify',0,'file open',0,'SQL*Net message to client',0,'SQL*Net message to dblink',0, 'SQL*Net more data to client',0,'SQL*Net more data to dblink',0, 'SQL*Net break/reset to client',0,'SQL*Net break/reset to dblink',0, 'log file single write',0,'log file parallel write',0,total_waits))) Other FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
225 |
226 |
227 | waits_singleblock_read.Query=SELECT to_char(sum(decode(event,'db file sequential read',total_waits,0))) SingleBlockRead \
228 | FROM V$system_event WHERE 1=1 AND event not in ( \
229 | 'SQL*Net message from client', \
230 | 'SQL*Net more data from client', \
231 | 'pmon timer', 'rdbms ipc message', \
232 | 'rdbms ipc reply', 'smon timer')
233 |
234 | waits_sqlnet.Query=SELECT to_char(sum(decode(event,'SQL*Net message to client',total_waits,'SQL*Net message to dblink',total_waits,'SQL*Net more data to client',total_waits,'SQL*Net more data to dblink',total_waits,'SQL*Net break/reset to client',total_waits,'SQL*Net break/reset to dblink',total_waits,0))) SQLNET FROM V$system_event WHERE 1=1 \
235 | AND event not in ( 'SQL*Net message from client','SQL*Net more data from client','pmon timer','rdbms ipc message','rdbms ipc reply', 'smon timer')
236 |
237 |
238 | dg_error.Query=SELECT ERROR_CODE, SEVERITY, MESSAGE, TO_CHAR(TIMESTAMP, 'DD-MON-RR HH24:MI:SS') TIMESTAMP FROM V$DATAGUARD_STATUS WHERE CALLOUT='YES' AND TIMESTAMP > SYSDATE-1
239 | dg_error.NoDataFound=none
240 |
241 | dg_sequence_number.Query=SELECT MAX (sequence#) FROM v$log_history
242 |
243 | #dg_sequence_number_stby.Query=SELECT MAX (sequence#) last_log_applied FROM v$log_history
244 | dg_sequence_number_stby.Query= select max(sequence#) from v$archived_log
245 |
--------------------------------------------------------------------------------
/orabbix/conf/query_b.props:
--------------------------------------------------------------------------------
1 | DefaultQueryPeriod=2
2 |
3 | archive,audit,dbblockgets,dbconsistentgets,dbhitratio,dbphysicalread,dbversion,hitratio_body,hitratio_sqlarea,hitratio_table_proc, \
4 | lio_current_read,locks,maxprocs,maxsession,miss_latch,pga_aggregate_target, pga,phio_datafile_reads,phio_datafile_writes,phio_redo_writes,pinhitratio_body,pinhitratio_sqlarea,pinhitratio_table-proc,pinhitratio_trigger, \
5 | pool_dict_cache,pool_free_mem,pool_lib_cache,pool_misc,pool_sql_area,procnum,session_active,session_inactive,session,session_system,sga_buffer_cache
6 |
7 | QueryList=sga_fixed,sga_java_pool,sga_large_pool,sga_log_buffer,sga_shared_pool,tbl_space,userconn,waits_controfileio,waits_directpath_read, \
8 | waits_file_io,waits_latch,waits_logwrite,waits_multiblock_read,waits_singleblock_read,hitratio_trigger,lio_block_changes,lio_consistent_read,waits_other,waits_sqlnet,users_locked,uptime
9 |
10 | DataGuardPrimaryQueryList=dg_error,dg_sequence_number
11 | DataGuardStandbyQueryList=dg_sequence_number_stby
12 | RmanQueryList=rman_check_status
13 |
14 |
15 | rman_check_status.Query=select ' DB NAME->'||DB_NAME||'- ROW TYPE->'||ROW_TYPE||'- START TIME->'||to_char(start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') ||'- END TIME->'||to_char(end_time, 'Dy DD-Mon-YYYY HH24:MI:SS')||'- MBYTES PROCESSED->'||MBYTES_PROCESSED||'- OBJECT TYPE->'||OBJECT_TYPE||'- STATUS->'||STATUS||'- OUTPUT DEVICE->'||OUTPUT_DEVICE_TYPE||'- INPUT MB->'||INPUT_BYTES/1048576||'- OUT MB'||OUTPUT_BYTES/1048576 \
16 | FROM rc_rman_status \
17 | WHERE start_time > SYSDATE - 1 \
18 | AND ( STATUS like '%FAILED%' \
19 | OR STATUS like '%ERROR%') \
20 | ORDER BY END_TIME
21 |
22 | rman_check_status.NoDataFound=none
23 |
24 | uptime.Query=select to_char((sysdate-startup_time)*86400, 'FM99999999999999990') retvalue from v$instance
25 |
26 | users_locked.Query=SELECT username||' '|| lock_date ||' '|| account_status FROM dba_users where ACCOUNT_STATUS like 'EXPIRED(GRACE)' or ACCOUNT_STATUS like 'LOCKED(TIMED)'
27 | users_locked.NoDataFound=none
28 |
29 |
30 | archive.Query=select round(A.LOGS*B.AVG/1024/1024/10) from ( SELECT COUNT (*) LOGS FROM V$LOG_HISTORY WHERE FIRST_TIME >= (sysdate -10/60/24)) A, ( SELECT Avg(BYTES) AVG, Count(1), Max(BYTES) Max_Bytes, Min(BYTES) Min_Bytes FROM v$log) B
31 | archive.RaceConditionQuery=select value from v$parameter where name='log_archive_start'
32 | archive.RaceConditionValue=FALSE
33 |
34 |
35 |
36 | audit.Query=select username "username", \
37 | to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "time_stamp", \
38 | action_name "statement", \
39 | os_username "os_username", \
40 | userhost "userhost", \
41 | returncode||decode(returncode,'1004','-Wrong Connection','1005','-NULL Password','1017','-Wrong Password','1045','-Insufficient Priviledge','0','-Login Accepted','--') "returncode" \
42 | from sys.dba_audit_session \
43 | where (sysdate - timestamp)*24 < 1 and returncode <> 0 \
44 | order by timestamp
45 | audit.NoDataFound=none
46 |
47 |
48 | dbblockgets.Query=select to_char(sum(decode(name,'db block gets', value,0))) "block_gets" \
49 | FROM v$sysstat
50 |
51 | dbconsistentgets.Query=select to_char(sum(decode(name,'consistent gets', value,0))) "consistent_gets" \
52 | FROM v$sysstat
53 |
54 | dbhitratio.Query=select ( \
55 | sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) - sum(decode(name,'physical reads', value,0))) / (sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) ) * 100 "hit_ratio" \
56 | FROM v$sysstat
57 | dbphysicalread.Query=select sum(decode(name,'physical reads', value,0)) "phys_reads" FROM v$sysstat
58 |
59 | dbversion.Query=select COMP_ID||' '||COMP_NAME||' '||VERSION||' '||STATUS||'
' from dba_registry union SELECT ' - SERVERNAME = '||UTL_INADDR.get_host_name ||' - SERVERADDRESS = '||UTL_INADDR.get_host_address||'
'from dual union SELECT ' - DB_NAME = '||SYS_CONTEXT ('USERENV', 'DB_NAME') ||' - INSTANCE_NAME = ' ||SYS_CONTEXT ('USERENV', 'INSTANCE_NAME')||'
' FROM dual
60 |
61 | sqlnotindexed.Query=SELECT SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))/ (SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))+SUM(DECODE(NAME, 'table scans (short tables)', VALUE, 0)))*100 SQL_NOT_INDEXED FROM V$SYSSTAT WHERE 1=1 AND ( NAME IN ('table scans (long tables)','table scans (short tables)') )
62 |
63 | hitratio_body.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='BODY'
64 | hitratio_sqlarea.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='SQL AREA'
65 | hitratio_trigger.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='TRIGGER'
66 | hitratio_table_proc.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace = 'TABLE/PROCEDURE'
67 |
68 | lio_block_changes.Query=SELECT to_char(SUM(DECODE(NAME,'db block changes',VALUE,0))) \
69 | FROM V$SYSSTAT \
70 | WHERE NAME ='db block changes'
71 |
72 | lio_consistent_read.Query=SELECT to_char(sum(decode(name,'consistent gets',value,0))) FROM V$SYSSTAT WHERE NAME ='consistent gets'
73 | lio_current_read.Query=SELECT to_char(sum(decode(name,'db block gets',value,0))) FROM V$SYSSTAT WHERE NAME ='db block gets'
74 |
75 | locks.Query=SELECT b.session_id AS sid, \
76 | NVL(b.oracle_username, '(oracle)') AS username, \
77 | a.owner AS object_owner, \
78 | a.object_name, \
79 | Decode(b.locked_mode, 0, 'None', \
80 | 1, 'Null (NULL)', \
81 | 2, 'Row-S (SS)', \
82 | 3, 'Row-X (SX)', \
83 | 4, 'Share (S)', \
84 | 5, 'S/Row-X (SSX)', \
85 | 6, 'Exclusive (X)', \
86 | b.locked_mode) locked_mode, \
87 | b.os_user_name \
88 | FROM dba_objects a, \
89 | v$locked_object b \
90 | WHERE a.object_id = b.object_id \
91 | ORDER BY 1, 2, 3, 4
92 |
93 | #locks.Query=select sn.USERNAME ||'@'||sn.machine, \
94 | '|SID->' || m.SID, \
95 | '|Serial->'|| sn.SERIAL#, \
96 | '|Lock Type->'||m.TYPE, \
97 | decode(LMODE, \
98 | 1, 'Null', \
99 | 2, 'Row-S (SS)', \
100 | 3, 'Row-X (SX)', \
101 | 4, 'Share', \
102 | 5, 'S/Row-X (SSX)', \
103 | 6, 'Exclusive') lock_type, \
104 | decode(REQUEST, \
105 | 0, 'None', \
106 | 1, 'Null', \
107 | 2, 'Row-S (SS)', \
108 | 3, 'Row-X (SX)', \
109 | 4, 'Share', \
110 | 5, 'S/Row-X (SSX)', \
111 | 6, 'Exclusive') lock_requested, \
112 | '|Time (Sec)->'||m.CTIME "Time(sec)", \
113 | '|ID1->'||m.ID1, \
114 | '|ID2->'||m.ID2, \
115 | '|SQL Text->'||t.SQL_TEXT \
116 | from v$session sn, \
117 | v$lock m , \
118 | v$sqltext t \
119 | where t.ADDRESS =sn.SQL_ADDRESS \
120 | and t.HASH_VALUE =sn.SQL_HASH_VALUE \
121 | and ((sn.SID =m.SID and m.REQUEST !=0) \
122 | or (sn.SID =m.SID and m.REQUEST =0 and LMODE !=4 and (ID1, ID2) in \
123 | (select s.ID1, s.ID2 \
124 | from v$lock S \
125 | where REQUEST !=0 \
126 | and s.ctime > 5 \
127 | and s.ID1 =m.ID1 \
128 | and s.ID2 =m.ID2))) \
129 | order by sn.USERNAME, sn.SID, t.PIECE
130 | locks.NoDataFound=none
131 |
132 |
133 | maxprocs.Query=select value "maxprocs" from v$parameter where name ='processes'
134 | maxsession.Query=select value "maxsess" from v$parameter where name ='sessions'
135 | miss_latch.Query=SELECT SUM(misses) FROM V$LATCH
136 | pga_aggregate_target.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'aggregate PGA target parameter'
137 | pga.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'total PGA inuse'
138 | phio_datafile_reads.Query=select to_char(sum(decode(name,'physical reads direct',value,0))) FROM V$SYSSTAT where name ='physical reads direct'
139 | phio_datafile_writes.Query=select to_char(sum(decode(name,'physical writes direct',value,0))) FROM V$SYSSTAT where name ='physical writes direct'
140 | phio_redo_writes.Query=select to_char(sum(decode(name,'redo writes',value,0))) FROM V$SYSSTAT where name ='redo writes'
141 | pinhitratio_body.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='BODY'
142 | pinhitratio_sqlarea.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='SQL AREA'
143 | pinhitratio_table-proc.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TABLE/PROCEDURE'
144 | pinhitratio_trigger.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TRIGGER'
145 | pool_dict_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'dictionary cache',(bytes)/(1024*1024),0),0)),2)) pool_dict_cache FROM V$SGASTAT
146 | pool_free_mem.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'free memory',(bytes)/(1024*1024),0),0)),2)) pool_free_mem FROM V$SGASTAT
147 | pool_lib_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',(bytes)/(1024*1024),0),0)),2)) pool_lib_cache FROM V$SGASTAT
148 | pool_misc.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area', 0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
149 | pool_sql_area.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'sql area',(bytes)/(1024*1024),0),0)),2)) pool_sql_area FROM V$SGASTAT
150 | procnum.Query=select count(*) "procnum" from v$process
151 | session_active.Query=select count(*) from v$session where TYPE!='BACKGROUND' and status='ACTIVE'
152 | session_inactive.Query=select SUM(Decode(Type, 'BACKGROUND', 0, Decode(Status, 'ACTIVE', 0, 1))) FROM V$SESSION
153 | session.Query=select count(*) from v$session
154 | session_system.Query=select SUM(Decode(Type, 'BACKGROUND', 1, 0)) system_sessions FROM V$SESSION
155 | sga_buffer_cache.Query=SELECT to_char(ROUND(SUM(decode(pool,NULL,decode(name,'db_block_buffers',(bytes)/(1024*1024),'buffer_cache',(bytes)/(1024*1024),0),0)),2)) sga_bufcache FROM V$SGASTAT
156 | sga_fixed.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'fixed_sga',(bytes)/(1024*1024),0),0)),2)) sga_fixed FROM V$SGASTAT
157 | sga_java_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'java pool',(bytes)/(1024*1024),0)),2)) sga_jpool FROM V$SGASTAT
158 | sga_large_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'large pool',(bytes)/(1024*1024),0)),2)) sga_lpool FROM V$SGASTAT
159 | sga_log_buffer.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'log_buffer',(bytes)/(1024*1024),0),0)),2)) sga_lbuffer FROM V$SGASTAT
160 | sga_shared_pool.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area',0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
161 |
162 | tbl_space.Query=SELECT * FROM ( \
163 | select '- Tablespace ->',t.tablespace_name ktablespace, \
164 | '- Type->',substr(t.contents, 1, 1) tipo, \
165 | '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
166 | '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
167 | '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
168 | '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
169 | '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
170 | '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
171 | from \
172 | ( select SUM(bytes) tbs_size, \
173 | SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
174 | from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
175 | from dba_data_files \
176 | union all \
177 | select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
178 | from dba_temp_files \
179 | ) \
180 | group by tablespace_name \
181 | ) d, \
182 | ( select SUM(bytes) free_space, \
183 | tablespace_name tablespace \
184 | from dba_free_space \
185 | group by tablespace_name \
186 | ) s, \
187 | dba_tablespaces t \
188 | where t.tablespace_name = d.tablespace(+) and \
189 | t.tablespace_name = s.tablespace(+) \
190 | order by 8) \
191 | where kperc > 93 \
192 | and tipo <>'T' \
193 | and tipo <>'U'
194 | tbl_space.NoDataFound=none
195 |
196 |
197 | userconn.Query=select count(username) from v$session where username is not null
198 | waits_controfileio.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
199 |
200 | waits_directpath_read.Query=SELECT to_char(sum(decode(event,'direct path read',total_waits,0))) DirectPathRead FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from ', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
201 |
202 | waits_file_io.Query=SELECT to_char(sum(decode(event,'file identify',total_waits, 'file open',total_waits,0))) FileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
203 |
204 | waits_latch.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, \
205 | 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO \
206 | FROM V$system_event WHERE 1=1 AND event not in ( \
207 | 'SQL*Net message from client', \
208 | 'SQL*Net more data from client', \
209 | 'pmon timer', 'rdbms ipc message', \
210 | 'rdbms ipc reply', 'smon timer')
211 |
212 | waits_logwrite.Query=SELECT to_char(sum(decode(event,'log file single write',total_waits, 'log file parallel write',total_waits,0))) LogWrite \
213 | FROM V$system_event WHERE 1=1 AND event not in ( \
214 | 'SQL*Net message from client', \
215 | 'SQL*Net more data from client', \
216 | 'pmon timer', 'rdbms ipc message', \
217 | 'rdbms ipc reply', 'smon timer')
218 |
219 | waits_multiblock_read.Query=SELECT to_char(sum(decode(event,'db file scattered read',total_waits,0))) MultiBlockRead \
220 | FROM V$system_event WHERE 1=1 AND event not in ( \
221 | 'SQL*Net message from client', \
222 | 'SQL*Net more data from client', \
223 | 'pmon timer', 'rdbms ipc message', \
224 | 'rdbms ipc reply', 'smon timer')
225 |
226 | waits_other.Query=SELECT to_char(sum(decode(event,'control file sequential read',0,'control file single write',0,'control file parallel write',0,'db file sequential read',0,'db file scattered read',0,'direct path read',0,'file identify',0,'file open',0,'SQL*Net message to client',0,'SQL*Net message to dblink',0, 'SQL*Net more data to client',0,'SQL*Net more data to dblink',0, 'SQL*Net break/reset to client',0,'SQL*Net break/reset to dblink',0, 'log file single write',0,'log file parallel write',0,total_waits))) Other FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
227 |
228 |
229 | waits_singleblock_read.Query=SELECT to_char(sum(decode(event,'db file sequential read',total_waits,0))) SingleBlockRead \
230 | FROM V$system_event WHERE 1=1 AND event not in ( \
231 | 'SQL*Net message from client', \
232 | 'SQL*Net more data from client', \
233 | 'pmon timer', 'rdbms ipc message', \
234 | 'rdbms ipc reply', 'smon timer')
235 |
236 | waits_sqlnet.Query=SELECT to_char(sum(decode(event,'SQL*Net message to client',total_waits,'SQL*Net message to dblink',total_waits,'SQL*Net more data to client',total_waits,'SQL*Net more data to dblink',total_waits,'SQL*Net break/reset to client',total_waits,'SQL*Net break/reset to dblink',total_waits,0))) SQLNET FROM V$system_event WHERE 1=1 \
237 | AND event not in ( 'SQL*Net message from client','SQL*Net more data from client','pmon timer','rdbms ipc message','rdbms ipc reply', 'smon timer')
238 |
239 |
240 | dg_error.Query=SELECT ERROR_CODE, SEVERITY, MESSAGE, TO_CHAR(TIMESTAMP, 'DD-MON-RR HH24:MI:SS') TIMESTAMP FROM V$DATAGUARD_STATUS WHERE CALLOUT='YES' AND TIMESTAMP > SYSDATE-1
241 | dg_error.NoDataFound=none
242 |
243 | dg_sequence_number.Query=SELECT MAX (sequence#) FROM v$log_history
244 |
245 | #dg_sequence_number_stby.Query=SELECT MAX (sequence#) last_log_applied FROM v$log_history
246 | dg_sequence_number_stby.Query= select max(sequence#) from v$archived_log
247 |
--------------------------------------------------------------------------------
/orabbix/conf/query_a.props:
--------------------------------------------------------------------------------
1 | DefaultQueryPeriod=2
2 |
3 | QueryList=archive,audit,dbblockgets,dbconsistentgets,dbhitratio,dbphysicalread,dbversion,hitratio_body,hitratio_sqlarea,hitratio_table_proc, \
4 | lio_current_read,locks,maxprocs,maxsession,miss_latch,pga_aggregate_target, pga,phio_datafile_reads,phio_datafile_writes,phio_redo_writes,pinhitratio_body,pinhitratio_sqlarea,pinhitratio_table-proc,pinhitratio_trigger, \
5 | pool_dict_cache,pool_free_mem,pool_lib_cache,pool_misc,pool_sql_area,procnum,session_active,session_inactive,session,session_system,sga_buffer_cache
6 |
7 | sga_fixed,sga_java_pool,sga_large_pool,sga_log_buffer,sga_shared_pool,tbl_space,userconn,waits_controfileio,waits_directpath_read, \
8 | waits_file_io,waits_latch,waits_logwrite,waits_multiblock_read,waits_singleblock_read,hitratio_trigger,lio_block_changes,lio_consistent_read,waits_other,waits_sqlnet,users_locked,uptime
9 |
10 | DataGuardPrimaryQueryList=dg_error,dg_sequence_number
11 | DataGuardStandbyQueryList=dg_sequence_number_stby
12 | RmanQueryList=rman_check_status
13 |
14 |
15 | rman_check_status.Query=select ' DB NAME->'||DB_NAME||'- ROW TYPE->'||ROW_TYPE||'- START TIME->'||to_char(start_time, 'Dy DD-Mon-YYYY HH24:MI:SS') ||'- END TIME->'||to_char(end_time, 'Dy DD-Mon-YYYY HH24:MI:SS')||'- MBYTES PROCESSED->'||MBYTES_PROCESSED||'- OBJECT TYPE->'||OBJECT_TYPE||'- STATUS->'||STATUS||'- OUTPUT DEVICE->'||OUTPUT_DEVICE_TYPE||'- INPUT MB->'||INPUT_BYTES/1048576||'- OUT MB'||OUTPUT_BYTES/1048576 \
16 | FROM rc_rman_status \
17 | WHERE start_time > SYSDATE - 1 \
18 | AND ( STATUS like '%FAILED%' \
19 | OR STATUS like '%ERROR%') \
20 | ORDER BY END_TIME
21 |
22 | rman_check_status.NoDataFound=none
23 |
24 | uptime.Query=select to_char((sysdate-startup_time)*86400, 'FM99999999999999990') retvalue from v$instance
25 |
26 | users_locked.Query=SELECT username||' '|| lock_date ||' '|| account_status FROM dba_users where ACCOUNT_STATUS like 'EXPIRED(GRACE)' or ACCOUNT_STATUS like 'LOCKED(TIMED)'
27 | users_locked.NoDataFound=none
28 |
29 |
30 | archive.Query=select round(A.LOGS*B.AVG/1024/1024/10) from ( SELECT COUNT (*) LOGS FROM V$LOG_HISTORY WHERE FIRST_TIME >= (sysdate -10/60/24)) A, ( SELECT Avg(BYTES) AVG, Count(1), Max(BYTES) Max_Bytes, Min(BYTES) Min_Bytes FROM v$log) B
31 | archive.RaceConditionQuery=select value from v$parameter where name='log_archive_start'
32 | archive.RaceConditionValue=FALSE
33 | archive.Period=40
34 |
35 |
36 |
37 | audit.Query=select username "username", \
38 | to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "time_stamp", \
39 | action_name "statement", \
40 | os_username "os_username", \
41 | userhost "userhost", \
42 | returncode||decode(returncode,'1004','-Wrong Connection','1005','-NULL Password','1017','-Wrong Password','1045','-Insufficient Priviledge','0','-Login Accepted','--') "returncode" \
43 | from sys.dba_audit_session \
44 | where (sysdate - timestamp)*24 < 1 and returncode <> 0 \
45 | order by timestamp
46 | audit.NoDataFound=none
47 |
48 | dbblockgets.Query=select to_char(sum(decode(name,'db block gets', value,0))) "block_gets" \
49 | FROM v$sysstat
50 |
51 | dbconsistentgets.Query=select to_char(sum(decode(name,'consistent gets', value,0))) "consistent_gets" \
52 | FROM v$sysstat
53 |
54 | dbhitratio.Query=select ( \
55 | sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) - sum(decode(name,'physical reads', value,0))) / (sum(decode(name,'consistent gets', value,0)) + sum(decode(name,'db block gets', value,0)) ) * 100 "hit_ratio" \
56 | FROM v$sysstat
57 | dbphysicalread.Query=select sum(decode(name,'physical reads', value,0)) "phys_reads" FROM v$sysstat
58 |
59 | dbversion.Query=select COMP_ID||' '||COMP_NAME||' '||VERSION||' '||STATUS||'
' from dba_registry union SELECT ' - SERVERNAME = '||UTL_INADDR.get_host_name ||' - SERVERADDRESS = '||UTL_INADDR.get_host_address||'
'from dual union SELECT ' - DB_NAME = '||SYS_CONTEXT ('USERENV', 'DB_NAME') ||' - INSTANCE_NAME = ' ||SYS_CONTEXT ('USERENV', 'INSTANCE_NAME')||'
' FROM dual
60 |
61 | sqlnotindexed.Query=SELECT SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))/ (SUM(DECODE(NAME, 'table scans (long tables)', VALUE, 0))+SUM(DECODE(NAME, 'table scans (short tables)', VALUE, 0)))*100 SQL_NOT_INDEXED FROM V$SYSSTAT WHERE 1=1 AND ( NAME IN ('table scans (long tables)','table scans (short tables)') )
62 |
63 | hitratio_body.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='BODY'
64 | hitratio_sqlarea.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='SQL AREA'
65 | hitratio_trigger.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace ='TRIGGER'
66 | hitratio_table_proc.Query=select gethitratio*100 "get_pct" FROM v$librarycache where namespace = 'TABLE/PROCEDURE'
67 |
68 | lio_block_changes.Query=SELECT to_char(SUM(DECODE(NAME,'db block changes',VALUE,0))) \
69 | FROM V$SYSSTAT \
70 | WHERE NAME ='db block changes'
71 |
72 | lio_consistent_read.Query=SELECT to_char(sum(decode(name,'consistent gets',value,0))) FROM V$SYSSTAT WHERE NAME ='consistent gets'
73 | lio_current_read.Query=SELECT to_char(sum(decode(name,'db block gets',value,0))) FROM V$SYSSTAT WHERE NAME ='db block gets'
74 |
75 | locks.Query=SELECT b.session_id AS sid, \
76 | NVL(b.oracle_username, '(oracle)') AS username, \
77 | a.owner AS object_owner, \
78 | a.object_name, \
79 | Decode(b.locked_mode, 0, 'None', \
80 | 1, 'Null (NULL)', \
81 | 2, 'Row-S (SS)', \
82 | 3, 'Row-X (SX)', \
83 | 4, 'Share (S)', \
84 | 5, 'S/Row-X (SSX)', \
85 | 6, 'Exclusive (X)', \
86 | b.locked_mode) locked_mode, \
87 | b.os_user_name \
88 | FROM dba_objects a, \
89 | v$locked_object b \
90 | WHERE a.object_id = b.object_id \
91 | ORDER BY 1, 2, 3, 4
92 |
93 | #locks.Query=select sn.USERNAME ||'@'||sn.machine, \
94 | '|SID->' || m.SID, \
95 | '|Serial->'|| sn.SERIAL#, \
96 | '|Lock Type->'||m.TYPE, \
97 | decode(LMODE, \
98 | 1, 'Null', \
99 | 2, 'Row-S (SS)', \
100 | 3, 'Row-X (SX)', \
101 | 4, 'Share', \
102 | 5, 'S/Row-X (SSX)', \
103 | 6, 'Exclusive') lock_type, \
104 | decode(REQUEST, \
105 | 0, 'None', \
106 | 1, 'Null', \
107 | 2, 'Row-S (SS)', \
108 | 3, 'Row-X (SX)', \
109 | 4, 'Share', \
110 | 5, 'S/Row-X (SSX)', \
111 | 6, 'Exclusive') lock_requested, \
112 | '|Time (Sec)->'||m.CTIME "Time(sec)", \
113 | '|ID1->'||m.ID1, \
114 | '|ID2->'||m.ID2, \
115 | '|SQL Text->'||t.SQL_TEXT \
116 | from v$session sn, \
117 | v$lock m , \
118 | v$sqltext t \
119 | where t.ADDRESS =sn.SQL_ADDRESS \
120 | and t.HASH_VALUE =sn.SQL_HASH_VALUE \
121 | and ((sn.SID =m.SID and m.REQUEST !=0) \
122 | or (sn.SID =m.SID and m.REQUEST =0 and LMODE !=4 and (ID1, ID2) in \
123 | (select s.ID1, s.ID2 \
124 | from v$lock S \
125 | where REQUEST !=0 \
126 | and s.ctime > 5 \
127 | and s.ID1 =m.ID1 \
128 | and s.ID2 =m.ID2))) \
129 | order by sn.USERNAME, sn.SID, t.PIECE
130 | locks.NoDataFound=none
131 |
132 |
133 | maxprocs.Query=select value "maxprocs" from v$parameter where name ='processes'
134 | maxsession.Query=select value "maxsess" from v$parameter where name ='sessions'
135 | miss_latch.Query=SELECT SUM(misses) FROM V$LATCH
136 | pga_aggregate_target.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'aggregate PGA target parameter'
137 | pga.Query=select to_char(decode( unit,'bytes', value/1024/1024, value),'999999999.9') value from V$PGASTAT where name in 'total PGA inuse'
138 | phio_datafile_reads.Query=select to_char(sum(decode(name,'physical reads direct',value,0))) FROM V$SYSSTAT where name ='physical reads direct'
139 | phio_datafile_writes.Query=select to_char(sum(decode(name,'physical writes direct',value,0))) FROM V$SYSSTAT where name ='physical writes direct'
140 | phio_redo_writes.Query=select to_char(sum(decode(name,'redo writes',value,0))) FROM V$SYSSTAT where name ='redo writes'
141 | pinhitratio_body.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='BODY'
142 | pinhitratio_sqlarea.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='SQL AREA'
143 | pinhitratio_table-proc.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TABLE/PROCEDURE'
144 | pinhitratio_trigger.Query=select pins/(pins+reloads)*100 "pin_hit ratio" FROM v$librarycache where namespace ='TRIGGER'
145 | pool_dict_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'dictionary cache',(bytes)/(1024*1024),0),0)),2)) pool_dict_cache FROM V$SGASTAT
146 | pool_free_mem.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'free memory',(bytes)/(1024*1024),0),0)),2)) pool_free_mem FROM V$SGASTAT
147 | pool_lib_cache.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',(bytes)/(1024*1024),0),0)),2)) pool_lib_cache FROM V$SGASTAT
148 | pool_misc.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area', 0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
149 | pool_sql_area.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'sql area',(bytes)/(1024*1024),0),0)),2)) pool_sql_area FROM V$SGASTAT
150 | procnum.Query=select count(*) "procnum" from v$process
151 | session_active.Query=select count(*) from v$session where TYPE!='BACKGROUND' and status='ACTIVE'
152 | session_inactive.Query=select SUM(Decode(Type, 'BACKGROUND', 0, Decode(Status, 'ACTIVE', 0, 1))) FROM V$SESSION
153 | session.Query=select count(*) from v$session
154 | session_system.Query=select SUM(Decode(Type, 'BACKGROUND', 1, 0)) system_sessions FROM V$SESSION
155 | sga_buffer_cache.Query=SELECT to_char(ROUND(SUM(decode(pool,NULL,decode(name,'db_block_buffers',(bytes)/(1024*1024),'buffer_cache',(bytes)/(1024*1024),0),0)),2)) sga_bufcache FROM V$SGASTAT
156 | sga_fixed.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'fixed_sga',(bytes)/(1024*1024),0),0)),2)) sga_fixed FROM V$SGASTAT
157 | sga_java_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'java pool',(bytes)/(1024*1024),0)),2)) sga_jpool FROM V$SGASTAT
158 | sga_large_pool.Query=SELECT to_char(ROUND(SUM(decode(pool,'large pool',(bytes)/(1024*1024),0)),2)) sga_lpool FROM V$SGASTAT
159 | sga_log_buffer.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,NULL,decode(name,'log_buffer',(bytes)/(1024*1024),0),0)),2)) sga_lbuffer FROM V$SGASTAT
160 | sga_shared_pool.Query=SELECT TO_CHAR(ROUND(SUM(decode(pool,'shared pool',decode(name,'library cache',0,'dictionary cache',0,'free memory',0,'sql area',0,(bytes)/(1024*1024)),0)),2)) pool_misc FROM V$SGASTAT
161 |
162 | tbl_space.Query=SELECT * FROM ( \
163 | select '- Tablespace ->',t.tablespace_name ktablespace, \
164 | '- Type->',substr(t.contents, 1, 1) tipo, \
165 | '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
166 | '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
167 | '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
168 | '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
169 | '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
170 | '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
171 | from \
172 | ( select SUM(bytes) tbs_size, \
173 | SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
174 | from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
175 | from dba_data_files \
176 | union all \
177 | select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
178 | from dba_temp_files \
179 | ) \
180 | group by tablespace_name \
181 | ) d, \
182 | ( select SUM(bytes) free_space, \
183 | tablespace_name tablespace \
184 | from dba_free_space \
185 | group by tablespace_name \
186 | ) s, \
187 | dba_tablespaces t \
188 | where t.tablespace_name = d.tablespace(+) and \
189 | t.tablespace_name = s.tablespace(+) \
190 | order by 8) \
191 | where kperc > 93 \
192 | and tipo <>'T' \
193 | and tipo <>'U'
194 | tbl_space.NoDataFound=none
195 |
196 |
197 | userconn.Query=select count(username) from v$session where username is not null
198 | waits_controfileio.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
199 |
200 | waits_directpath_read.Query=SELECT to_char(sum(decode(event,'direct path read',total_waits,0))) DirectPathRead FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from ', 'SQL*Net more data from client','pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
201 |
202 | waits_file_io.Query=SELECT to_char(sum(decode(event,'file identify',total_waits, 'file open',total_waits,0))) FileIO FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
203 |
204 | waits_latch.Query=SELECT to_char(sum(decode(event,'control file sequential read', total_waits, \
205 | 'control file single write', total_waits, 'control file parallel write',total_waits,0))) ControlFileIO \
206 | FROM V$system_event WHERE 1=1 AND event not in ( \
207 | 'SQL*Net message from client', \
208 | 'SQL*Net more data from client', \
209 | 'pmon timer', 'rdbms ipc message', \
210 | 'rdbms ipc reply', 'smon timer')
211 |
212 | waits_logwrite.Query=SELECT to_char(sum(decode(event,'log file single write',total_waits, 'log file parallel write',total_waits,0))) LogWrite \
213 | FROM V$system_event WHERE 1=1 AND event not in ( \
214 | 'SQL*Net message from client', \
215 | 'SQL*Net more data from client', \
216 | 'pmon timer', 'rdbms ipc message', \
217 | 'rdbms ipc reply', 'smon timer')
218 |
219 | waits_multiblock_read.Query=SELECT to_char(sum(decode(event,'db file scattered read',total_waits,0))) MultiBlockRead \
220 | FROM V$system_event WHERE 1=1 AND event not in ( \
221 | 'SQL*Net message from client', \
222 | 'SQL*Net more data from client', \
223 | 'pmon timer', 'rdbms ipc message', \
224 | 'rdbms ipc reply', 'smon timer')
225 |
226 | waits_other.Query=SELECT to_char(sum(decode(event,'control file sequential read',0,'control file single write',0,'control file parallel write',0,'db file sequential read',0,'db file scattered read',0,'direct path read',0,'file identify',0,'file open',0,'SQL*Net message to client',0,'SQL*Net message to dblink',0, 'SQL*Net more data to client',0,'SQL*Net more data to dblink',0, 'SQL*Net break/reset to client',0,'SQL*Net break/reset to dblink',0, 'log file single write',0,'log file parallel write',0,total_waits))) Other FROM V$system_event WHERE 1=1 AND event not in ( 'SQL*Net message from client', 'SQL*Net more data from client', 'pmon timer', 'rdbms ipc message', 'rdbms ipc reply', 'smon timer')
227 |
228 |
229 | waits_singleblock_read.Query=SELECT to_char(sum(decode(event,'db file sequential read',total_waits,0))) SingleBlockRead \
230 | FROM V$system_event WHERE 1=1 AND event not in ( \
231 | 'SQL*Net message from client', \
232 | 'SQL*Net more data from client', \
233 | 'pmon timer', 'rdbms ipc message', \
234 | 'rdbms ipc reply', 'smon timer')
235 |
236 | waits_sqlnet.Query=SELECT to_char(sum(decode(event,'SQL*Net message to client',total_waits,'SQL*Net message to dblink',total_waits,'SQL*Net more data to client',total_waits,'SQL*Net more data to dblink',total_waits,'SQL*Net break/reset to client',total_waits,'SQL*Net break/reset to dblink',total_waits,0))) SQLNET FROM V$system_event WHERE 1=1 \
237 | AND event not in ( 'SQL*Net message from client','SQL*Net more data from client','pmon timer','rdbms ipc message','rdbms ipc reply', 'smon timer')
238 |
239 |
240 | dg_error.Query=SELECT ERROR_CODE, SEVERITY, MESSAGE, TO_CHAR(TIMESTAMP, 'DD-MON-RR HH24:MI:SS') TIMESTAMP FROM V$DATAGUARD_STATUS WHERE CALLOUT='YES' AND TIMESTAMP > SYSDATE-1
241 | dg_error.NoDataFound=none
242 |
243 | dg_sequence_number.Query=SELECT MAX (sequence#) FROM v$log_history
244 |
245 | #dg_sequence_number_stby.Query=SELECT MAX (sequence#) last_log_applied FROM v$log_history
246 | dg_sequence_number_stby.Query= select max(sequence#) from v$archived_log
247 |
--------------------------------------------------------------------------------
/orabbix/template/Orabbix_export_graphs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 0
6 | 0
7 |
8 | 0.0.0.0
9 | 10050
10 | 3
11 | 0
12 | 127.0.0.1
13 | 623
14 | -1
15 | 2
16 |
17 |
18 |
19 | TEMPLATES
20 |
21 |
22 |
23 |
24 |
25 |
26 | 1
27 | 0
28 |
29 |
30 | 1
31 | 0
32 | 0
33 | 0.0000
34 | 100.0000
35 | 0
36 | 0
37 | 0.0000
38 | 0.0000
39 |
40 |
41 | 0
42 | 0
43 | 009900
44 | 0
45 | 2
46 | 0
47 | 5
48 |
49 |
50 |
51 |
52 | 1
53 | 0
54 |
55 |
56 | 0
57 | 0
58 | 0
59 | 0.0000
60 | 100.0000
61 | 0
62 | 0
63 | 0.0000
64 | 0.0000
65 |
66 |
67 | 0
68 | 0
69 | 009900
70 | 0
71 | 2
72 | 0
73 | 5
74 |
75 |
76 | 0
77 | 1
78 | 0000DD
79 | 0
80 | 2
81 | 0
82 | 5
83 |
84 |
85 |
86 |
87 | 1
88 | 1
89 |
90 |
91 | 0
92 | 0
93 | 0
94 | 0.0000
95 | 100.0000
96 | 0
97 | 0
98 | 0.0000
99 | 0.0000
100 |
101 |
102 | 0
103 | 3
104 | 0000CC
105 | 0
106 | 2
107 | 0
108 | 5
109 |
110 |
111 | 0
112 | 1
113 | FFFF33
114 | 0
115 | 2
116 | 0
117 | 5
118 |
119 |
120 | 0
121 | 2
122 | FF99FF
123 | 0
124 | 2
125 | 0
126 | 5
127 |
128 |
129 | 0
130 | 0
131 | 009900
132 | 0
133 | 2
134 | 0
135 | 5
136 |
137 |
138 |
139 |
140 | 1
141 | 0
142 |
143 |
144 | 0
145 | 0
146 | 1
147 | 0.0000
148 | 100.0000
149 | 0
150 | 0
151 | 0.0000
152 | 0.0000
153 |
154 |
155 | 1
156 | 1
157 | 00FFFF
158 | 0
159 | 2
160 | 0
161 | 5
162 |
163 |
164 | 1
165 | 0
166 | 0000FF
167 | 0
168 | 2
169 | 0
170 | 5
171 |
172 |
173 | 1
174 | 2
175 | FF6666
176 | 0
177 | 2
178 | 0
179 | 5
180 |
181 |
182 |
183 |
184 | 1
185 | 0
186 |
187 |
188 | 0
189 | 0
190 | 0
191 | 0.0000
192 | 100.0000
193 | 0
194 | 0
195 | 0.0000
196 | 0.0000
197 |
198 |
199 | 0
200 | 0
201 | 009900
202 | 0
203 | 2
204 | 0
205 | 5
206 |
207 |
208 |
209 |
210 | 1
211 | 0
212 |
213 |
214 | 0
215 | 0
216 | 0
217 | 0.0000
218 | 100.0000
219 | 0
220 | 0
221 | 0.0000
222 | 0.0000
223 |
224 |
225 | 0
226 | 2
227 | FF6666
228 | 0
229 | 7
230 | 0
231 | 5
232 |
233 |
234 | 0
235 | 0
236 | 0000CC
237 | 0
238 | 7
239 | 0
240 | 5
241 |
242 |
243 | 0
244 | 1
245 | 00FFFF
246 | 0
247 | 7
248 | 0
249 | 5
250 |
251 |
252 |
253 |
254 | 1
255 | 1
256 |
257 |
258 | 0
259 | 0
260 | 0
261 | 0.0000
262 | 100.0000
263 | 0
264 | 0
265 | 0.0000
266 | 0.0000
267 |
268 |
269 | 0
270 | 3
271 | 00CC00
272 | 0
273 | 2
274 | 0
275 | 5
276 |
277 |
278 | 0
279 | 1
280 | 999900
281 | 0
282 | 2
283 | 0
284 | 5
285 |
286 |
287 | 0
288 | 0
289 | 000099
290 | 0
291 | 2
292 | 0
293 | 5
294 |
295 |
296 | 0
297 | 2
298 | 990099
299 | 0
300 | 2
301 | 0
302 | 5
303 |
304 |
305 |
306 |
307 | 1
308 | 0
309 |
310 |
311 | 0
312 | 0
313 | 1
314 | 0.0000
315 | 100.0000
316 | 0
317 | 0
318 | 0.0000
319 | 0.0000
320 |
321 |
322 | 1
323 | 0
324 | 009900
325 | 0
326 | 2
327 | 0
328 | 5
329 |
330 |
331 | 1
332 | 1
333 | 990000
334 | 0
335 | 2
336 | 0
337 | 5
338 |
339 |
340 | 1
341 | 2
342 | 009999
343 | 0
344 | 2
345 | 0
346 | 5
347 |
348 |
349 | 1
350 | 3
351 | 990099
352 | 0
353 | 2
354 | 0
355 | 5
356 |
357 |
358 | 1
359 | 4
360 | CCCC00
361 | 0
362 | 2
363 | 0
364 | 5
365 |
366 |
367 |
368 |
369 | 1
370 | 0
371 |
372 |
373 | 0
374 | 0
375 | 0
376 | 0.0000
377 | 100.0000
378 | 0
379 | 0
380 | 0.0000
381 | 0.0000
382 |
383 |
384 | 0
385 | 0
386 | 0000FF
387 | 0
388 | 2
389 | 0
390 | 5
391 |
392 |
393 | 0
394 | 1
395 | 009900
396 | 0
397 | 2
398 | 0
399 | 5
400 |
401 |
402 |
403 |
404 | 1
405 | 0
406 |
407 |
408 | 1
409 | 1
410 | 1
411 | 0.0000
412 | 100.0000
413 | 0
414 | 0
415 | 0.0000
416 | 0.0000
417 |
418 |
419 | 1
420 | 2
421 | 009900
422 | 0
423 | 2
424 | 0
425 | 5
426 |
427 |
428 | 1
429 | 1
430 | FF00FF
431 | 0
432 | 2
433 | 0
434 | 5
435 |
436 |
437 | 1
438 | 0
439 | 0000FF
440 | 0
441 | 2
442 | 0
443 | 5
444 |
445 |
446 |
447 |
448 | 1
449 | 0
450 |
451 |
452 | 0
453 | 0
454 | 1
455 | 0.0000
456 | 100.0000
457 | 0
458 | 0
459 | 0.0000
460 | 0.0000
461 |
462 |
463 | 1
464 | 0
465 | 009900
466 | 0
467 | 2
468 | 0
469 | 5
470 |
471 |
472 | 1
473 | 1
474 | CC0000
475 | 0
476 | 2
477 | 0
478 | 5
479 |
480 |
481 | 1
482 | 2
483 | 00CCCC
484 | 0
485 | 2
486 | 0
487 | 5
488 |
489 |
490 | 1
491 | 3
492 | CC00CC
493 | 0
494 | 2
495 | 0
496 | 5
497 |
498 |
499 | 1
500 | 5
501 | 0000CC
502 | 0
503 | 2
504 | 0
505 | 5
506 |
507 |
508 | 1
509 | 4
510 | CCCC00
511 | 0
512 | 2
513 | 0
514 | 5
515 |
516 |
517 |
518 |
519 | 1
520 | 0
521 |
522 |
523 | 1
524 | 1
525 | 0
526 | 0.0000
527 | 100.0000
528 | 0
529 | 0
530 | 0.0000
531 | 0.0000
532 |
533 |
534 | 0
535 | 1
536 | 0000CC
537 | 0
538 | 2
539 | 0
540 | 5
541 |
542 |
543 | 1
544 | 0
545 | 00CC00
546 | 0
547 | 2
548 | 0
549 | 5
550 |
551 |
552 |
553 |
554 | 1
555 | 0
556 |
557 |
558 | 0
559 | 0
560 | 1
561 | 0.0000
562 | 100.0000
563 | 0
564 | 0
565 | 0.0000
566 | 0.0000
567 |
568 |
569 | 1
570 | 6
571 | 00CCCC
572 | 0
573 | 2
574 | 0
575 | 5
576 |
577 |
578 | 1
579 | 5
580 | 888888
581 | 0
582 | 2
583 | 0
584 | 5
585 |
586 |
587 | 1
588 | 4
589 | 009900
590 | 0
591 | 2
592 | 0
593 | 5
594 |
595 |
596 | 1
597 | 3
598 | FFFF00
599 | 0
600 | 2
601 | 0
602 | 5
603 |
604 |
605 | 1
606 | 2
607 | FF00FF
608 | 0
609 | 2
610 | 0
611 | 5
612 |
613 |
614 | 1
615 | 1
616 | FF3333
617 | 0
618 | 2
619 | 0
620 | 5
621 |
622 |
623 | 1
624 | 0
625 | CCFFCC
626 | 0
627 | 2
628 | 0
629 | 5
630 |
631 |
632 | 1
633 | 0
634 | 9999FF
635 | 0
636 | 2
637 | 0
638 | 5
639 |
640 |
641 | 1
642 | 7
643 | FF9999
644 | 0
645 | 2
646 | 0
647 | 5
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
--------------------------------------------------------------------------------
/src/com/smartmarmot/orabbix/Configurator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Andrea Dalle Vacche.
3 | *
4 | * This file is part of orabbix.
5 | *
6 | * orabbix is free software: you can redistribute it and/or modify it under the
7 | * terms of the GNU General Public License as published by the Free Software
8 | * Foundation, either version 3 of the License, or (at your option) any later
9 | * version.
10 | *
11 | * orabbix is distributed in the hope that it will be useful, but WITHOUT ANY
12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 | * details.
15 | *
16 | * You should have received a copy of the GNU General Public License along with
17 | * orabbix. If not, see .
18 | */
19 |
20 |
21 | package com.smartmarmot.orabbix;
22 |
23 |
24 | import java.io.File;
25 | import java.io.FileInputStream;
26 | import java.io.IOException;
27 | import java.sql.Connection;
28 | import java.sql.PreparedStatement;
29 | import java.sql.ResultSet;
30 | import java.sql.ResultSetMetaData;
31 | import java.util.ArrayList;
32 | import java.util.Collection;
33 | import java.util.Hashtable;
34 | import java.util.List;
35 | import java.util.Properties;
36 | import java.util.StringTokenizer;
37 |
38 | import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
39 | import org.apache.commons.dbcp.datasources.SharedPoolDataSource;
40 | import org.apache.commons.lang.ArrayUtils;
41 | import org.apache.log4j.Level;
42 |
43 |
44 | import com.smartmarmot.common.SmartLogger;
45 | import com.smartmarmot.common.db.DBConn;
46 |
47 | public class Configurator {
48 | private static Properties _props;
49 |
50 | protected static Properties getPropsFromFile(String _filename) {
51 | try {
52 | verifyConfig();
53 | Properties propsq = new Properties();
54 | FileInputStream fisq;
55 | if (_filename != "" && _filename != null) {
56 | File queryFile = new File(_filename);
57 | fisq = new FileInputStream(new java.io.File(queryFile
58 | .getAbsoluteFile().getCanonicalPath()));
59 | queryFile = null;
60 | SmartLogger.logThis(Level.DEBUG, "Loaded the properties from " + _filename);
61 | propsq.load(fisq);
62 | fisq.close();
63 | return propsq;
64 | }
65 | } catch (Exception e) {
66 | // TODO Auto-generated catch block
67 | SmartLogger.logThis(Level.ERROR, "Error on Configurator reading properties file getPropsFromFile("
68 | + _filename + ") " + e.getMessage());
69 | return null;
70 | }
71 | return null;
72 | }
73 |
74 | protected static Query[] getQueries(Properties _propsq) throws Exception {
75 | return getQueries(Constants.QUERY_LIST, _propsq);
76 | }
77 |
78 |
79 | private static Query[] getQueries(String parameter, Properties _propsq)
80 | throws Exception {
81 | try {
82 | StringTokenizer stq = new StringTokenizer(_propsq
83 | .getProperty(parameter), Constants.DELIMITER);
84 | String[] QueryLists = new String[stq.countTokens()];
85 | int count = 0;
86 | while (stq.hasMoreTokens()) {
87 | String token = stq.nextToken().toString().trim();
88 | QueryLists[count] = token;
89 | count++;
90 | }
91 |
92 | Collection Queries = new ArrayList();
93 | for (int i = 0; i < QueryLists.length; i++) {
94 | try {
95 | Query q = getQueryProperties(_propsq, QueryLists[i]);
96 | Queries.add(q);
97 | }catch (Exception e1){
98 | SmartLogger.logThis(Level.ERROR, "Error on Configurator on reading query "+QueryLists[i] +e1);
99 | SmartLogger.logThis(Level.INFO, "Query "+QueryLists[i] +" skipped due to error " +e1);
100 |
101 | }
102 | }
103 | Query[] queries = (Query[]) Queries.toArray(new Query[0]);
104 | return queries;
105 | } catch (Exception ex) {
106 |
107 | SmartLogger.logThis(Level.ERROR, "Error on Configurator on reading properties file "+ _propsq.toString() +" getQueries("
108 | + parameter + "," + _propsq.toString() + ") "
109 | + ex.getMessage());
110 | return null;
111 | }
112 |
113 | }
114 |
115 | private static Query getQueryProperties(Properties _propsq,
116 | String _queryName) throws Exception {
117 | try {
118 |
119 | String query = "";
120 | try {
121 | query = new String(_propsq.getProperty(_queryName + "."
122 | + Constants.QUERY_POSTFIX));
123 | } catch (Exception ex) {
124 | SmartLogger.logThis(Level.ERROR, "Error while getting " + _queryName + "."
125 | + Constants.QUERY_POSTFIX + " " + ex.getMessage());
126 | }
127 |
128 | String noDataFound = "";
129 | try {
130 | noDataFound = new String(_propsq.getProperty(_queryName + "."
131 | + Constants.QUERY_NO_DATA_FOUND));
132 | } catch (Exception ex) {
133 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName
134 | + "." + Constants.QUERY_NO_DATA_FOUND
135 | + " null or not present " + ex.getMessage());
136 | }
137 | String raceCondQuery = "";
138 | try {
139 | raceCondQuery = new String(_propsq.getProperty(_queryName + "."
140 | + Constants.RACE_CONDITION_QUERY));
141 | } catch (Exception ex) {
142 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName
143 | + "." + Constants.RACE_CONDITION_QUERY
144 | + " null or not present " + ex.getMessage());
145 | }
146 | String raceCondValue = "";
147 | try {
148 | raceCondValue = new String(_propsq.getProperty(_queryName + "."
149 | + Constants.RACE_CONDITION_VALUE));
150 | } catch (Exception ex) {
151 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName
152 | + "." + Constants.RACE_CONDITION_VALUE
153 | + " null or not present " + ex.getMessage());
154 | }
155 | /**
156 | * set Period if not defined period =2 min.
157 | */
158 | int period = -1;
159 | try {
160 | period = new Integer(_propsq.getProperty(_queryName + "."
161 | + Constants.QUERY_PERIOD));
162 | } catch (Exception ex) {
163 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName
164 | + "." + Constants.QUERY_PERIOD
165 | + " null or not present " + ex.getMessage());
166 | try {
167 | period = new Integer(_propsq.getProperty(Constants.QUERY_DEFAULT_PERIOD));
168 | }catch (Exception ex1) {
169 | SmartLogger.logThis(Level.DEBUG, "Note: " + Constants.QUERY_DEFAULT_PERIOD
170 | + " null or not present using default values 2 min.");
171 | period = 2;
172 | }
173 | }
174 |
175 | Boolean active = true;
176 | try {
177 | String active_str = _propsq.getProperty(_queryName + "."
178 | + Constants.QUERY_ACTIVE);
179 | if (active_str != null) {
180 | if (active_str.equalsIgnoreCase("false")) {
181 | active = false;
182 | }
183 | }
184 | } catch (Exception ex) {
185 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName
186 | + "." + Constants.QUERY_ACTIVE
187 | + " null or not present " + ex.getMessage());
188 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
189 | + Constants.QUERY_ACTIVE
190 | + " null or not present using default values TRUE");
191 | }
192 |
193 | Boolean trim = true;
194 | try {
195 | String trim_str = _propsq.getProperty(_queryName + "."
196 | + Constants.QUERY_TRIM);
197 | if (trim_str != null) {
198 | if (trim_str.equalsIgnoreCase("false")) {
199 | trim = false;
200 | }
201 | }
202 | } catch (Exception ex) {
203 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
204 | + Constants.QUERY_TRIM + " null or not present "
205 | + ex.getMessage());
206 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
207 | + Constants.QUERY_TRIM
208 | + " null or not present using default values TRUE");
209 | }
210 |
211 | Boolean space = false;
212 | try {
213 | String space_str = _propsq.getProperty(_queryName + "."
214 | + Constants.QUERY_SPACE);
215 | if (space_str != null) {
216 | if (space_str.equalsIgnoreCase("false")) {
217 | space = false;
218 | }
219 | }
220 | } catch (Exception ex) {
221 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
222 | + Constants.QUERY_SPACE + " null or not present "
223 | + ex.getMessage());
224 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
225 | + Constants.QUERY_SPACE
226 | + " null or not present using default values TRUE");
227 | }
228 |
229 | List excludeColumns = new ArrayList();
230 | try {
231 | String excludeColumnsList = new String(_propsq
232 | .getProperty(_queryName + "."
233 | + Constants.QUERY_EXCLUDE_COLUMNS));
234 |
235 | StringTokenizer st = new StringTokenizer(excludeColumnsList,
236 | Constants.DELIMITER);
237 | while (st.hasMoreTokens()) {
238 | String token = st.nextToken().toString();
239 | Integer tmpInteger = new Integer(token);
240 | excludeColumns.add(tmpInteger);
241 | }
242 | } catch (Exception ex) {
243 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
244 | + Constants.QUERY_EXCLUDE_COLUMNS + " error "
245 | + ex.getMessage());
246 | }
247 |
248 | List raceExcludeColumns = new ArrayList();
249 | try {
250 | String excludeColumnsList = new String(_propsq
251 | .getProperty(_queryName + "."
252 | + Constants.RACE_CONDITION_EXCLUDE_COLUMNS));
253 |
254 | StringTokenizer st = new StringTokenizer(excludeColumnsList,
255 | Constants.DELIMITER);
256 | while (st.hasMoreTokens()) {
257 | String token = st.nextToken().toString();
258 | Integer tmpInteger = new Integer(token);
259 | excludeColumns.add(tmpInteger);
260 | }
261 | } catch (Exception ex) {
262 | SmartLogger.logThis(Level.DEBUG, "Note: " + _queryName + "."
263 | + Constants.RACE_CONDITION_EXCLUDE_COLUMNS + " error "
264 | + ex.getMessage());
265 | }
266 |
267 |
268 |
269 | Query q = new Query(query, _queryName, noDataFound, raceCondQuery,
270 | raceCondValue, period, active, trim, space, excludeColumns,
271 | raceExcludeColumns);
272 |
273 | return q;
274 | } catch (Exception ex) {
275 |
276 | SmartLogger.logThis(Level.ERROR, "Error on Configurator on getQueryProperties("
277 | + _propsq.toString() + ") " + ex.getMessage());
278 | return null;
279 | }
280 | }
281 |
282 |
283 | /*protected Query[] refresh(Query[] _myquery, String _prpFile,String _extraPrpFile) {
284 | if (_prpFile!=null){
285 | Properties _prp = getPropsFromFile(_prpFile);
286 | Query[] q = Configurator.getQueries(_prp);
287 |
288 |
289 |
290 | _prp = getPropsFromFile(_extraPrpFile);
291 | Query[] q = Configurator.getQueries(_prp);
292 |
293 |
294 | Configurator.getQueryProperties(_prpFile, q);
295 | }
296 |
297 |
298 | /*Properties _prp = getPropsFromFile(_prpFile);
299 | for (int i = 0; i < _myquery.length; i++) {
300 | try {
301 | Query qnew = Configurator.getQueryProperties(_prp, _myquery[i]
302 | .getName());
303 | if (!_myquery[i].getSQL().equalsIgnoreCase(qnew.getSQL())) {
304 | _myquery[i].setSql(qnew.getSQL());
305 | SmartLogger.logThis(Level.INFO, "Statement changed on query "
306 | + _myquery[i].getName() + " new statement ->"
307 | + qnew.getSQL());
308 | }
309 | if ((_myquery[i].getActive().equals(true) && qnew.getActive()
310 | .equals(false))
311 | || (_myquery[i].getActive().equals(false) && qnew
312 | .getActive().equals(true))) {
313 |
314 | _myquery[i].setActive(qnew.getActive());
315 | SmartLogger.logThis(Level.INFO, "Status of query "
316 | + _myquery[i].getName() + " has changed ->"
317 | + qnew.getActive());
318 | }
319 | if (_myquery[i].getPeriod() != qnew.getPeriod()) {
320 | _myquery[i].setPeriod(qnew.getPeriod());
321 | if (qnew.getPeriod() > 0) {
322 | Date now = new Date(System.currentTimeMillis());
323 | Date newNextRun = new Date(now.getTime()
324 | + (qnew.getPeriod() * 1000 * 60));
325 | _myquery[i].setNextrun(newNextRun);
326 | }
327 | SmartLogger.logThis(Level.INFO, "Period of query "
328 | + _myquery[i].getName() + " has changed ->"
329 | + qnew.getPeriod());
330 | }
331 | if (!_myquery[i].getRaceQuery().equalsIgnoreCase(
332 | qnew.getRaceQuery())) {
333 | _myquery[i].setRaceQuery(qnew.getRaceQuery());
334 | SmartLogger.logThis(Level.INFO, "RaceQuery for query "
335 | + _myquery[i].getName() + " has changed ->"
336 | + qnew.getRaceQuery());
337 | }
338 | if (!_myquery[i].getRaceValue().equalsIgnoreCase(
339 | qnew.getRaceValue())) {
340 | _myquery[i].setRaceQuery(qnew.getRaceQuery());
341 | SmartLogger.logThis(Level.INFO, "RaceValue of query "
342 | + _myquery[i].getName() + " has changed ->"
343 | + qnew.getRaceValue());
344 | }
345 | } catch (Exception e) {
346 | // TODO Auto-generated catch block
347 | SmartLogger.logThis(Level.ERROR,
348 | "Error on Configurator while getting getQueryProperties( "
349 | + _prp + " , " + _myquery[i].getName()
350 | + ") Error " + e.getMessage());
351 | }
352 | }
353 | return _myquery;
354 | }*/
355 |
356 | private static void verifyConfig() {
357 | if (_props == null ) {
358 | throw new IllegalArgumentException("empty properties");
359 | }
360 |
361 | }
362 |
363 | public Configurator(String _url) throws IOException {
364 | Properties props = new Properties();
365 |
366 | FileInputStream fis;
367 | try {
368 | try {
369 | File configFile = new File(_url);
370 | fis = new FileInputStream(new java.io.File(configFile
371 | .getAbsoluteFile().getCanonicalPath()));
372 | props.load(fis);
373 | fis.close();
374 | } catch (Exception e) {
375 | SmartLogger.logThis(Level.ERROR,
376 | "Error on Configurator while retriving configuration file "
377 | + _url + " " + e.getMessage());
378 | }
379 | _props = props;
380 | } catch (Exception e) {
381 | // TODO Auto-generated catch block
382 | SmartLogger.logThis(Level.ERROR, "Error on Configurator " + e.getMessage());
383 | }
384 | }
385 |
386 | private DBConn getConnection(String dbName) throws Exception {
387 | try {
388 | verifyConfig();
389 |
390 | SmartLogger.logThis(Level.DEBUG, "getConnection for database " + dbName);
391 | String url = "";
392 | try {
393 | url = new String(_props.getProperty(dbName + "."
394 | + Constants.CONN_URL));
395 | } catch (Exception ex) {
396 | SmartLogger.logThis(Level.ERROR,
397 | "Error on Configurator getConnection while getting "
398 | + dbName + "." + Constants.CONN_URL + " "
399 | + ex.getMessage());
400 | }
401 |
402 | String uname = "";
403 | try {
404 | uname = new String(_props.getProperty(dbName + "."
405 | + Constants.CONN_USERNAME));
406 | } catch (Exception ex) {
407 | try {
408 | SmartLogger.logThis(Level.DEBUG,
409 | "Error on Configurator getConnection while getting "
410 | + dbName + "."
411 | + Constants.CONN_USERNAME + " "
412 | + ex.getMessage());
413 |
414 | uname = new String(_props.getProperty(
415 | Constants.CONN_DEFAULT_USERNAME));
416 | } catch (Exception ex1){
417 | SmartLogger.logThis(Level.ERROR,
418 | "Error on Configurator getConnection while getting "
419 | + Constants.CONN_DEFAULT_USERNAME + " "
420 | + ex1.getMessage());
421 | }
422 | }
423 | String password = "";
424 | try {
425 | password = new String(_props.getProperty(dbName + "."
426 | + Constants.CONN_PASSWORD));
427 | } catch (Exception ex) {
428 | try{
429 | SmartLogger.logThis(Level.DEBUG,
430 | "Error on Configurator getConnection while getting "
431 | + dbName + "."
432 | + Constants.CONN_PASSWORD + " "
433 | + ex.getMessage());
434 | password = new String(_props.getProperty(
435 | Constants.CONN_DEFAULT_PASSWORD));
436 | } catch (Exception ex1){
437 | SmartLogger.logThis(Level.ERROR,
438 | "Error on Configurator getConnection while getting "
439 | + dbName + "." + Constants.CONN_PASSWORD + " "
440 | + ex.getMessage());
441 | }
442 | }
443 | DriverAdapterCPDS cpds = new DriverAdapterCPDS();
444 | cpds.setDriver(Constants.ORACLE_DRIVER);
445 | cpds.setUrl(url.toString());
446 | cpds.setUser(uname.toString());
447 | cpds.setPassword(password.toString());
448 | SharedPoolDataSource tds = new SharedPoolDataSource();
449 | tds.setConnectionPoolDataSource(cpds);
450 | // tds.setMaxActive(5);
451 | Integer maxActive = new Integer(5);
452 | try {
453 | maxActive = new Integer(_props.getProperty(dbName + "."
454 | + Constants.CONN_MAX_ACTIVE));
455 | } catch (Exception ex) {
456 | SmartLogger.logThis(Level.DEBUG, "Note: " + dbName + "."
457 | + Constants.CONN_MAX_ACTIVE + " " + ex.getMessage());
458 | try {
459 | maxActive = new Integer(_props
460 | .getProperty(Constants.DATABASES_LIST + "."
461 | + Constants.CONN_MAX_ACTIVE));
462 | } catch (Exception e) {
463 | SmartLogger.logThis(Level.WARN, "Note: "
464 | + Constants.DATABASES_LIST + "."
465 | + Constants.CONN_MAX_ACTIVE + " " + e.getMessage());
466 | SmartLogger.logThis(Level.WARN, "Warning I will use default value "
467 | + maxActive);
468 | }
469 | }
470 | tds.setMaxActive(maxActive.intValue());
471 | Integer maxWait = new Integer(100);
472 | try {
473 | maxWait = new Integer(_props.getProperty(dbName + "."
474 | + Constants.CONN_MAX_WAIT));
475 | } catch (Exception ex) {
476 | SmartLogger.logThis(Level.DEBUG, "Note: " + dbName + "."
477 | + Constants.CONN_MAX_WAIT + " " + ex.getMessage());
478 | try {
479 | maxWait = new Integer(_props
480 | .getProperty(Constants.DATABASES_LIST + "."
481 | + Constants.CONN_MAX_WAIT));
482 | } catch (Exception e) {
483 | SmartLogger.logThis(Level.WARN, "Note: "
484 | + Constants.DATABASES_LIST + "."
485 | + Constants.CONN_MAX_WAIT + " " + e.getMessage());
486 | SmartLogger.logThis(Level.WARN, "Warning I will use default value "
487 | + maxWait);
488 | }
489 | }
490 | tds.setMaxWait(maxWait.intValue());
491 | Integer maxIdle = new Integer(1);
492 | try {
493 | maxIdle = new Integer(_props.getProperty(dbName + "."
494 | + Constants.CONN_MAX_IDLE));
495 | } catch (Exception ex) {
496 | SmartLogger.logThis(Level.DEBUG, "Note: " + dbName + "."
497 | + Constants.CONN_MAX_IDLE + " " + ex.getMessage());
498 | try {
499 | maxIdle = new Integer(_props
500 | .getProperty(Constants.DATABASES_LIST + "."
501 | + Constants.CONN_MAX_IDLE));
502 | } catch (Exception e) {
503 | SmartLogger.logThis(Level.WARN, "Note: "
504 | + Constants.DATABASES_LIST + "."
505 | + Constants.CONN_MAX_IDLE + " " + e.getMessage());
506 | SmartLogger.logThis(Level.WARN, "Warning I will use default value "
507 | + maxIdle);
508 | }
509 | }
510 | tds.setMaxIdle(maxIdle.intValue());
511 |
512 | SmartLogger.logThis( Level.INFO,"DB Pool created: " + tds);
513 | SmartLogger.logThis( Level.INFO, "URL=" + url.toString() );
514 | SmartLogger.logThis( Level.INFO, "maxPoolSize=" + tds.getMaxActive() );
515 | SmartLogger.logThis( Level.INFO, "maxIdleSize=" + tds.getMaxIdle() );
516 | SmartLogger.logThis( Level.INFO, "maxIdleTime=" + tds.getMinEvictableIdleTimeMillis() + "ms" );
517 | SmartLogger.logThis( Level.INFO, "poolTimeout=" + tds.getMaxWait() );
518 | SmartLogger.logThis( Level.INFO, "timeBetweenEvictionRunsMillis=" + tds.getTimeBetweenEvictionRunsMillis() );
519 | SmartLogger.logThis( Level.INFO, "numTestsPerEvictionRun=" + tds.getNumTestsPerEvictionRun() );
520 |
521 |
522 | tds.setValidationQuery(Constants.ORACLE_VALIDATION_QUERY);
523 | Connection con = null;
524 | con = tds.getConnection();
525 | PreparedStatement p_stmt = null;
526 | p_stmt = con.prepareStatement(Constants.ORACLE_WHOAMI_QUERY);
527 | ResultSet rs = null;
528 | rs = p_stmt.executeQuery();
529 | String tempStr = new String("");
530 | ResultSetMetaData rsmd = rs.getMetaData();
531 | int numColumns = rsmd.getColumnCount();
532 | while (rs.next()) {
533 | for (int r = 1; r < numColumns + 1; r++) {
534 | tempStr = tempStr + rs.getObject(r).toString().trim();
535 | }
536 | }
537 | SmartLogger.logThis(Level.INFO, "Connected as " + tempStr);
538 |
539 | con.close();
540 | con = null;
541 | con = tds.getConnection();
542 | p_stmt = con.prepareStatement(Constants.ORACLE_DBNAME_QUERY);
543 | rs = p_stmt.executeQuery();
544 | rsmd = rs.getMetaData();
545 | numColumns = rsmd.getColumnCount();
546 | tempStr = "";
547 | while (rs.next()) {
548 | for (int r = 1; r < numColumns + 1; r++) {
549 | tempStr = tempStr + rs.getObject(r).toString().trim();
550 | }
551 | }
552 | SmartLogger.logThis(Level.INFO, "--------- on Database -> " + tempStr);
553 | con.close();
554 | con = null;
555 | DBConn mydbconn = new DBConn(tds, dbName.toString());
556 | return mydbconn;
557 |
558 | } catch (Exception ex) {
559 | SmartLogger.logThis(Level.ERROR, "Error on Configurator for database " + dbName
560 | + " -->" + ex.getMessage());
561 | return null;
562 | }
563 | }
564 |
565 | public DBConn[] getConnections() throws Exception {
566 | try {
567 | verifyConfig();
568 | String[] DatabaseList = getDBList();
569 | Collection connections = new ArrayList();
570 | for (int i = 0; i < DatabaseList.length; i++) {
571 | DBConn dbc=this.getConnection(DatabaseList[i]);
572 | if (dbc!=null){
573 | connections.add(dbc);
574 | }else {
575 | SmartLogger.logThis(Level.INFO,"This Database "+DatabaseList[i]+" removed");
576 | }
577 | }
578 | // fis.close();
579 | DBConn[] connArray = (DBConn[]) connections.toArray(new DBConn[0]);
580 | return connArray;
581 | } catch (Exception ex) {
582 | SmartLogger.logThis(Level.ERROR, "Error on Configurator getConnections "
583 | + ex.getMessage());
584 | return null;
585 | }
586 | }
587 |
588 | public String[] getDBList() throws Exception {
589 | try {
590 | verifyConfig();
591 | String dblist = "";
592 | try {
593 | dblist = new String(_props
594 | .getProperty(Constants.DATABASES_LIST));
595 | } catch (Exception e) {
596 | SmartLogger.logThis(Level.ERROR,
597 | "Error on Configurator while retriving the databases list "
598 | + Constants.DATABASES_LIST + " " + e);
599 | }
600 |
601 | StringTokenizer st = new StringTokenizer(dblist,
602 | Constants.DELIMITER);
603 | String[] DatabaseList = new String[st.countTokens()];
604 | int count = 0;
605 | while (st.hasMoreTokens()) {
606 | String token = st.nextToken().toString();
607 | DatabaseList[count] = token;
608 | count++;
609 | }
610 | // fisdb.close();
611 | return DatabaseList;
612 | } catch (Exception ex) {
613 | SmartLogger.logThis(Level.ERROR,
614 | "Error on Configurator while retriving the databases list "
615 | + Constants.DATABASES_LIST + " " + ex);
616 | return null;
617 | }
618 | }
619 |
620 | public Integer getMaxThread() throws Exception {
621 | try {
622 | verifyConfig();
623 | return new Integer(_props
624 | .getProperty(Constants.ORABBIX_DAEMON_THREAD));
625 | } catch (Exception ex) {
626 | SmartLogger.logThis(Level.ERROR, "Error on Configurator while retriving the "
627 | + Constants.ORABBIX_DAEMON_THREAD + " " + ex);
628 | return null;
629 | }
630 | }
631 |
632 | public String getPidFile() throws Exception {
633 | try {
634 | verifyConfig();
635 | String _pidfile = new String(_props
636 | .getProperty(Constants.ORABBIX_PIDFILE));
637 | SmartLogger.logThis(Level.INFO, "PidFile -> " + _pidfile);
638 |
639 | if (_pidfile == "") {
640 | SmartLogger.logThis(Level.ERROR, "Error retrieving pidfile from " + _props);
641 | }
642 | return _pidfile;
643 |
644 | } catch (Exception ex) {
645 |
646 | SmartLogger.logThis(Level.ERROR, "Error on Configurator getPidFile " + ex);
647 | return null;
648 | }
649 | }
650 |
651 | public static String getQueryFile() {
652 | String queryFile = new String(_props
653 | .getProperty(Constants.QUERY_LIST_FILE));
654 | return queryFile;
655 | }
656 |
657 | public static String getQueryFile(String dbName) {
658 | try {
659 | verifyConfig();
660 | if (_props.getProperty(dbName + "." + Constants.QUERY_LIST_FILE) != null) {
661 | return (_props.getProperty(dbName + "."
662 | + Constants.QUERY_LIST_FILE));
663 | }
664 | } catch (Exception ex) {
665 | SmartLogger.logThis(Level.ERROR, "Error on Configurator on getQueryFile("
666 | + dbName + ") " + ex.getMessage());
667 | SmartLogger.logThis(Level.WARN, "I'm going to return getQueryFile() ");
668 | return getQueryFile();
669 | }
670 | return null;
671 | }
672 | public static String getExtraQueryFile(String dbName) {
673 | try {
674 | verifyConfig();
675 | if (_props.getProperty(dbName + "." + Constants.EXTRA_QUERY_LIST_FILE) != null) {
676 | return (_props.getProperty(dbName + "."
677 | + Constants.EXTRA_QUERY_LIST_FILE));
678 | }
679 | } catch (Exception ex) {
680 | SmartLogger.logThis(Level.ERROR, "Error on Configurator on getExtraQueryFile("
681 | + dbName + ") " + ex.getMessage());
682 | }
683 | return null;
684 | }
685 |
686 | public Properties getQueryProp() {
687 | verifyConfig();
688 | Properties propsq = new Properties();
689 | try {
690 | FileInputStream fisq;
691 | String fiqp = new String(_props
692 | .getProperty(Constants.QUERY_LIST_FILE));
693 | File queryFile = new File(fiqp);
694 | fisq = new FileInputStream(new java.io.File(queryFile
695 | .getAbsoluteFile().getCanonicalPath()));
696 | queryFile = null;
697 | propsq.load(fisq);
698 | fisq.close();
699 | } catch (Exception e) {
700 | // TODO Auto-generated catch block
701 | SmartLogger.logThis(Level.ERROR, "Error on Configurator while getting "
702 | + Constants.QUERY_LIST_FILE + " error -> " + e.getMessage());
703 | return null;
704 | }
705 | return propsq;
706 | }
707 |
708 | public Properties getQueryProp(String dbname) {
709 | try {
710 | verifyConfig();
711 | Properties propsq = new Properties();
712 | FileInputStream fisq;
713 | if (dbname != "" && dbname != null) {
714 | // logger.warn("Method called with null or empty string on Configurator "+dbname);
715 | File queryFile = new File(_props.getProperty(dbname + "."
716 | + Constants.QUERY_LIST_FILE));
717 | fisq = new FileInputStream(new java.io.File(queryFile
718 | .getAbsoluteFile().getCanonicalPath()));
719 | queryFile = null;
720 | SmartLogger.logThis(Level.DEBUG, "Debug loaded the " + dbname + "."
721 | + Constants.QUERY_LIST_FILE);
722 | // fisq = new FileInputStream (new java.io.File(
723 | // _props.getProperty(dbname+"."+Constants.QUERY_LIST_FILE)));
724 | } else {
725 | // fisq = new FileInputStream (new java.io.File(
726 | // _props.getProperty(Constants.QUERY_LIST_FILE)));
727 | SmartLogger.logThis(Level.DEBUG, "Debug I'm loading the default "
728 | + Constants.QUERY_LIST_FILE + " " + dbname
729 | + " don't have it's own");
730 | File queryFile = new File(_props
731 | .getProperty(Constants.QUERY_LIST_FILE));
732 | fisq = new FileInputStream(new java.io.File(queryFile
733 | .getAbsoluteFile().getCanonicalPath()));
734 | queryFile = null;
735 | }
736 | propsq.load(fisq);
737 | fisq.close();
738 | return propsq;
739 | } catch (Exception e) {
740 | // TODO Auto-generated catch block
741 | SmartLogger.logThis(Level.ERROR, "Error on Configurator getting "+Constants.QUERY_LIST_FILE +" " + dbname
742 | + e.getMessage());
743 | return null;
744 | }
745 | }
746 |
747 | public String getZabbixServer() throws Exception {
748 | try {
749 | verifyConfig();
750 | return _props.getProperty(Constants.ZABBIX_SERVER_HOST);
751 |
752 | } catch (Exception ex) {
753 | SmartLogger.logThis(Level.ERROR,
754 | "Error on Configurator while retriving zabbix server host "
755 | + Constants.ZABBIX_SERVER_HOST + " or port "
756 | + Constants.ZABBIX_SERVER_PORT + " " + ex);
757 | return null;
758 | }
759 | }
760 |
761 | public int getZabbixServerPort() throws Exception {
762 | try {
763 | verifyConfig();
764 | Integer port = new Integer(_props
765 | .getProperty(Constants.ZABBIX_SERVER_PORT));
766 | return port.intValue();
767 | } catch (Exception ex) {
768 | SmartLogger.logThis(Level.ERROR,
769 | "Error on Configurator while retriving zabbix server port "
770 | + Constants.ZABBIX_SERVER_PORT + " " + ex);
771 | SmartLogger.logThis(Level.WARN, "I will use the default port "
772 | + Constants.ZABBIX_SERVER_DEFAULT_PORT);
773 | return Constants.ZABBIX_SERVER_DEFAULT_PORT;
774 | }
775 | }
776 |
777 | public Hashtable getZabbixServers() throws Exception {
778 | String zxblist = new String();
779 | try {
780 | zxblist = new String(_props
781 | .getProperty(Constants.ZABBIX_SERVER_LIST));
782 | } catch (Exception e) {
783 | SmartLogger.logThis(Level.ERROR, "Error on getZabbixServers while getting "
784 | + Constants.ZABBIX_SERVER_LIST + " " + e.getMessage());
785 | }
786 | StringTokenizer st = new StringTokenizer(zxblist, Constants.DELIMITER);
787 | Hashtable ZabbixServers = new Hashtable();
788 | int count = 0;
789 | while (st.hasMoreTokens()) {
790 | String token = st.nextToken().toString();
791 | String server = new String();
792 | try {
793 | server = new String(_props.getProperty(token + "."
794 | + Constants.ZABBIX_SERVER_HOST));
795 | } catch (Exception e) {
796 | SmartLogger.logThis(Level.ERROR, "Error on getZabbixServers while getting "
797 | + token + "." + Constants.ZABBIX_SERVER_HOST + " "
798 | + e.getMessage());
799 | }
800 | Integer port = new Integer(Constants.ZABBIX_SERVER_DEFAULT_PORT);
801 | try {
802 | port = new Integer(_props.getProperty(token + "."
803 | + Constants.ZABBIX_SERVER_PORT));
804 | } catch (Exception e) {
805 | SmartLogger.logThis(Level.WARN,
806 | "Warning on getZabbixServers while getting " + token
807 | + "." + Constants.ZABBIX_SERVER_PORT + " "
808 | + e.getMessage());
809 | SmartLogger.logThis(Level.WARN, "Warning I will use the default port"
810 | + port);
811 | }
812 | ZabbixServers.put(server, port);
813 | count++;
814 | }
815 | // fisdb.close();
816 | return ZabbixServers;
817 | }
818 |
819 | public static boolean hasQueryFile(String dbName) {
820 | if (dbName == null) {
821 | return false;
822 | }
823 | try {
824 | verifyConfig();
825 | if (_props.getProperty(dbName + "." + Constants.QUERY_LIST_FILE) != null) {
826 | return true;
827 | }
828 | } catch (Exception ex) {
829 | SmartLogger.logThis(Level.ERROR, "Error on Configurator getting"+ Constants.QUERY_LIST_FILE
830 | + dbName + ex.getMessage());
831 | return false;
832 | }
833 | return false;
834 | }
835 |
836 | public static boolean hasExtraQueryFile(String dbName) {
837 | if (dbName == null) {
838 | return false;
839 | }
840 | try {
841 | verifyConfig();
842 | if (_props.getProperty(dbName + "." + Constants.EXTRA_QUERY_LIST_FILE) != null) {
843 | return true;
844 | }
845 | } catch (Exception ex) {
846 | SmartLogger.logThis(Level.ERROR, "Error on Configurator getting"+ Constants.EXTRA_QUERY_LIST_FILE
847 | + dbName + ex.getMessage());
848 | return false;
849 | }
850 | return false;
851 | }
852 |
853 | public boolean isEqualsDBList(DBConn[] _dbc) throws Exception {
854 | try {
855 | verifyConfig();
856 |
857 | String[] localdblist = this.getDBList();
858 | String[] remotedblist = new String[_dbc.length];
859 | for (int i = 0; i < _dbc.length; i++) {
860 | remotedblist[i] = _dbc[i].getName();
861 | }
862 | return ArrayUtils.isEquals(localdblist, remotedblist);
863 | } catch (Exception ex) {
864 | SmartLogger.logThis(Level.ERROR,
865 | "Error on Configurator while comparing the databases lists on isEqualsDBList "
866 | + ex);
867 | return false;
868 | }
869 | }
870 |
871 | public DBConn[] rebuildDBList(DBConn[] _dbc) {
872 | try {
873 | verifyConfig();
874 | String[] localdblist = this.getDBList();
875 | String[] remotedblist = new String[_dbc.length];
876 | for (int i = 0; i < _dbc.length; i++) {
877 | remotedblist[i] = _dbc[i].getName();
878 | }
879 |
880 | Collection connections = new ArrayList();
881 | for (int j = 0; j < localdblist.length; j++) {
882 | if (ArrayUtils.contains(remotedblist, localdblist[j])) {
883 | DBConn tmpDBConn;
884 | tmpDBConn = _dbc[ArrayUtils.indexOf(remotedblist,
885 | localdblist[j])];
886 | connections.add(tmpDBConn);
887 | }
888 | if (!ArrayUtils.contains(remotedblist, localdblist[j])) {
889 | /*
890 | * adding database
891 | */
892 | SmartLogger.logThis(Level.INFO, "New database founded! "
893 | + localdblist[j]);
894 | DBConn tmpDBConn = this.getConnection(localdblist[j]);
895 | if (tmpDBConn != null) {
896 | connections.add(tmpDBConn);
897 | }
898 | }
899 | }
900 | for (int x = 0; x < _dbc.length; x++) {
901 | if (!ArrayUtils.contains(localdblist, _dbc[x].getName())) {
902 | SmartLogger.logThis(Level.WARN, "Database " + _dbc[x].getName()
903 | + " removed from configuration file");
904 | /**
905 | * removing database
906 | */
907 | // _dbc[x].closeAll();
908 | _dbc[x].getSPDS().close();
909 | SmartLogger.logThis(Level.WARN, "Database " + _dbc[x].getName()
910 | + " conections closed");
911 | _dbc[x] = null;
912 | }
913 | }
914 | DBConn[] connArray = (DBConn[]) connections.toArray(new DBConn[0]);
915 | return connArray;
916 | } catch (Exception ex) {
917 | SmartLogger.logThis(Level.ERROR,
918 | "Error on Configurator while retriving the databases list "
919 | + Constants.DATABASES_LIST + " error:" + ex);
920 | return _dbc;
921 | }
922 |
923 | }
924 | public static Integer getSleep() throws Exception {
925 | try{
926 | verifyConfig();
927 | Integer sleep = new Integer(5);
928 | try{
929 | sleep=new Integer(_props.getProperty(Constants.ORABBIX_DAEMON_SLEEP));
930 | }catch (Exception e){
931 | SmartLogger.logThis(Level.WARN,"Warning while getting "+Constants.ORABBIX_DAEMON_SLEEP+" I will use the default "+sleep);
932 | }
933 | return sleep;
934 |
935 | } catch (Exception ex){
936 |
937 | SmartLogger.logThis(Level.ERROR,"Error on Configurator while retriving "+Constants.ORABBIX_DAEMON_SLEEP+" "+ex);
938 | return null;
939 | }
940 | }
941 |
942 | public static boolean propVerify(String _prop) {
943 | // TODO Auto-generated method stub
944 |
945 | if (_prop!= null){
946 | if (!_prop.isEmpty()&&!_prop.equals("")){
947 | Properties props = new Properties();
948 | FileInputStream fisq;
949 | File queryFile = new File(_prop);
950 | try {
951 | fisq = new FileInputStream(new java.io.File(queryFile
952 | .getAbsoluteFile().getCanonicalPath()));
953 | props.load(fisq);
954 | fisq.close();
955 | return true;
956 | }
957 | catch (Exception ex){
958 | SmartLogger.logThis(Level.DEBUG,"Error on Configurator while checking file "+_prop+" "+ex);
959 | return false;
960 | }
961 | }
962 | }
963 | return false;
964 | }
965 |
966 | public static Querybox buildQueryBoxbyDBName(String dbname){
967 | String queryFile =null;
968 | String extraQueryFile=null;
969 |
970 | if (hasQueryFile(dbname)) {
971 | queryFile = getQueryFile(dbname);
972 | } else {
973 | queryFile = getQueryFile();
974 | }
975 |
976 | if (hasExtraQueryFile(dbname)){
977 | extraQueryFile = getExtraQueryFile(dbname);
978 | }
979 |
980 | Querybox qboxtmp = new Querybox(dbname,
981 | queryFile,extraQueryFile);
982 | return qboxtmp;
983 | }
984 |
985 |
986 | }
987 |
--------------------------------------------------------------------------------