From: <hr...@rh...> - 2008-11-25 15:51:27
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [2123] RHQ-1182 Provide a ping time metric and don't preven metric sending for non-snmp based metrics when no snmp is configured.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>2123</dd> <dt>Author</dt> <dd>hrupp</dd> <dt>Date</dt> <dd>2008-11-25 09:51:23 -0600 (Tue, 25 Nov 2008)</dd> </dl> <h3>Log Message</h3> <pre>RHQ-1182 Provide a ping time metric and don't preven metric sending for non-snmp based metrics when no snmp is configured.</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulespluginsapachesrcmainjavaorgrhqpluginsapacheApacheServerComponentjava">rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java</a></li> <li><a href="#rhqtrunkmodulespluginsapachesrcmainresourcesMETAINFrhqpluginxml">rhq/trunk/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulespluginsapachesrcmainjavaorgrhqpluginsapacheApacheServerComponentjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java (2122 => 2123)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java 2008-11-25 15:08:54 UTC (rev 2122) +++ rhq/trunk/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java 2008-11-25 15:51:23 UTC (rev 2123) </span><span class="lines">@@ -95,6 +95,7 @@ </span><span class="cx"> private SNMPClient snmpClient; private URL url; private ApacheBinaryInfo binaryInfo; </span><span class="add">+ private long availPingTime = -1; </span><span class="cx"> /** * Delegate instance for handling all calls to invoke operations on this component. </span><span class="lines">@@ -112,8 +113,11 @@ </span><span class="cx"> if (!snmpSession.ping()) { log.warn( "Failed to connect to SNMP agent at " </span><span class="rem">- + snmpSession - + ". Make sure 1) the managed Apache server has been instrumented with the JON SNMP module, 2) the Apache server is running, and 3) the SNMP agent host, port, and community are set correctly in this resource's connection properties."); </span><span class="add">+ + snmpSession + "\n" + + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n" + + "2) the Apache server is running, and\n" + + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n" + + "The agent will not be able to record metrics from apache httpd without SNMP"); </span><span class="cx"> } else configured = true; </span><span class="lines">@@ -166,7 +170,15 @@ </span><span class="cx"> // process is running. boolean available; try { </span><span class="rem">- available = (this.url != null) ? WWWUtils.isAvailable(this.url) : getSNMPSession().ping(); </span><span class="add">+ if (this.url != null ) { + long t1 = System.currentTimeMillis(); + available = WWWUtils.isAvailable(this.url); + availPingTime =System.currentTimeMillis()-t1; + } + else { + available = getSNMPSession().ping(); + availPingTime = -1; + } </span><span class="cx"> } catch (Exception e) { available = false; } </span><span class="lines">@@ -176,18 +188,23 @@ </span><span class="cx"> public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> schedules) throws Exception { SNMPSession snmpSession = getSNMPSession(); </span><span class="rem">- if (!snmpSession.ping()) { - throw new Exception("Failed to connect to SNMP agent at " + snmpSession - + " - aborting metric collection..."); - } </span><span class="add">+ boolean snmpPresent = snmpSession.ping(); </span><span class="cx"> for (MeasurementScheduleRequest schedule : schedules) { String metricName = schedule.getName(); if (metricName.equals(SERVER_BUILT_TRAIT)) { MeasurementDataTrait trait = new MeasurementDataTrait(schedule, this.binaryInfo.getBuilt()); report.addData(trait); </span><span class="add">+ } else if (metricName.equals("rhq_avail_ping_time")) { + if (availPingTime == -1) + continue; // Skip if we have no data + MeasurementDataNumeric num = new MeasurementDataNumeric(schedule, (double) availPingTime); + report.addData(num); </span><span class="cx"> } else { // Assume anything else is an SNMP metric. </span><span class="add">+ if (!snmpPresent) + continue; // Skip this metric if no SNMP present + </span><span class="cx"> try { //noinspection UnnecessaryLocalVariable String mibName = metricName; </span></pre></div> <a id="rhqtrunkmodulespluginsapachesrcmainresourcesMETAINFrhqpluginxml"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml (2122 => 2123)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml 2008-11-25 15:08:54 UTC (rev 2122) +++ rhq/trunk/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml 2008-11-25 15:51:23 UTC (rev 2123) </span><span class="lines">@@ -25,7 +25,7 @@ </span><span class="cx"> <c:simple-property name="executablePath" required="false" description="the path to the Apache executable - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default value is 'bin/httpd' on UNIX or 'bin\Apache.exe' on Windows"/> <c:simple-property name="controlScriptPath" required="false" </span><span class="rem">- description="the path to the Apache control script - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'bin/apachectl' on UNIX or the Apache executable on Windows"/> </span><span class="add">+ description="the path to the Apache control script - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'bin/apachectl' on UNIX or the Apache executable on Windows"/> </span><span class="cx"> <c:simple-property name="url" displayName="URL" required="false" description="the http or https URL that will be used to check availability for this Apache server; if not set, availablity will be determined based on whether plugin can connect to the Apache server's SNMP agent"/> <c:simple-property name="snmpAgentHost" displayName="SNMP Agent Host" default="127.0.0.1" </span><span class="lines">@@ -60,7 +60,7 @@ </span><span class="cx"> detail."/> </c:group> </span><span class="rem">- </span><span class="add">+ </span><span class="cx"> </plugin-configuration> <!-- all httpd processes that are not child processes of another httpd process --> </span><span class="lines">@@ -133,9 +133,9 @@ </span><span class="cx"> <c:simple-property name="output" type="longString" description="the control script's output (stdout and stderr interleaved)"/> </results> </operation> </span><span class="rem">- </span><span class="add">+ </span><span class="cx"> <metric displayName="Number of Concurrent Connections" property="applInboundAssociations" </span><span class="rem">- defaultOn="true" defaultInterval="300000" displayType="summary" units="none"/> </span><span class="add">+ defaultOn="true" defaultInterval="300000" displayType="summary" units="none"/> </span><span class="cx"> <!-- traits determined via "httpd -V" --> </span><span class="lines">@@ -149,6 +149,11 @@ </span><span class="cx"> description="the date and time this Apache server was last started" dataType="trait" defaultOn="true" displayType="summary"/> </span><span class="add">+ <!-- Metric collected by pinging availability over http --> + <metric property="rhq_avail_ping_time" displayType="summary" units="milliseconds" + displayName="Time to ping the server for availability" + description="Time it took to ping the server for availability over http; this includes DNS lookup time."/> + </span><span class="cx"> <event name="errorLogEntry" description="an entry in the error log file"/> <service name="Apache Virtual Host" discovery="ApacheVirtualHostServiceDiscoveryComponent" class="ApacheVirtualHostServiceComponent"> </span><span class="lines">@@ -304,7 +309,7 @@ </span><span class="cx"> <metric property="ResponseTime" displayName="HTTP Response Time" dataType="calltime" defaultOn="false" units="milliseconds" destinationType="URL" description="the minimum, maximum, and average response times for HTTP requests serviced by this virtual host"/> </span><span class="rem">- </span><span class="add">+ </span><span class="cx"> </service> </server> </span> </pre> </div> </div> </body> </html> |