not able to fetch the data from rrd file - rrdtool

I am using RRDTool version 1.2.30 on windows platform, i have one .rrd file and when i tried to fetch data using 'rrdtool fetch' it is giving me following error.
ERROR: the RRD does not contain an RRA
matching the chosen CF
on firing following command
rrdtool fetch usage.rrd AVERAGE -r
3600 -s 1298264400 -e 1298350800
i really don't know whats wrong with this even when i tried to view the data in xml using rrdtool dump over usage.rrd its is showing me following error.
<!-- Round Robin Database Dump --><rrd> <version> 0003 </version
<step> 2 </step> <!-- Seconds -->
<lastupdate> 0 </lastupdate> <!-- 1970-01-01 05:30:00 In
e -->
<ds>
<name> </name>
<type> </type>
<minimal_heartbeat> 0 </minimal_heartbeat>
<min> 5.9287877501e-322 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> LAST </last_ds>
<value> 5.0000000000e-001 </value>
<unknown_sec> 1 </unknown_sec>
</ds>
<ds>
<name> </name>
<type> </type>
<minimal_heartbeat> 0 </minimal_heartbeat>
<min> 5.9287877501e-322 </min>
<max> NaN </max>
<!-- PDP Status -->
<last_ds> </last_ds>
<value> 2.4703282292e-323 </value>
<unknown_sec> 2016 </unknown_sec>
</ds>
<!-- Round Robin Archives --></rrd>
ERROR: unknown data acquisition function ''

my guess is, that this rrd file was created by some other copy of rrdtool ... under windows it is possible to create slightly incompatible versions of rrdtool by compiling them with different compilers :-(

Rrd database created at Linux is not compatible with rrdtool (same version) at Windows. Tested on version 1.3.8.
You must export rrd to xml at Linux:
rrdtool dump file.rrd > file.xml
and import it at Windows:
rrdtool.exe restore file.xml file.rrd
If your locale representation of floating point number differs between Linux (1.234e+05) and Windows (1,234e+05), you must convert numbers in file.xml before import.

Related

Xslt conversion for dateTime in different timezone with day light saving

Looking for some help on xslt conversion for dateTime in different timezone with day light saving. How to handle EST vs EDT while doing dateTime conversion in xslt?
enter code here
Below is one Sample order xml which will be converted into another order format <salesOrders> using xslt.
All dates in the "salesOrders" are supposed to be stored in GMT timezone.
<!-- Input orders xml -->
<xml>
<orders>
<order>
<order_id>1</order_id>
<!--lots of other details -->
<order_dateTime>2019/03/09 14:00</order_dateTime> <!-- yyyy/MM/dd hh24:mm-->
<order_timezone>America/New_York</order_timezone>
<!-- This time does not fall under day light saving ( UTC -0500) -->
</order>
<order>
<order_id>2</order_id>
<!--lots of other details -->
<order_dateTime>2019/03/10 14:00</order_dateTime>
<order_timezone>America/New_York</order_timezone>
<!-- This time falls under day light saving timing ( UTC -0400) -->
</order>
<order>
<order_id>3</order_id>
<!--lots of other details -->
<order_dateTime>2019/03/10 14:00</order_dateTime>
<!-- format : yyyy/MM/dd hh24:mm-->
<order_timezone>Asia/Kolkata</order_timezone>
<!-- Indian Standard Time ( UTC +0530) -->
</order>
</orders>
</xml>
<!-- after xslt conversion, the date should be converted as given below. -->
<xml>
<salesOrders>
<salesOrder>
<salesOrderId>1</salesOrderId>
<!-- required details -->
<salesOrderDttm>2019-03-09T19:00:00</salesOrderDttm> <!-- (14 + 5:00) -->
<!-- converted the time into GMT (-04:30)-->
</salesOrder>
<salesOrder>
<salesOrderId>2</salesOrderId>
<!-- required details -->
<salesOrderDttm>2019-03-09T18:00:00</salesOrderDttm> <!-- (14 + 4:00) -->
<!-- converted the time into GMT (-05:30)-->
</salesOrder>
<salesOrder>
<salesOrderId>2</salesOrderId>
<salesOrderDttm>2019-03-09T08:30:00</salesOrderDttm> <!-- (14 - 5:30) -->
</salesOrder>
</salesOrders>
</xml>
Need help for pupulating content of "salesOrderDttm"
The content of <orderDateTime> and <orderTimeZone> will be used to populate <salesOrderDttm>.
As mentioned above, it will be maintained in GMT (offset +0000) timezone.
The main problem is, same Time zone being treated differently. At one time(first order), offset is +5:00 and at another time(2nd order) the offset is +04:30
How to do it in xslt?
Came across adjust-dateTime-to-timezone() function, but that also expects us to provide the offset.
Is there any way to handle it?
I hope this is a very common problem and must be solved
Saw this post, but all it says it is not possible what I am looking for.
Similar query on stack overflow
In XSLT 3.0 you can achieve this using the $place argument of the format-dateTime() function. Quoting from the Functions and Operators spec ยง9.8.4
If the $place argument is supplied in the form of an IANA timezone
name that is recognized by the implementation, then the date or time
being formatted is adjusted to the timezone offset applicable in that
timezone. For example, if the xs:dateTime value 2010-02-15T12:00:00Z
is formatted with the $place argument set to America/New_York, then
the output will be as if the value 2010-02-15T07:00:00-05:00 had been
supplied. This adjustment takes daylight savings time into account
where possible; if the date in question falls during daylight savings
time in New York, then it is adjusted to timezone offset -PT4H rather
than -PT5H. Adjustment using daylight savings time is only possible
where the value includes a date, and where the date is within the
range covered by the timezone database.
Note that the way this is phrased gives implementations the option to "not recognize" timezone names; but let's assume they do.
First of course you need to convert 2019/03/09 14:00 to the xs:dateTime value 2019-03-09T14:00:00Z, which is a simple bit of string manipulation.
Now you can determine the timezone offset for America/New_York by doing format-time(xs:dateTime('2019-03-09T00:00:00'), '[Z]', (), (), 'America/New_York'), which will give you a value such as "-05:00" (as a string). You can convert this to a dayTimeDuration -PT05H00M using more simple string manipulation, and then use adjustDateTimeToTimezone() to apply this displacement to your original date/time value.
The XSLT 2.0 version of format-dateTime() does not have this capability defined.

Xmlstarlet select String+number for update

I want to update an element in my xml-File, with some dynamic names.
The name (paraName) is always GLOBPARA followed by a number, like you can see in the following example. These are the elements I want to change the value.
The file is also filled with some elements, which are also starting with an GLOBPARA, but have no simple number following. These elements I don't want to change.
With the following command I can change every element, which has a GLOBPARA in the name. Including the unwanted ones.
xmlstarlet ed --update "//globPara[contains(paramName, 'GLOBPARA')]/paramValue" -v "100" test.xml
Question:
How do I change only the ones, containing a String (GLOBPARA) and some random Numbers?
Before:
<?xml version="1.0" encoding="UTF-8"?>
<container>
<dataList>
<globPara>
<paramName>GLOBPARA260</paramName>
<paramValue>0</paramValue>
</globPara>
<globPara>
<paramName>GLOBPARAMON_BAD_TEST_18_1_SGB_IV</paramName>
<paramValue>2555</paramValue>
</globPara>
</dataList>
</container>
Wanted result:
<?xml version="1.0" encoding="UTF-8"?>
<container>
<dataList>
<globPara>
<paramName>GLOBPARA260</paramName>
<paramValue>100</paramValue>
</globPara>
<globPara>
<paramName>GLOBPARAMON_BAD_TEST_18_1_SGB_IV</paramName>
<paramValue>2555</paramValue>
</globPara>
</dataList>
</container>
I tried it with the regex d+, but it didn't work.
xmlstarlet ed --update "//globPara[contains(paramName, 'GLOBPARA[\d+]')]/paramValue" -v "100" test.xml
You can try below XPath
//globPara[number(substring-after(paramName, 'GLOBPARA'))>=0]/paramValue
This will return you paramValue of globPara node that contains paraName child with text in format GLOBPARAXXX where XXX is ANY positive number

Unexpected behaviour of the XPath-axis preceding

I tried to make a list of all different values of the attribute year from the following XML
<Parts>
<Part Name="S1">
<Year year="2018" i="1"/>
<Year year="2017" i="2"/>
<Year year="2018" i="3"/>
<Year year="2017" i="4"/>
</Part>
</Parts>
with XSLT (with ant 1.8.2), using the axis preceding
<xsl:template match="/">
<xsl:for-each select="//Year [not( #year = preceding::Year/#year)]">
<xsl:sort select="#year" order="ascending" />
year: <xsl:value-of select="#year"/> -- <xsl:value-of select="./#i"/>
<br/><hr/>
</xsl:for-each>
</xsl:template>
getting the result
year: 2017 -- 2
year: 2018 -- 1
year: 2018 -- 3
I don't know, why I've got two times the "2018" (it is always the first of the selected elements giving the double).
With the axis preceding-sibling I get the expected result, a list with every value once:
year: 2017 -- 2
year: 2018 -- 1
Has anybody an explanation for this behaviour? I supposed preceding and preceding-sibling giving the same result in this example.
MK
Edit: Thanks for the comments.
I use the Java SE JDK 1.7.0
In the next time I will try to replace the processor by another implementation.
Last I knew, the version of Xalan packaged with the Sun JDKs was ancient and buggy. As Michael suggests, I would STRONGLY recommend obtaining the Apache versions until and unless Sun/Oracle fixes that.
(The XSLT processor packaged with IBM's JDKs is much less buggy -- it was being maintained in parallel with the Apache code until relatively recently, when that was replaced by a new processor written inside IBM. Alas, the IBM JDKs are not available separately; they ship only bundled with an IBM product that uses them.)

How to Get Correctly formatted date using Xslt?

I have a xslt code for getting the date from the database.the code is working correctly and I got the output ,but the problem is the date is not in correct format.here is the result.
output: 2013-05-07T11:27:46.7+02:00
my code is
<xsl:variable name="lastchange" select="shop:ExecStoredProcedure('kt_Lastchange',concat('#account:',$accid,',#itemnumber:',id))"></xsl:variable>
<textarea>
<xsl:value-of select ="$lastchange"/>
</textarea>
anyone can help for getting the correctly format of date?
If you are using
XSLT 1.0 version, use EXSLT - date:format-date date extension
XSLT 2.0 version, use built-in: Formatting Dates and Times date extension
Code
<xsl:variable name="dt" as="xs:dateTime" select="xs:dateTime('2012-10-21T22:10:15')"/>
<xsl:value-of select="format-dateTime($dt, '[Y0001]/[M01]/[D01]')"/>

libxml2 XPATH - Selecting subset of data from XML

I am fairly new to XML dev.. I had a few questions regarding XML parsing with XPATH and libxml.
I have an XML structured as :
<resultset>
<result count=1>
<row>
<name> He-Man! </name>
<home> Greyskull </home>
<row>
</result>
<result count=2>
<row>
<name> Spider-Man</name>
<home> Some downtown apartment </home>
<row>
<row>
<name> Disco-Man!</name>
<home> The 70's dance floor </home>
<row>
</result>
<resultset>
I need to pick out the names from this XML , but where the count is 2 , i need it only from the first record. I ran through a few tutorials, but i am unable to come up with an XPATH query which would serve this purpose.
/name will select all name elements.
/result[#count > 1 ]/row[1]/name | /result[#count =1 ]/row/name
Is this possible to be done with XPATH ? Is this better to be done via XPATH or by walking the XML tree?
Can some one point me to some complex searches through out XML's ?
Edit : The actual scenario requires select a subset of the XML row , which are nested at 2 levels at times. This sounds like i need to OR '|' many paths to select the nodes i require... I am not sure if that would be efficient as opposed to walking a tree... The above is typed to replicate the problem :)
Thanks!
Try this XPath -
/resultset/result[#count=2]/row/name
This will give a list of all nodes falling under this XPath. From this just take the first element (as you needed only the first record).
I'd probably keep my xpath simpler and just extract both cases, then loop over both node sets.
If you do need to go down the single xpath route, you should try out your xpath expressions in something that lets you enter them live, rather than having to recompile C/C++ code. You should be able to do that by loading your XML into firefox and using firebug - for example typing $x('//name') in the firebug console gives three nodes.
NOTE however that your XML is invalid... You have a bunch of "<row>"s that should be "</row>" and the same for "<resultset>" and your counts need to be
<result count="1">
i.e. with quote marks around the value.