Calculating for MAX

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
mihael
Posts: 6
Joined: Wed Dec 10, 2014 7:47 am

Calculating for MAX

Post by mihael »

I'm trying to manually calculate for the MAX value of my interface via python script, but I can't get the same result as the one shown in my cacti graph.

Script:

Code: Select all

data = rrdtool.fetch(rrd_file, 'AVERAGE', '-r', '300', '-s',  '1588069832', '-e', '1588674632')
    for row in data[2]:
        if row[1] is not None:
            max_out.append(float(row[1]))
 max_out.sort()
 max_value = max_out[-1]
 max_bps = max_value * 8
 max_mbps = round((max_bps / 1000 / 1000), 2)
print(f'{max_mbps}M)
#Result: 591.27M
Cacti Graph:
Image

Image


I even tried manually running the rrdtool graph command, but it's also giving me a different result:

Code: Select all

➜  rrd_files rrdtool graph -s 1588069832 -e 1588674632 \
DEF:a='1min_traffic_in_14983.rrd':'1min_traffic_in':AVERAGE \
DEF:b='1min_traffic_in_14983.rrd':'1min_traffic_out':AVERAGE \
CDEF:cdefe='b,8,*' \
PRINT:cdefe:MAX:'Maximum\:%8.2lf %s'
0x0
Maximum:  538.64 M
Is there any cacti calculation or anything that I'm missing causing the graph to display a different result?
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: Calculating for MAX

Post by cigamit »

trying changing
max_mbps = round((max_bps / 1000 / 1000), 2)
to
max_mbps = round((max_bps / 1024 / 1024), 2)
and see if it gets you a bit closer.
mihael
Posts: 6
Joined: Wed Dec 10, 2014 7:47 am

Re: Calculating for MAX

Post by mihael »

cigamit wrote: Tue May 05, 2020 7:48 pm trying changing
max_mbps = round((max_bps / 1000 / 1000), 2)
to
max_mbps = round((max_bps / 1024 / 1024), 2)
and see if it gets you a bit closer.
Yeah it does, now it's giving me 563.88M.
I've also tried calculating the 95th Percentile, which I was able to accurately do and I was using 1000 to convert bits to mbps/gbps
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Calculating for MAX

Post by TheWitness »

Look at the base value of the graph template.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mihael
Posts: 6
Joined: Wed Dec 10, 2014 7:47 am

Re: Calculating for MAX

Post by mihael »

TheWitness wrote: Tue May 05, 2020 9:11 pm Look at the base value of the graph template.
But shouldn't the cli command `rrdtool graph` have the same result for that as it is the same command shown by cacti?
Also, I checked the "Base Value" for the graph, it's '1000'.
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Calculating for MAX

Post by TheWitness »

I thing the problem is Python, lol. Just kidding. This is a good question for Tobi. It may simply be that RRDtool chose to pull the data from another less/granular archive that was different to what the fetch function choose. The Python math looks good to me.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Calculating for MAX

Post by TheWitness »

Looking again, you need to ensure you are consistent with resolution. In your Python call, you are calling out the 5 minute rra, Cacti let's Tobi pick.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
mihael
Posts: 6
Joined: Wed Dec 10, 2014 7:47 am

Re: Calculating for MAX

Post by mihael »

TheWitness wrote: Wed May 06, 2020 7:03 am Looking again, you need to ensure you are consistent with resolution. In your Python call, you are calling out the 5 minute rra, Cacti let's Tobi pick.
I tried calling out the one minute rra, and it is giving way more max value.
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Calculating for MAX

Post by TheWitness »

Well, once you figure it out, report back here, some people are lurking.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests