Least Square Line

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

Post Reply
Mikf
Posts: 47
Joined: Fri Aug 13, 2004 11:35 am
Location: Paris, France

Least Square Line

Post by Mikf »

hi!
i'm writing a patch to use the LSL (least square line) of rrdtool ( http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html )
Only for rrdtool version 1.2.x

I have created 4 new 'Special Data Source' for CDEF function :
  • CURRENT_DS_LSLSLOPE : return the LSLSCOPE variable of rrdtool
    CURRENT_DS_LSLINT : return the LSLINT variable of rrdtool
    CURRENT_DS_LSLCORREL : return the LSLCORREL variable of rrdtool (not tested)
    CURRENT_DS_LSLFUNCTION : return the y=ax+b function (y=LSLSCOPE * x + LSLINT)
To use the LSL function, VDEF definitions must be created in the rrdgraph command. This is what my path is doing.


CURRENT_DS_LSLFUNCTION can be used alone in a CDEF function, this will trace the line, but if the datasource is used with a CDEF function (like 'turn byte into bits'), you may create a CDEF with CURRENT_DS_LSLFUNCTION and the same operation.

exemple : if your graph is using "Turn Bytes into bits"
"Turn Bytes into bits" cdef=CURRENT_DATA_SOURCE,8,*
then , to trace the LSL line, create a cdef function like this:
"LSL Turn Bytes into bits" cdef=CURRENT_DS_LSLFUNCTION,8,*

note: LSL's functions cannot be used alone, in a CDEF function, a data_source must be present.
(exepted the CURRENT_DS_LSLFUNCTION that include automaticaly a datasource and POP it (remove from the stack in cdef))

to display the percent of evolution of the graphed period, create a cdef function
cdef=CURRENT_DATA_SOURCE,POP,CURRENT_DS_LSLSLOPE,COUNT,*,CURRENT_DS_LSLINT,0,LE,0.1,CURRENT_DS_LSLINT,IF,/,100,*
and use a GPRINT with "LAST" as Consolidation Function


Patch is for cacti 0.8.6j without official patch
copy the patch file in cacti directory
be in cacti directory to apply the patch
if you want to test before :
patch -p1 -N --dry-run < lsl.patch

patch:
patch -p1 -N < lsl.patch

-
Jerome

Sorry for my english

EDIT: version 1.1 : trace line even if data value is unknown (cf picture 2)
EDIT : version 1.2: simplify function
Attachments
LSL exemple version 1.1<br />line is drawn even if data is unknown
LSL exemple version 1.1
line is drawn even if data is unknown
LSL1.1.jpg (40.82 KiB) Viewed 20861 times
LSL exemple
LSL exemple
lsl.jpg (41.19 KiB) Viewed 20922 times
lsl-1.2.patch
Patch version 1.2, oct 18 2007
for cacti 0.8.6j
(4.62 KiB) Downloaded 685 times
Last edited by Mikf on Thu Oct 18, 2007 4:34 am, edited 9 times in total.
User avatar
chrisgapske
Cacti User
Posts: 278
Joined: Tue May 22, 2007 7:56 am
Location: Pensacola, Fl - Padacuh, Ky-Alpena, MI-Gulf Shores,AL

Interesting

Post by chrisgapske »

Have you tested this with 0.8.7 beta 4/SVN ?


Would be nice to have added to cacti base.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

VDEF will be coming, not in 0.8.7. But will be in an upcoming release.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
Mikf
Posts: 47
Joined: Fri Aug 13, 2004 11:35 am
Location: Paris, France

Re: Interesting

Post by Mikf »

chrisgapske wrote:Have you tested this with 0.8.7 beta 4/SVN ?
No, only with 0.8.6j
rony wrote: VDEF will be coming, not in 0.8.7. But will be in an upcoming release.
:D
samcpeak
Posts: 10
Joined: Wed May 25, 2011 9:06 am
Location: Alabama, USA

Re: Least Square Line

Post by samcpeak »

I’ve been looking for a way to make a trend line that changes based on the time frame that is shown. Someone from my company had previously used your patch to accomplish this, but they have left the company. I’m trying to install this patch on my server, but I am having some trouble.

I copied uploaded the patch into my cacti directory (/var/www/html) and then did

[root@localhost emsadmin]# cd /var/www/html
[root@localhost html]# patch -p1 -N <lsl-1.2.patch
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -ruBbd cacti-0.8.6j.test/include/config_arrays.php cacti-0.8.6j-patch/include/config_arrays.php
|--- cacti-0.8.6j.test/include/config_arrays.php 2007-10-17 20:49:36.000000000 +0200
|+++ cacti-0.8.6j-patch/include/config_arrays.php 2007-10-17 20:51:32.000000000 +0200
--------------------------
File to patch:

And then it waited for a response at ‘File to patch:’ I’m not sure what to put there.

Maybe I am doing it wrong. Could you explain to me how to correctly patch your file?

Btw I'm using v0.8.7g.

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

Re: Least Square Line

Post by noname »

That patch is for quite older version (0.8.6j) of Cacti. There isn't "include/config_arrays.php" now.

I tried to create new one (but nothing changed).
This patch is for Cacti 0.8.7g with official patch.
lsl-1.2_087g.patch
for 0.8.7g with official patch
(4.35 KiB) Downloaded 428 times
(You'll see "Hunk ..." if you have installed PA. But probably it will succeed to apply.)

And I followed as Mikf mentioned, make a graph template.
Here is a example.
(sample)cacti_graph_template_interface_traffic_with_lsl.zip
sample graph template: "Interface - Traffic (bits/sec) with LSL"
(3.36 KiB) Downloaded 352 times
Import results:
Image
Graph:
Image

They say Least Squares is elementary method in Classical Econometrics,
but anyway it is interesting when drawing graph... :wink:
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Least Square Line

Post by noname »

P.S.
This modification uses LSLSLOPE, LSLINT, and LSLCORREL on VDEF= statement as Mikf mentioned at the above.
I'm guessing, these RRDtool options (and others?) will be able to use in 088 release...
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Least Square Line

Post by gandalf »

noname wrote:P.S.
This modification uses LSLSLOPE, LSLINT, and LSLCORREL on VDEF= statement as Mikf mentioned at the above.
I'm guessing, these RRDtool options (and others?) will be able to use in 088 release...
Correct
R.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Least Square Line

Post by gandalf »

Function has been postponed to 089
R.
kdmillerii
Posts: 12
Joined: Thu Nov 12, 2009 9:40 am
Location: University Park, PA

Re: Least Square Line

Post by kdmillerii »

I upgraded from 087g to 088a and this patch no longer works. Is someone working on a 088a patch?

What is the timeframe of 089? I saw on the roadmap that 1.0.0 is planned for a few months. Is that still correct?

What I'm trying to do is take a daily 95th percentile and LSL that over time.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Least Square Line

Post by gandalf »

VDEF is already part of 089. This is currently in alpha state, which means, that bug hunting is in progress now.
Here's the deal:
In case you help testing this feature with 089, I will do the coding for this feature, if sth is still missing.
In case you agree, please download 089 code from SVN to a test machine. Open a new thread for your issues in the announcement forum
R.
artms
Posts: 1
Joined: Tue Oct 15, 2013 1:14 am

Re: Least Square Line

Post by artms »

Here is the patch for cacti 0.8.8a. Everything else is the same as Mikf wrote...
Attachments
lsl-0.8.8.patch
cacti 0.8.8a patch for Least Square method
(4.31 KiB) Downloaded 171 times
artiflo
Cacti User
Posts: 76
Joined: Wed Dec 19, 2007 2:00 pm

Re: Least Square Line

Post by artiflo »

Thanks for the patch.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests