Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 1S¨jpLã@sHddlZddlZddlZddlmZmZejeƒZGdd„dejƒZ dS)éN)ÚjavaÚjavaxc'@sœeZdZdZdZdZdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhd=œ!Zed>d?„ƒZe d@dA„ƒZ e dBdC„ƒZ e dDdE„ƒZ e dFdG„ƒZ dS)iÚTomcatJMXPluginzCTomcat Plugin for the FortiMonitor Agent using JMX to collect data.Z tomcat_jmxz Tomcat (JMX)úHeap Memory Usage Usedú java.langÚMemoryNÚHeapMemoryUsageÚusedÚbytesúHeap Memory Usage CommittedÚ committedúHeap Memory Usage InitÚinitúHeap Memory Usage MaxÚmaxúNon-Heap Memory Usage UsedÚNonHeapMemoryUsageúNon-Heap Memory Usage CommittedúNon-Heap Memory Usage InitúNon-Heap Memory Usage Maxú Thread CountÚ ThreadingÚ ThreadCountÚcountúOS Process CPU LoadÚOperatingSystemÚProcessCpuLoadÚpercentúOS System CPU LoadÚ SystemCpuLoadúOS Open File Descriptor CountÚOpenFileDescriptorCountúLoaded Class CountÚ ClassLoadingÚLoadedClassCountú Eden SpaceÚ MemoryPoolÚUsageú PS Eden SpaceúPar Eden Spaceú G1 Eden SpaceúSurvivor SpaceúPS Survivor SpaceúPar Survivor SpaceúG1 Survivor Spaceú PS Old Genú CMS Old Genú G1 Old GenÚCopyÚGarbageCollectorÚCollectionCountú PS ScavengeÚParNewúG1 Young GenerationúG1 Mixed GenerationÚMarkSweepCompactú PS MarkSweepÚConcurrentMarkSweepúG1 Old Generation)!z memory.heapzmemory.heap.committedzmemory.heap.initzmemory.heap.maxzmemory.non_heapzmemory.non_heap.committedzmemory.non_heap.initzmemory.non_heap.maxzthreading.countzos.cpu_load.processzos.cpu_load.systemzos.open_file_descriptorszclass_loading.loaded_classeszmemory_pool.edenzmemory_pool.eden.pszmemory_pool.eden.parzmemory_pool.eden.g1zmemory_pool.survivorzmemory_pool.survivor.pszmemory_pool.survivor.parzmemory_pool.survivor.g1zmemory_pool.old.pszmemory_pool.old.cmszmemory_pool.old.g1z gc.young.copyzgc.young.ps_scavengezgc.young.par_newzgc.young.g1_generationzgc.mixed.g1_generationzgc.old.mark_sweep_compactzgc.old.ps_mark_sweepzgc.old.concurrent_mark_sweepzgc.old.g1_generationcCsP|d|d|d}}}d|}|r4|d|7}|rD|d|7}tjj|ƒS)aÎreturns a constructed ObjectName. :type tuple_: tuple (label, domain, type, bean_name, attribute_name, composite_data_key, unit) :param tuple_: A tuple with all the information for an ObjectName. A string that represents the label, a string that represents the domain, and so on and so forth. :rtype: javax.management.ObjectName :return: An ObjectName object that can be used to lookup a MBean. éééz%s:zname=%s,ztype=%s)rÚ managementÚ ObjectName)Útuple_ÚdomainÚtype_Z bean_nameZcanonical_name©rEú'/usr/lib/fm-agent/plugins/tomcat_jmx.pyZ__get_object_name_from_tupleBs   z,TomcatJMXPlugin.__get_object_name_from_tuplec Csdddddg}i}x`|D]X}|j|ƒ}| rB|d krBtd|ƒ‚q| rT|d krTqqdd„|jd ƒDƒ}|||<qWi}|d}x–t|ƒD]Š\} } d| i|| <xtdD]l}t|j|gƒƒd krÊ||| } n:t|j|gƒƒd krì||d } n|dkr¤td|ƒ‚nq¤| || |<q¤WqŠW|S)aØ Parse the config object to build a structure of connections parameters based on the number of entries that are in each key. The main parameter we base on to split off is host. :type config: dict (host, port, username, password, jvm_path) :param config: Dictionary with the information stored in the config file. :rtype: Dict :return: Dictionary with connection information split up in multiple if needed. ÚhostÚportÚusernameÚpasswordÚjvm_pathz"Missing %s information from configcSsg|]}|jdƒ‘qS)ú )Ústrip)Ú.0ÚvaluerErErFú qsz?TomcatJMXPlugin.get_connections_from_config..ú,r=r)rIrJ)rIrJ)rHrIrJrK)rIrJ)ÚgetÚ ValueErrorÚsplitÚ enumerateÚlen) ÚclsÚconfigÚkeysÚdataÚkeyÚ key_valueÚvaluesÚ connectionsÚhostsÚindexrGrOrErErFÚget_connections_from_configZs0      z+TomcatJMXPlugin.get_connections_from_configc Csòtj}d}|s$d}|jj|ƒtj}d|ks4d|krPd|j}|jj|ƒtj}|jdƒ}|s´y,tjƒ}|sˆtj}d|j}|jj|ƒWn(tj}d|j}|jj|ƒYnXy"|tjkrÔtj ƒ rÔtj |ƒWn"tj}d}|jj|ƒYnX|tjk�rèyºtj ƒ�stj |ƒt j j ƒ}|jd ƒ�rt|jd ƒ�rttjt jjƒ|jd ƒ|jd ƒgƒ}|jtjjjj|ƒd |jdƒt|jdƒƒf}tjjj|ƒ}tjjjj||ƒ} | jƒ} || dfStk �ræd }|jj|ƒYnX|d|fS) a… returns a list of connections from the jpype library - a python interface to the Java Native Interface. Wheter there are 1 or many connections depends on the number of entries in the host, port and optionally username/password/jvm entries. :type config: dict :param config: Mapping of information under the application block for this plugin. :rtype: tuple (status, connection, error_message) :return: A tuple containing a numeric value corresponding to the agent_util status'. A MBeanServerConnection object. And, a string with an error message if any. NzNo JMX configuration foundrGrHzJMissing value in the [%s] block of the agent config file (e.g host, port).rKzYUnable to find JVM, please specify 'jvm_path' in the [%s] block of the agent config file.z;Unable to access JMX metrics because JVM cannot be started.rIrJz*service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmizBUnable to access JMX metrics, JMX is not running or not installed.)Ú agent_utilÚ SUPPORTEDÚlogÚinfoÚ MISCONFIGUREDÚtextkeyrRÚjpypeÚgetDefaultJVMPathÚ isJVMStartedÚstartJVMrÚutilÚHashMapÚJArrayÚlangÚStringÚputrr@ÚremoteÚ JMXConnectorÚ CREDENTIALSÚintÚ JMXServiceURLÚJMXConnectorFactoryÚconnectÚgetMBeanServerConnectionÚ ExceptionÚ exception) rWrXÚstatusÚmsgrKZj_hashZj_arrayÚurlZjmx_urlZjmx_socÚ connectionrErErFZ__get_connectionˆsl          z TomcatJMXPlugin.__get_connectionc Cs¦i}|j|ƒ}i}g}xT|jƒD]H}|j|ƒ\}}} d|d|df} | r`|jd| | fƒq ||| <q W|jƒsž|jjdƒx|D]} |jj| ƒq†W|Stj }d} x|D]} |jj | ƒq®WxÞ|j j ƒD]Ð\} } |j | ƒ}g}xZ|j ƒD]N\} }y|j|ƒ|j| ƒWqîtk �r:|jjd|| fƒwîYqîXqîWt|jƒƒdk�rn| �rnd }tj}d | } n d} tj }| d | d }}|||| |d œ|| <qÎW|S)areturns a json object who's textkeys correspond to a given metric available on the JVM. :type config: dict :param config: Mapping of information under the application block for this plugin. :return: JSON Object for all metrics z%s:%srGrHz%s %sz#Unable to connect to any connectionÚz.Tomcat (JMX) plugin - %s bean not found at %s.r=Nz Unreachable %s at any connectionré)ÚlabelÚoptionsr|Ú error_messageÚunit)rar]Ú _TomcatJMXPlugin__get_connectionÚappendrYrdreÚerrorrbrcÚwarningÚ JMX_MAPPINGÚitemsÚ,_TomcatJMXPlugin__get_object_name_from_tupleÚgetObjectInstancerzr{rVÚ UNSUPPORTED)rWrXÚresultÚconfigsr^ÚerrorsÚentryr|rr}Zconnection_keyrˆr[rBÚ object_namerƒr‚r…rErErFÚ get_metadataósX           zTomcatJMXPlugin.get_metadatac Cs |j|ƒ}|rBx:|jƒD]$}d|d|df}||kr|}qWn|d}|j|ƒ\}}} | rr|jjd| ƒdS|jj|ƒ} | d| d} } |j| ƒ} yR|j| ƒ}|j |j ƒ| ƒ}|j j }d |krÎ|j ƒS|j| ƒsÜdS|j| ƒ}|j ƒS|jjd | ƒdSdS) a�returns a value for the metric. :type textkey: string :param textkey: Canonical name for a metric. :type data: string :param data: Specific option to check for. :type config: dict :param config: Mapping of information under the application block for this plugin. :rtype: double :return: Value for a specific metric z%s:%srGrHrzFailed to get a connection: %sNééZCompositeDataSupportz(Tomcat (JMX) plugin - %s bean not found.)rar]r†rdrerŠrRrŒr�Ú getAttributeZ getObjectNameÚ __class__Ú__name__Ú floatValueZ containsKey)rWrgrZrXÚentriesr’Zpossible_matchr|rr}rBZattribute_nameZcomposite_data_keyr“Zobject_instanceZattribute_valueZattribute_class_nameZ check_resultrErErFÚcheck;s8        zTomcatJMXPlugin.check)rrrNrr r )r rrNrr r )r rrNrrr )rrrNrrr )rrrNrr r )rrrNrr r )rrrNrrr )rrrNrrr )rrrNrNr)rrrNrNr)rrrNrNr)r rrNr!Nr)r"rr#Nr$Nr)r%rr&r%r'r r )r(rr&r(r'r r )r)rr&r)r'r r )r*rr&r*r'r r )r+rr&r+r'r r )r,rr&r,r'r r )r-rr&r-r'r r )r.rr&r.r'r r )r/rr&r/r'r r )r0rr&r0r'r r )r1rr&r1r'r r )r2rr3r2r4Nr)r5rr&r5r4Nr)r6rr3r6r4Nr)r7rr3r7r4Nr)r8rr3r8r4Nr)r9rr3r9r4Nr)r:rr3r:r4Nr)r;rr3r;r4Nr)r<rr3r<r4Nr)r™Ú __module__Ú __qualname__Ú__doc__rgr‚rŠÚ staticmethodrŒÚ classmethodrar†r”rœrErErErFr sÞ  . k Hr) ÚloggingrbrhrrÚ getLoggerr™ÚloggerÚPluginrrErErErFÚs