Skip to content

Commit

Permalink
porting to new platform
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalgupApDx committed Feb 10, 2015
1 parent bb88393 commit fb452bf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 31 deletions.
12 changes: 6 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"id" : "ssl-certificate-monitoring-extension",
"type" : "monitor",
"displayName" : "SSL Certificate Monitoring Extension",
"description" : "SSL Certificate Monitoring Extension",
"version" : "1.0.3",
"repoLink" : "https://github.com/Appdynamics/ssl-certificate-monitoring-extension",
"downloadFilename" : "SslCertificateMonitor.zip",
"configs" : [
"displayName" : "SSL Certificate Extension",
"description" : "An AppDynamics extension that monitors the SSL certificates for configurable domains and should be used with a stand alone Java Machine Agent.",
"version" : "1.0.4",
"downloadLink" : "https://github.com/Appdynamics/ssl-certificate-monitoring-extension",
"imageLink" : "https://no-cache.appdynamics-static.com/appsphere/logos/ssl_128.png",
"defaultConfigs" : [
{
"name" : "monitor.xml",
"link" : "https://raw.githubusercontent.com/Appdynamics/ssl-certificate-monitoring-extension/master/src/main/resources/conf/monitor.xml",
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.appdynamics.extensions</groupId>
<artifactId>ssl-certificate-monitoring-extension</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -147,7 +147,7 @@
<copy todir="${target.dir}">
<fileset dir="${build.directory}" includes="${project.artifactId}.${project.packaging}"/>
</copy>
<zip destfile="${target.dir}-${project.version}.zip">
<zip destfile="${target.dir}.zip">
<zipfileset dir="${target.dir}" filemode="755" prefix="SslCertificateMonitor/"/>
</zip>
<delete dir="${target.dir}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ public class SslCertificateMonitor extends AManagedMonitor {
public static final Logger logger = Logger.getLogger(SslCertificateMonitor.class);
public static final String CONFIG_ARG = "config-file";
public static final String METRIC_SEPARATOR = "|";
public static final String LOG_PREFIX = "log-prefix";
private static final int DEFAULT_NUMBER_OF_THREADS = 10;
public static final int DEFAULT_THREAD_TIMEOUT = 30;

private static String logPrefix;
private ExecutorService threadPool;
//To load the config files
private final static ConfigUtil<Configuration> configUtil = new ConfigUtil<Configuration>();
Expand All @@ -50,10 +48,9 @@ public SslCertificateMonitor(){

public TaskOutput execute(Map<String, String> taskArgs, TaskExecutionContext taskExecutionContext) throws TaskExecutionException {
if(taskArgs != null) {
setLogPrefix(taskArgs.get(LOG_PREFIX));
logger.info(getLogPrefix() + " Starting the SSL Certificate Monitoring task.");
logger.info(" Starting the SSL Certificate Monitoring task.");
if (logger.isDebugEnabled()) {
logger.debug(getLogPrefix() + "Task Arguments Passed ::" + taskArgs);
logger.debug("Task Arguments Passed ::" + taskArgs);
}
String configFilename = getConfigFilename(taskArgs.get(CONFIG_ARG));
try {
Expand All @@ -66,19 +63,19 @@ public TaskOutput execute(Map<String, String> taskArgs, TaskExecutionContext tas
List<SslCertificateMetrics> sslCertMetrics = collectMetrics(parallelTasks,config.getThreadTimeout() == 0 ? DEFAULT_THREAD_TIMEOUT : config.getThreadTimeout());
//print the metrics
printStats(config, sslCertMetrics);
return new TaskOutput(getLogPrefix() + "SSL Certificate monitoring task completed successfully.");
return new TaskOutput("SSL Certificate monitoring task completed successfully.");
} catch (FileNotFoundException e) {
logger.error(getLogPrefix() + "Config file not found :: " + configFilename, e);
logger.error("Config file not found :: " + configFilename, e);
} catch (Exception e) {
logger.error(getLogPrefix() + "Metrics collection failed", e);
logger.error("Metrics collection failed", e);
} finally {
if(!threadPool.isShutdown()){
threadPool.shutdown();
}
}
}

throw new TaskExecutionException(getLogPrefix() + "SSL Certificate monitoring task completed with failures.");
throw new TaskExecutionException("SSL Certificate monitoring task completed with failures.");
}

private List<SslCertificateMetrics> collectMetrics(List<Future<SslCertificateMetrics>> parallelTasks,int timeout) {
Expand All @@ -89,11 +86,11 @@ private List<SslCertificateMetrics> collectMetrics(List<Future<SslCertificateMet
certMetricsForDomain = aParallelTask.get(timeout, TimeUnit.SECONDS);
allMetrics.add(certMetricsForDomain);
} catch (InterruptedException e) {
logger.error(getLogPrefix() + "Task interrupted." + e);
logger.error("Task interrupted." + e);
} catch (ExecutionException e) {
logger.error(getLogPrefix() + "Task execution failed." + e);
logger.error("Task execution failed." + e);
} catch (TimeoutException e) {
logger.error(getLogPrefix() + "Task timed out." + e);
logger.error("Task timed out." + e);
}
}
return allMetrics;
Expand Down Expand Up @@ -132,10 +129,10 @@ private void printMetric(String metricPath,String metricValue,String aggType,Str
timeRollupType,
clusterRollupType
);
System.out.println(getLogPrefix()+"Sending [" + aggType + METRIC_SEPARATOR + timeRollupType + METRIC_SEPARATOR + clusterRollupType
System.out.println("Sending [" + aggType + METRIC_SEPARATOR + timeRollupType + METRIC_SEPARATOR + clusterRollupType
+ "] metric = " + metricPath + " = " + metricValue);
if (logger.isDebugEnabled()) {
logger.debug(getLogPrefix() + "Sending [" + aggType + METRIC_SEPARATOR + timeRollupType + METRIC_SEPARATOR + clusterRollupType
logger.debug("Sending [" + aggType + METRIC_SEPARATOR + timeRollupType + METRIC_SEPARATOR + clusterRollupType
+ "] metric = " + metricPath + " = " + metricValue);
}
metricWriter.printMetric(metricValue);
Expand Down Expand Up @@ -180,14 +177,6 @@ private String getConfigFilename(String filename) {
return configFileName;
}

public String getLogPrefix() {
return logPrefix;
}

public void setLogPrefix(String logPrefix) {
this.logPrefix = (logPrefix != null) ? logPrefix : "";
}


public ExecutorService getThreadPool() {
return threadPool;
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/conf/monitor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<task-arguments>
<!-- config file-->
<argument name="config-file" is-required="true" default-value="monitors/SslCertificateMonitor/config.yml" />
<argument name="log-prefix" is-required="false" default-value="[SslCertificateAppDExt] " />
</task-arguments>
<java-task>
<classpath>ssl-certificate-monitoring-extension.jar</classpath>
Expand Down

0 comments on commit fb452bf

Please sign in to comment.