2
我正在更新監視tomcat7的tomcat線程利用率的nagios插件,並且存在「引號」中所包含值的問題。包含引號的Perl xml
相關的XML從自卸車:
$VAR1 = {
'connector' => {
'"ajp-bio-8009"' => {
'requestInfo' => {
'maxTime' => '0',
'errorCount' => '0',
'bytesSent' => '0',
'processingTime' => '0',
'requestCount' => '0',
'bytesReceived' => '0'
},
'workers' => {},
'threadInfo' => {
'currentThreadCount' => '0',
'maxThreads' => '500',
'currentThreadsBusy' => '0'
}
}
},
培訓相關的Perl:
$max = $xml->{'connector'}->{'"ajp-bio-8009"'}->{'threadInfo'}->{'maxThreads'};
$current = $xml->{'connector'}->{'"ajp-bio-8009"'}->{'threadInfo'}->{'currentThreadCount'};
$busy = $xml->{'connector'}->{'"ajp-bio-8009"'}->{'threadInfo'}->{'currentThreadsBusy'};
但不幸的是這似乎不工作,當我不填充爲$最大的任何值,$當前或$繁忙。根據要求
完整的XML:
<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="/manager/xform.xsl" ?>
<status>
<jvm>
<memory free="70176624" total="165605376" max="2534080512"/>
<memorypool name="Eden Space" type="Heap memory" usageInit="12582912"
usageCommitted="45744128" usageMax="699072512" usageUsed="23043760"/>
<memorypool name="Survivor Space" type="Heap memory" usageInit="1572864"
usageCommitted="5701632" usageMax="87359488" usageUsed="5545632"/>
<memorypool name="Tenured Gen" type="Heap memory" usageInit="31588352"
usageCommitted="114159616" usageMax="1747648512" usageUsed="66839360"/>
<memorypool name="Code Cache" type="Non-heap memory" usageInit="2555904"
usageCommitted="5505024" usageMax="50331648" usageUsed="5395264"/>
<memorypool name="Perm Gen" type="Non-heap memory" usageInit="21757952"
usageCommitted="51904512" usageMax="1048576000" usageUsed="51657456"/>
</jvm>
<connector name='"ajp-bio-8009"'>
<threadInfo maxThreads="500" currentThreadCount="0" currentThreadsBusy="0"/>
<requestInfo maxTime="0" processingTime="0" requestCount="0" errorCount="0"
bytesReceived="0" bytesSent="0"/>
<workers/>
</connector>
<connector name='"http-bio-8080"'>
<threadInfo maxThreads="200" currentThreadCount="10" currentThreadsBusy="1"/>
<requestInfo maxTime="1596" processingTime="4078" requestCount="416" errorCount="64"
bytesReceived="0" bytesSent="639904"/>
<workers>
<worker stage="R" requestProcessingTime="0" requestBytesSent="0"
requestBytesReceived="0" remoteAddr="?" virtualHost="?" method="?"
currentUri="?" currentQueryString="?" protocol="?"/>
<worker stage="R" requestProcessingTime="0" requestBytesSent="0"
requestBytesReceived="0" remoteAddr="?" virtualHost="?" method="?"
currentUri="?" currentQueryString="?" protocol="?"/>
<worker stage="R" requestProcessingTime="0" requestBytesSent="0"
requestBytesReceived="0" remoteAddr="?" virtualHost="?" method="?"
currentUri="?" currentQueryString="?" protocol="?"/>
<worker stage="S" requestProcessingTime="3" requestBytesSent="0"
requestBytesReceived="0" remoteAddr="38.88.49.38" virtualHost="blah01.blah.com"
method="GET" currentUri="/manager/status" currentQueryString="XML=true"
protocol="HTTP/1.1"/>
<worker stage="R" requestProcessingTime="0" requestBytesSent="0"
requestBytesReceived="0" remoteAddr="?" virtualHost="?" method="?"
currentUri="?" currentQueryString="?" protocol="?"/>
<worker stage="R" requestProcessingTime="0" requestBytesSent="0"
requestBytesReceived="0" remoteAddr="?" virtualHost="?" method="?"
currentUri="?" currentQueryString="?" protocol="?"/>
</workers>
</connector>
</status>
你可以顯示原始XML嗎? – David
當然,編輯後。 – user3029353
嘗試逐節點調試。例如,打印Dumper $ xml - > {'connector'} - > {'「ajp-bio-8009」'}然後下一個節點,直到最後一個節點。並檢查你在哪裏缺少價值。 –