Skip to content

Commit 7a59edb

Browse files
authored
Merge pull request #8 from Appdynamics/v2.0.3
V2.0.3
2 parents aa4983f + 3ae5795 commit 7a59edb

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.appdynamics</groupId>
66
<artifactId>appd-exts-commons</artifactId>
7-
<version>2.0.2</version>
7+
<version>2.0.3</version>
88
<packaging>jar</packaging>
99
<name>extension-utils</name>
1010
<properties>

src/main/java/com/appdynamics/extensions/ABaseMonitor.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import com.singularity.ee.agent.systemagent.api.exception.TaskExecutionException;
88
import org.slf4j.Logger;
99
import org.slf4j.LoggerFactory;
10+
11+
import java.io.File;
1012
import java.util.Map;
1113

1214
/**
@@ -91,12 +93,19 @@ protected void initialize(Map<String, String> args) {
9193
if(configuration == null){
9294
monitorJob = createMonitorJob();
9395
MonitorConfiguration conf = new MonitorConfiguration(monitorName,getDefaultMetricPrefix(), monitorJob);
94-
conf.setConfigYml(args.get("config-file"));
96+
conf.setConfigYml(args.get("config-file"), new MonitorConfiguration.FileWatchListener() {
97+
@Override
98+
public void onFileChange(File file) {
99+
onConfigReload(file);
100+
}
101+
});
95102
initializeMoreStuff(conf);
96103
this.configuration = conf;
97104
}
98105
}
99106

107+
protected void onConfigReload(File file){};
108+
100109
protected AMonitorJob createMonitorJob() {
101110
return new AMonitorJob(this);
102111
}

src/main/java/com/appdynamics/extensions/conf/MonitorConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,5 @@ public MetricWriter getFromWriterCache(String metricPath) {
275275
public void putInWriterCache(String metricPath, MetricWriter writer) {
276276
cacheModule.putInWriterCache(metricPath,writer);
277277
}
278+
278279
}

src/main/java/com/appdynamics/extensions/dashboard/CustomDashboardUploader.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void uploadDashboard(String dashboardName, Xml xml, Map<String, String> a
5858
}
5959
}
6060
logger.debug("The controller login is successful, the cookie is [{}] and csrf is {}", cookies, csrf);
61-
boolean isPresent = isDashboardPresent(client, cookies, dashboardName);
61+
boolean isPresent = isDashboardPresent(client, cookies, dashboardName, csrf);
6262
if (isPresent) {
6363
if (overwrite) {
6464
uploadFile(dashboardName, xml, argsMap, cookies, csrf);
@@ -91,9 +91,11 @@ private void setProxyIfApplicable(Map<String, String> argsMap) {
9191
}
9292
}
9393

94-
private boolean isDashboardPresent(SimpleHttpClient client, StringBuilder cookies, String dashboardName) {
95-
Response response = client.target().path("controller/restui/dashboards/list/false")
96-
.header("Cookie", cookies.toString()).get();
94+
private boolean isDashboardPresent(SimpleHttpClient client, StringBuilder cookies, String dashboardName, String csrf) {
95+
Response response = client.target().path("controller/restui/dashboards/list/getAllDashboardsByType/false")
96+
.header("Cookie", cookies.toString())
97+
.header("X-CSRF-TOKEN",csrf)
98+
.get();
9799
if (response.getStatus() == 200) {
98100
ArrayNode arrayNode = response.json(ArrayNode.class);
99101
boolean isPresent = false;
@@ -111,7 +113,8 @@ private boolean isDashboardPresent(SimpleHttpClient client, StringBuilder cookie
111113
, response.getStatus());
112114
logger.info("Please change the [uploadDashboard] property in the config.yml to false. " +
113115
"The xml will be written to the logs folder. Please import it to controller manually");
114-
return false;
116+
logger.error("This API was changed in the controller version 4.3. So for older controllers, upload the dashboard xml file from the logs folder.");
117+
return true;//Fake that the dashboard exists.
115118
}
116119
}
117120

0 commit comments

Comments
 (0)