Skip to content

Commit c772958

Browse files
committed
moved commands configuration inside database config to support for multiple databases
1 parent fdd3801 commit c772958

6 files changed

Lines changed: 73 additions & 53 deletions

File tree

README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,30 @@ Please make sure to not use tab (\t) while editing yaml files. You may want to v
3636

3737
```
3838
# Configure the SQLMonitor
39+
# Provide password OR encryptedPassword,encryptionKey. See the documentation to find about password encryption.
40+
# isolationLevel:Transaction isolation level to apply on the connection
41+
#Supported values are TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ and TRANSACTION_SERIALIZABLE
42+
#Default is TRANSACTION_READ_UNCOMMITTED
3943
servers:
40-
- server: "localhost"
44+
- displayName: "Instance1"
4145
driver: "com.mysql.jdbc.Driver"
42-
connectionString: "jdbc:mysql://localhost:3388/test"
46+
connectionString: "jdbc:mysql://localhost:3388/database1"
4347
user: "root"
44-
#Provide password or encryptedPassword and encryptionKey. See the documentation to find about password encryption.
4548
password: "root"
46-
47-
encryptedPassword:
4849
encryptionKey:
49-
#Transaction isolation level to apply on the connection
50-
#Supported values are TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ and TRANSACTION_SERIALIZABLE
51-
#Default is TRANSACTION_READ_UNCOMMITTED
50+
encryptedPassword:
5251
isolationLevel: "TRANSACTION_READ_UNCOMMITTED"
53-
54-
55-
commands:
56-
- command: "select value from monitortest where id = 1"
57-
displayPrefix: "Expedia"
58-
- command: "select value from monitortest where id = 2"
59-
displayPrefix: "DerbySoft"
60-
52+
commands:
53+
- command: "select value from monitortest where id = 1"
54+
displayPrefix: "Expedia"
55+
- command: "select value from monitortest where id = 2"
56+
displayPrefix: "DerbySoft"
6157
# Make sure the metric prefix ends with a |
62-
58+
#This will create this metric in all the tiers, under this path.
6359
metricPrefix: "Custom Metrics|SQL|"
64-
```
60+
#This will create it in specific Tier. Replace <ComponentID> with TierID
61+
#metricPrefix: "Server|Component:<ComponentID>|Custom Metrics|SQL|"
62+
```
6563

6664
2. Configure the path to the config.yaml file by editing the <task-arguments> in the monitor.xml file. Below is the sample
6765

@@ -121,7 +119,7 @@ Find out more in the [AppDynamics Exchange][].
121119
122120
For any questions or feature request, please contact [AppDynamics Center of Excellence][].
123121
124-
**Version:** 1.3
122+
**Version:** 1.3.1
125123
**Controller Compatibility:** 3.7 or later
126124
**SQL Version Tested On:** MySQL, 5.5.46
127125

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.appdynamics.extensions</groupId>
88
<artifactId>sql-monitoring-extension</artifactId>
9-
<version>1.3</version>
9+
<version>1.3.1</version>
1010
<packaging>jar</packaging>
1111
<name>sql-monitoring-extension</name>
1212
<url>http://maven.apache.org</url>
@@ -151,7 +151,7 @@
151151
<fileset dir="src/main/resources/conf" includes="config.yml"/>
152152
</copy>
153153
<copy todir="${target.dir}">
154-
<fileset dir="${build.directory}"
154+
<fileset dir="${project.build.directory}"
155155
includes="${project.artifactId}.${project.packaging}"/>
156156
</copy>
157157
<zip destfile="${target.dir}-${project.version}.zip">

src/main/java/com/appdynamics/monitors/sql/SQLMonitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public TaskOutput execute(Map<String, String> taskArguments, TaskExecutionContex
6565
//read the config.
6666
Configuration config = YmlReader.readFromFile(configFilename, Configuration.class);
6767

68-
// no point continuing if we don't have this
68+
/*// no point continuing if we don't have this
6969
if (config.getCommands().isEmpty()) {
7070
return new TaskOutput("Failure");
71-
}
71+
}*/
7272
processMetricPrefix(config.getMetricPrefix());
7373

7474
status = executeCommands(config, status);
@@ -89,12 +89,12 @@ private String executeCommands(Configuration config, String status) {
8989
for (Server server : config.getServers()) {
9090
conn = connect(server);
9191

92-
for (Command command : config.getCommands()) {
92+
for (Command command : server.getCommands()) {
9393
try {
9494
int counter = 1;
9595
logger.info("sql statement: " + counter++);
9696
String statement = command.getCommand();
97-
String displayPrefix = server.getServer()+"|"+command.getDisplayPrefix();
97+
String displayPrefix = server.getDisplayName()+"|"+command.getDisplayPrefix();
9898
if (statement != null) {
9999
statement = statement.trim();
100100
// parse into statement and roll up

src/main/java/com/appdynamics/monitors/sql/config/Configuration.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class Configuration {
2525

2626
String metricPrefix;
2727
List<Server> servers;
28-
List<Command> commands;
2928

3029
public List<Server> getServers() {
3130
return servers;
@@ -43,13 +42,6 @@ public void setMetricPrefix(String metricPrefix) {
4342
this.metricPrefix = metricPrefix;
4443
}
4544

46-
public List<Command> getCommands() {
47-
return commands;
48-
}
49-
50-
public void setCommands(List<Command> commands) {
51-
this.commands = commands;
52-
}
5345
}
5446

5547

src/main/java/com/appdynamics/monitors/sql/config/Server.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717
package com.appdynamics.monitors.sql.config;
1818

1919

20+
import java.util.List;
21+
2022
public class Server {
2123

22-
private String server;
24+
private String displayName;
2325
private String driver;
2426
private String connectionString;
2527
private String user;
2628
private String password;
2729
private String encryptedPassword;
2830
private String encryptionKey;
2931
private String isolationLevel;
32+
private List<Command> commands;
3033

3134
public enum IsolationLevel {
3235
TRANSACTION_READ_UNCOMMITTED(1), TRANSACTION_READ_COMMITTED(2), TRANSACTION_REPEATABLE_READ(4), TRANSACTION_SERIALIZABLE(8);
@@ -85,12 +88,12 @@ public void setPassword(String password) {
8588
}
8689

8790

88-
public String getServer() {
89-
return server;
91+
public String getDisplayName() {
92+
return displayName;
9093
}
9194

92-
public void setServer(String server) {
93-
this.server = server;
95+
public void setDisplayName(String displayName) {
96+
this.displayName = displayName;
9497
}
9598

9699
public String getEncryptedPassword() {
@@ -117,5 +120,12 @@ public void setIsolationLevel(String isolationLevel) {
117120
this.isolationLevel = isolationLevel;
118121
}
119122

123+
public List<Command> getCommands() {
124+
return commands;
125+
}
126+
127+
public void setCommands(List<Command> commands) {
128+
this.commands = commands;
129+
}
120130
}
121131

src/main/resources/conf/config.yml

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
1-
# Configure the SQLMonitor
1+
# SQLMonitor Configuration
2+
3+
# Provide password OR encryptedPassword,encryptionKey. See the documentation to find about password encryption.
4+
5+
# isolationLevel:Transaction isolation level to apply on the connection
6+
#Supported values are TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ and TRANSACTION_SERIALIZABLE
7+
#Default is TRANSACTION_READ_UNCOMMITTED
8+
29
servers:
3-
- server: "localhost"
10+
- displayName: "Instance1"
411
driver: "com.mysql.jdbc.Driver"
5-
connectionString: "jdbc:mysql://localhost:3388/test"
12+
connectionString: "jdbc:mysql://localhost:3388/database1"
613
user: "root"
7-
#Provide password or encryptedPassword and encryptionKey. See the documentation to find about password encryption.
814
password: "root"
9-
15+
encryptionKey:
1016
encryptedPassword:
17+
isolationLevel: "TRANSACTION_READ_UNCOMMITTED"
18+
19+
commands:
20+
- command: "select value from monitortest where id = 1"
21+
displayPrefix: "Expedia"
22+
- command: "select value from monitortest where id = 2"
23+
displayPrefix: "DerbySoft"
24+
25+
26+
- displayName: "Instance2"
27+
driver: "com.mysql.jdbc.Driver"
28+
connectionString: "jdbc:mysql://localhost:3388/database2"
29+
user: "root"
30+
password: "root"
1131
encryptionKey:
12-
#Transaction isolation level to apply on the connection
13-
#Supported values are TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ and TRANSACTION_SERIALIZABLE
14-
#Default is TRANSACTION_READ_UNCOMMITTED
32+
encryptedPassword:
1533
isolationLevel: "TRANSACTION_READ_UNCOMMITTED"
1634

35+
commands:
36+
- command: "select value from monitortest where id = 1"
37+
displayPrefix: "Expedia"
38+
- command: "select value from monitortest where id = 2"
39+
displayPrefix: "DerbySoft"
1740

18-
commands:
19-
- command: "select value from monitortest where id = 1"
20-
displayPrefix: "Expedia"
21-
- command: "select value from monitortest where id = 2"
22-
displayPrefix: "DerbySoft"
2341

2442
# Make sure the metric prefix ends with a |
25-
26-
metricPrefix: "Custom Metrics|SQL|"
43+
#This will create this metric in all the tiers, under this path.
44+
metricPrefix: "Custom Metrics|SQL|"
45+
#This will create it in specific Tier. Replace <ComponentID> with TierID
46+
#metricPrefix: "Server|Component:<ComponentID>|Custom Metrics|SQL|"

0 commit comments

Comments
 (0)