bash script, rrd ok, graph some data ok, some nan

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

Hello!

I have made a query script that pulls data from a mikrotik, I check the script and it works well, it takes 7 seconds to extract data, I created the graphs, and the problem is that it does not get all the data, some well, others in -nan-
I have checked the .rrd and if it has data, in the cacti log, it appears that if it collects data, but the graph does not leave all the data.
The script performs a query, if I only choose the graph of 1 single data, it goes well, but when I create the graphs of all the data, the problem appears.
i'm very lost, because i don't know what more to check....

If you need more information or a better explanation, tell me.

Thank you.
(sorry again for my google translator english)
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by netniV »

Without having the template, script and the output that comes from the microtek device (when you manually run the script for all the data), it'd be tricky to work out what is happening. Just make sure that you have defined all your input and output fields for your input method/query and that the graph is definitely using those fields.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

Hi Again!

Here is the output of the script, manually executed, XX.XX.XX.XX/XX is the IP that i used as index, this script is executed in 7 seconds maximun:

************** SCRIPT RESULT **************
sudo bash mk_ips_free.sh "DEVICE_IP" get used XX.XX.XX.XX/XX
26
sudo bash mk_ips_free.sh "DEVICE_IP" get total XX.XX.XX.XX/XX
30
sudo bash mk_ips_free.sh "DEVICE_IP" get free XX.XX.XX.XX/XX
4
***************************************************


**************** CACTI.LOG ******************************************
03/08/2018 08:51:12 AM - CMDPHP: Poller[0] Host[6058] DS[97843] CMD: bash /usr/share/cacti/site/scripts/mk_ips_free.sh "DEVICE_IP" get total XX.XX.XX.XX/XX, output: 30
03/08/2018 08:51:18 AM - CMDPHP: Poller[0] Host[6058] DS[97843] CMD: bash /usr/share/cacti/site/scripts/mk_ips_free.sh "DEVICE_IP" get used XX.XX.XX.XX/XX, output: 26
03/08/2018 08:51:24 AM - CMDPHP: Poller[0] Host[6058] DS[97843] CMD: bash /usr/share/cacti/site/scripts/mk_ips_free.sh "DEVICE_IP" get free XX.XX.XX.XX/XX, output: 4
**************************************************************************

************ XML *********************
<interface>
<name>Get public Ips usage</name>
<description>Queries mikrotik for public ip usage</description>
<script_path>bash |path_cacti|/scripts/mk_ips_free.sh</script_path>
<arg_prepend>|host_hostname|</arg_prepend>
<arg_index>index</arg_index>
<arg_query>query</arg_query>
<arg_get>get</arg_get>
<arg_num_indexes>num_indexes</arg_num_indexes>
<output_delimeter>:</output_delimeter>
<index_order>publicIp</index_order>
<index_order_type>alphabetic</index_order_type>
<index_title_format>|chosen_order_field|</index_title_format>

<fields>
<publicIp>
<name>Public ip</name>
<direction>input</direction>
<query_name>index</query_name>
</publicIp>
<totalIps>
<name>Total Ips</name>
<direction>output</direction>
<query_name>total</query_name>
</totalIps>

<usedIps>
<name>Used Ips</name>
<direction>output</direction>
<query_name>used</query_name>
</usedIps>
<freeIps>
<name>Free Ips</name>
<direction>output</direction>
<query_name>free</query_name>
</freeIps>
</fields>
</interface>
***********************************************

Don't know if it helps, i get the value avalaible ok, but used and free with -nan-

If you need more data, please tell me.

Thanks in advance!!!!
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by netniV »

You've said that your output is delimited. That means it expects the output to be more like:

Code: Select all

publicIp:xx usedIps:xx freeIps:xx
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

maybe I have explained wrong

My output depends of the router in which i perform the query:

Router 1: 3 public ip range
Router 2: 2 public ip range
Router 3: 2 public ip range
Router 4: 1 public ip range

I have other script, "Data input method" that only generate 1 output and i specify variables that way (Var:output), but this script is a "data query"

Do I need to specify the output that way too?

The strange thing is that in one router, 1 Ip is graphing ok!, but the other 2 Ips, they do not have all the values..
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by netniV »

Because you've said it's delimited, yes.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

OK!! i'll try!!

Thanksss for the reply!!!
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

Sorry Again!! i tried with the output:

usedIps:value

but doesn't work...graphs shows -nan-
whe i modified the script to show only the value, this way:

Poller[0] Host[6058] DS[98264] CMD: bash /usr/share/cacti/site/scripts/mk_ips_free.sh XX.XX.XX.XX/XX get total XX.XX.XX.XX/XX, output:30
..
..
..
The log shows all the values but the graphs only shows some of them..

i attached some images, hope it helps, ..

thankh you again!
Attachments
Sin nombre2.png
Sin nombre2.png (17.8 KiB) Viewed 1810 times
Sin nombre.png
Sin nombre.png (15.93 KiB) Viewed 1810 times
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

I found the problem, at last!

I follow this guide "[HOWTO] Debug NaN's in your graphs" made by gandalf, and in paragraph "6. Check rrd file numbers" i found that i had my upper limit to 100, and that was the problem, i change to 255, and problem solved!!!

Finally it was a simple mistake.. hope it helps to someone

Thanks
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by netniV »

Ah, so when you had a value over 100, you stopped seeing them? I wonder if that can be flagged as a warning somewhere.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
dnixneodevine
Posts: 13
Joined: Wed Sep 13, 2017 3:58 am

Re: bash script, rrd ok, graph some data ok, some nan

Post by dnixneodevine »

Yes! when my script returns some value over 100, the graph shows -nan-.
I think it is a good idea, some warning about it. :D
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests