Holt-Winters plugin - plots

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Moderators, Developers

Post Reply
Author
Message
Crypty
Posts: 4
Joined: Tue Feb 08, 2011 4:11 pm

Holt-Winters plugin - plots

#1 Post by Crypty » Tue Feb 21, 2012 10:06 am

Hi,

I have implemented HWdEtect plugin to NfSen based on Holt-Winters method, using RRD database. But I have an issue to solve.

See the image...

You can see yellow areas which means that the plugin discovered some kind of anomaly behavior. It should be displayed only if the measured (green) area is lower or higher than confidence band (red). But in several cases it is colored by yellow even if it is not out of the bands. I looked into the .rrd file and in RRA FAILURES it is signed as a failure (value 1).

So I think, I have something wrong in displaying confidence bands (red).

In my code I do this:

Code: Select all

RRDs::graph "$BACKEND_PLUGINDIR/hwdetect/plots/hwdetect-$profile-$rrd_var-$channel-00.png",
                "--title", "HWdEtect $rrd_var prediction",
                "--start", "$start - 86400",
                "--end", "$start",
                "--lower-limit=0",
                "--rigid",
                "--width=600",
                "--height=200",
                "--alt-autoscale-max",
                "--imgformat","PNG",
                "DEF:obs=$rrds[0]:$rrd_var:AVERAGE",
                "DEF:pred=$rrds[0]:$rrd_var:HWPREDICT",
                "DEF:dev=$rrds[0]:$rrd_var:DEVPREDICT",
                "DEF:fail=$rrds[0]:$rrd_var:FAILURES",
                "TICK:fail#ffffa0:1.0:\"Failures\"",
                "AREA:obs#00ff00:\"Measured count of $rrd_var\"",
                "LINE2:pred#0000ff:\"HW Prediction\"",
                "CDEF:upper=pred,dev,$deltapos[0],*,+",
                "CDEF:lower=pred,dev,$deltanegs[0],*,-",
                "LINE1:upper#ff0000:\"Upper Confidence Bound\"",
                "LINE1:lower#ff0000:\"Lower Confidence Bound\""
            ;
The important part is probably:

Code: Select all

 "CDEF:upper=pred,dev,$deltapos[0],*,+",
 "CDEF:lower=pred,dev,$deltanegs[0],*,-",
 "LINE1:upper#ff0000:\"Upper Confidence Bound\"",
 "LINE1:lower#ff0000:\"Lower Confidence Bound\""
The variable $deltapos[0] saves the current value of delta parameter for Holt-Winters method.

Is it right? Is there a bug in rrdtool or should I use different value of delta in the plot creation?

Thanks in advise. If necessary I could post additional information/code...
Attachments
hwdetect-peak.png
Flows
hwdetect-peak.png (53.79 KiB) Viewed 3753 times

noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Holt-Winters plugin - plots

#2 Post by noname » Wed Feb 22, 2012 5:31 am

Though I'm not sure about it,
is the "RRA:FAILURES" defined correctly? (Is threshold specified properly?)

Otherwise, try using custom CDEF to judge whether if measured count (=obs) exceeds upper/lower confidence bound.

For example, change these lines

Code: Select all

"DEF:fail=$rrds[0]:$rrd_var:FAILURES",
"TICK:fail#ffffa0:1.0:\"Failures\"",
to

Code: Select all

"CDEF:fail=obs,upper,GT,INF,obs,lower,LT,INF,UNKN,IF,IF",
"AREA:fail#ffffa0:\"Failures\"",
The above CDEF means (maybe):

Code: Select all

IF obs > upper then
	result = INF
else
	IF obs < lower then
		result = INF
	else
		result = UNKN
	endif
endif

Crypty
Posts: 4
Joined: Tue Feb 08, 2011 4:11 pm

Re: Holt-Winters plugin - plots

#3 Post by Crypty » Wed Feb 22, 2012 8:28 am

Hi,

Window size = 1, threshold = 1.

And I will try your advice...

Crypty
Posts: 4
Joined: Tue Feb 08, 2011 4:11 pm

Re: Holt-Winters plugin - plots

#4 Post by Crypty » Thu Mar 01, 2012 5:03 pm

Hi,

with your change, the plot really yellows the area upper/lower than bounds. But in the original .rrd file all failures were the ones which were yellowed in the orig.plot. So the original plot was right, but plots wider boundaries - don't know why actually.

Post Reply