Re: problem in collecting json with names starting with a number

"the outsider" <[email protected]>
Newsgroups gmane.network.opennms.general
Message-ID <[email protected]>
You can never use a variable name starting with a number in javascript. 

And since json is “JavaScript object notation” it can’t be used either. 

 

I lost handful of hairs in the past by making the same mistake more then once. 

 

Van: onmstester onmstester [mailto:[email protected]] 
Verzonden: woensdag 31 januari 2018 05:10
Aan: General OpenNMS Discussion <[email protected]>
CC: General OpenNMS Discussion <[email protected]>
Onderwerp: Re: [opennms-discuss] problem in collecting json with names starting with a number

 

I forgot to mention that i'm using DefaultJsonCollectionHandler as handler-class.

Thanks in Advance

 

Sent using  <https://www.zoho.com/mail/> Zoho Mail

 

 

---- On Wed, 31 Jan 2018 07:35:08 +0330 onmstester onmstester <[email protected] <mailto:[email protected]> > wrote ----

 

the xml-datacollection config:

<xml-groups xmlns="..."> 

<xml-group name="root" resource-type="someType" resource-xpath="/">

<xml-object name="name" type="GAUGE" xpath="1name"/>

</xml-group>

</xml-groups>

 

and sample json:

 

{"1name":"someValue"}

 

I've had some other problem with json collector: when the json is an array of objects opennms could not collect it, somthing like this:

[{},{}]

 

And debugging xml-collector code i've got to conclusion that these two problems are limitations of opennms xml collector and i should write a proxy to solve this two problems before json results would be sent to opennms. Any less smelly solution suggested?!

 

Sent using  <https://www.zoho.com/mail/> Zoho Mail

 

 

---- On Tue, 30 Jan 2018 18:11:53 +0330 Roskens, Ronald <[email protected] <mailto:[email protected]> > wrote ----

 

 

 

 

------------------------------------------------------------------------------ 

Check out the vibrant tech community on one of the world's most 

engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________ 

Please read the OpenNMS Mailing List FAQ: 

http://www.opennms.org/index.php/Mailing_List_FAQ 

 

opennms-discuss mailing list 

 

To *unsubscribe* or change your subscription options, see the bottom of this page: 

https://lists.sourceforge.net/lists/listinfo/opennms-discuss

That's a strange one. Can you provide more details, like your xml-datacollection config, and a sample json, as with that data you can create a junit test to debug this further.

 

Ron

 

From: onmstester onmstester [mailto:[email protected] <mailto:[email protected]> ] 
Sent: Monday, January 29, 2018 10:50 PM
To: [email protected] <mailto:[email protected]> 
Subject: [opennms-discuss] problem in collecting json with names starting with a number

 

I've ran into a problem while trying to collect json metrics from elatstic API, it seems like that attribute having name starting with a numeric character cause commons-jxpath to throw exception:

 

org.opennms.netmgt.collection.api.CollectionException: Can't collect XML data because Invalid XPath: '1name'. Syntax error after: '1'

        at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:170) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        at org.opennms.netmgt.collectd.CollectionSpecification.collect(CollectionSpecification.java:274) ~[opennms-services-16.0.0.jar:?]

        at org.opennms.netmgt.collectd.CollectableService.doCollection(CollectableService.java:388) ~[opennms-services-16.0.0.jar:?]

        at org.opennms.netmgt.collectd.CollectableService.doRun(CollectableService.java:322) [opennms-services-16.0.0.jar:?]

        at org.opennms.netmgt.collectd.CollectableService.access$000(CollectableService.java:70) [opennms-services-16.0.0.jar:?]

        at org.opennms.netmgt.collectd.CollectableService$1.run(CollectableService.java:300) [opennms-services-16.0.0.jar:?]

        at org.opennms.core.logging.Logging.withPrefix(Logging.java:66) [org.opennms.core.logging-16.0.0.jar:?]

        at org.opennms.netmgt.collectd.CollectableService.run(CollectableService.java:296) [opennms-services-16.0.0.jar:?]

        at org.opennms.netmgt.scheduler.LegacyScheduler$1.run(LegacyScheduler.java:209) [opennms-services-16.0.0.jar:?]

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_45]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_45]

        at org.opennms.core.concurrent.LogPreservingThreadFactory$3.run(LogPreservingThreadFactory.java:124) [opennms-util-16.0.0.jar:?]

        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]

Caused by: org.opennms.netmgt.collection.api.CollectionException: Invalid XPath: '1name'. Syntax error after: '1'

        at org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler.collect(AbstractXmlCollectionHandler.java:198) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:168) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        ... 12 more

Caused by: org.apache.commons.jxpath.JXPathInvalidSyntaxException: Invalid XPath: '1name'. Syntax error after: '1'

        at org.apache.commons.jxpath.ri.Parser.parseExpression(Parser.java:63) ~[commons-jxpath-1.3.jar:1.3]

        at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.compileExpression(JXPathContextReferenceImpl.java:249) ~[commons-jxpath-1.3.jar:1.3]

        at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathContextReferenceImpl.java:280) ~[commons-jxpath-1.3.jar:1.3]

        at org.opennms.protocols.json.collector.AbstractJsonCollectionHandler.fillCollectionSet(AbstractJsonCollectionHandler.java:100) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        at org.opennms.protocols.json.collector.DefaultJsonCollectionHandler.fillCollectionSet(DefaultJsonCollectionHandler.java:54) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        at org.opennms.protocols.xml.collector.AbstractXmlCollectionHandler.collect(AbstractXmlCollectionHandler.java:191) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        at org.opennms.protocols.xml.collector.XmlCollector.collect(XmlCollector.java:168) ~[org.opennms.protocols.xml-16.0.0.jar:?]

        ... 12 more

 

I've checked newest version of opennms, but still got the same exception?

 


  _____  


This e-mail message is being sent solely for use by the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by phone or reply by e-mail, delete the original message and destroy all copies. Thank you.

------------------------------------------------------------------------------ 

Check out the vibrant tech community on one of the world's most 

engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________ 

Please read the OpenNMS Mailing List FAQ: 

http://www.opennms.org/index.php/Mailing_List_FAQ 

 

opennms-discuss mailing list 

 

To *unsubscribe* or change your subscription options, see the bottom of this page: 

https://lists.sourceforge.net/lists/listinfo/opennms-discuss

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-discuss mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.