Menu

#7 graph does not reflect all data point

open
nobody
None
5
2015-02-15
2011-06-27
Anonymous
No

My RRD was created using the following template:

<rrd_def>
<path>${path}</path>
<step>300</step>
<datasource>
<name>${datasourceName}</name>
<type>GAUGE</type>
<heartbeat>600</heartbeat>
<min>U</min>
<max>U</max>
</datasource>
<archive>
<cf>LAST</cf>
<xff>0.5</xff>
<steps>1</steps>
<rows>105120</rows>
</archive>
<archive>
<cf>AVERAGE</cf>
<xff>0.5</xff>
<steps>12</steps>
<rows>8760</rows>
</archive>
<archive>
<cf>AVERAGE</cf>
<xff>0.5</xff>
<steps>288</steps>
<rows>366</rows>
</archive>
<archive>
<cf>AVERAGE</cf>
<xff>0.5</xff>
<steps>8928</steps>
<rows>12</rows>
</archive>
<archive>
<cf>MAX</cf>
<xff>0.5</xff>
<steps>1</steps>
<rows>288</rows>
</archive>
<archive>
<cf>MAX</cf>
<xff>0.5</xff>
<steps>288</steps>
<rows>366</rows>
</archive>
</rrd_def>
]]>
</rrd_template>

The database is popuated with 7 days worth of data. When I create a graph for the last 5 days the graph created is correct. When I create a graph starting 8 days ago, which includes NaN data the graph contains a spike for the first day in which data exists and nothing is plotted for the remainder of the days in which good data is available. Is this a configuration error?

The following method is called to create the graph.

public static void createGraphStartingAt(String fullyQualifiedRrdFileName, String fullyQualifiedGraphFileName,
Map<String, String> attributes, long startingAt) throws Exception
{
RrdDb rrdDb = new RrdDb(fullyQualifiedRrdFileName, true);

RrdGraphDef rrdGraphDef = new RrdGraphDef\(\);

Color color = new Color\(0x84, 0x93, 0x21\);

String legend = "";
String verticalLabel = "";
String consolidationFunction = DEFAULT\_CONSOLIDATION;

String title = attributes.get\(TITLE\_ATTRIBUTE\);

if\(attributes.containsKey\(CONSOLIDATION\_FUNCTION\)\)
    consolidationFunction = attributes.get\(CONSOLIDATION\_FUNCTION\);

if\(attributes.containsKey\(LEGEND\_ATTRIBUTE\)\)
    legend = attributes.get\(LEGEND\_ATTRIBUTE\);

if\(attributes.containsKey\(VERTICAL\_LABEL\_ATTRIBUTE\)\)
    verticalLabel = attributes.get\(VERTICAL\_LABEL\_ATTRIBUTE\);

if\(attributes.containsKey\(COLOR\_ATTRIBUTE\)\)
    color = KinetoColor.getColor\(attributes.get\(COLOR\_ATTRIBUTE\)\);

int datasourceIndex = 0;
int archiveIndex = 0;

if\(attributes.containsKey\(ARCHIVE\_INDEX\)\)
    archiveIndex = Integer.parseInt\(attributes.get\(ARCHIVE\_INDEX\)\);

Datasource ds = rrdDb.getDatasource\(datasourceIndex\);
String datasourceName = ds.getDsName\(\);

Archive arc = rrdDb.getArchive\(archiveIndex\);

long startTime = arc.getStartTime\(\);
long endTime = arc.getEndTime\(\);
long rraStep = arc.getArcStep\(\);

rrdDb.close\(\);

if\(startingAt == -1\)  
    startingAt = startTime;

logger.info\("rrd startTime=" + startTime + " endTime=" + endTime + " graph startTime=" + startingAt\);

if\(legend.length\(\) == 0\)
    \{
    rrdGraphDef.setNoLegend\(true\);
    \}

rrdGraphDef.setFilename\(fullyQualifiedGraphFileName\);

if\(verticalLabel.length\(\) &gt; 0\)
\{
    rrdGraphDef.setVerticalLabel\(verticalLabel\);

\}

String minValue = attributes.get\("minValue"\);
String maxValue = attributes.get\("maxValue"\);

if\(minValue \!= null\)
\{
    rrdGraphDef.setMinValue\(Double.parseDouble\(minValue\)\);
    rrdGraphDef.setRigid\(true\);

\}

if\(maxValue \!= null\)
\{
    rrdGraphDef.setMaxValue\(Double.parseDouble\(maxValue\)\);
    rrdGraphDef.setRigid\(true\);
\}

rrdGraphDef.datasource\(datasourceName, fullyQualifiedRrdFileName, 
        datasourceName, consolidationFunction\);

rrdGraphDef.line\(datasourceName, color, legend + "\\\l"\);
rrdGraphDef.setHeight\(200\);
rrdGraphDef.setWidth\(400\);
rrdGraphDef.setShowSignature\(false\);
rrdGraphDef.setUnitsExponent\(0\);
rrdGraphDef.setStep\(rraStep\);
rrdGraphDef.setImageFormat\(PNG\);
rrdGraphDef.setColor\(RrdGraphConstants.COLOR\_ARROW, new Color\(0x84, 0x93, 0x21\)\);

long timeNow = Calendar.getInstance\(\).getTimeInMillis\(\) / 1000;

rrdGraphDef.setTimeSpan\(startingAt, timeNow\);

rrdGraphDef.setTitle\(String.format\("%s - %s", title, DateAndTime.date\_now\(\)\)\);

@SuppressWarnings\("unused"\)
RrdGraph rrdGraph = new RrdGraph\(rrdGraphDef\);

}

The default CF is "LAST" and the archive index is 0.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.