export_link_value_to_texte_file

Support questions about the Network Weather Map plugin

Moderators: Moderators, Developers

Post Reply
Author
Message
klaud
Posts: 10
Joined: Sun Jun 26, 2016 4:12 am

export_link_value_to_texte_file

#1 Post by klaud » Thu Apr 12, 2018 9:27 am

Hello

i use cacti version 0.8.8b and weathermap version 0.98, to supervise traffic between routers. i like to use the value of a link between node and export this value to texte file. how can i do that.
thank you for help

klaud
Posts: 10
Joined: Sun Jun 26, 2016 4:12 am

Re: export_link_value_to_texte_file

#2 Post by klaud » Thu Apr 12, 2018 11:27 am

can i modify the source code of weathermap classes and get the value of link bandwidth. In this case which file i should modify.

User avatar
Howie
Cacti Guru User
Posts: 5333
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: export_link_value_to_texte_file

#3 Post by Howie » Thu Apr 12, 2018 11:54 am

The DATAOUTPUTFILE command will do that for you:

Code: Select all

DATAOUTPUTFILE filename
You get a file with the data for all nodes and links, in a format that can be read by the wmdata: datasource plugin.
Weathermap 0.98 is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

klaud
Posts: 10
Joined: Sun Jun 26, 2016 4:12 am

Re: export_link_value_to_texte_file

#4 Post by klaud » Fri Apr 13, 2018 4:57 am

thank you for your reply. :D

the value of the bandwidth display in the output file is on bits or bytes?

i need to export the bandwidth of a node to text file because i have an application that check this file and when i have a pic of traffic i get the wethermap image.png displayed in the output directory.

just i modified the source code of the weathermap.class.php and i added this section

Code: Select all


var $my_bb_tt_res = array();



$html .= '<div id="bbttel" style="display:none;">';
$bbtt_max = 0;
foreach($this->links as $link){
	foreach($link->my_bb_tt_res as $key => $value){
		if(substr($value, -1) == 'G'){
		if(floatval($value) > $bbtt_max){
			$bbtt_max = floatval($value);
		}
		}
		//$html .= $value . '|';
	}
}
$html .= $bbtt_max;
file_put_contents('output/bbtt_data.txt',$bbtt_max);
$html .= '</div>


in this version of weathermap i can't find the same files and not the same code. can you please help me to adapt this code to weathermap version 0.98

User avatar
Howie
Cacti Guru User
Posts: 5333
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: export_link_value_to_texte_file

#5 Post by Howie » Fri Apr 13, 2018 10:07 am

I don't understand. It already does what you want doesn't it? If you just need one value, grep will get it for you.
Weathermap 0.98 is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

User avatar
Howie
Cacti Guru User
Posts: 5333
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: export_link_value_to_texte_file

#6 Post by Howie » Fri Apr 13, 2018 10:09 am

It looks to me like Cacti's threshold plugin would be better for what you want, also. If it's an alert when a value goes above a threshold.
Weathermap 0.98 is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

klaud
Posts: 10
Joined: Sun Jun 26, 2016 4:12 am

Re: export_link_value_to_texte_file

#7 Post by klaud » Fri Apr 13, 2018 4:22 pm

thank you for your reply, i use cacti for administration purpose of a router which have multiple links the total of bandwidth is displayed on a link between two nodes. the goal is when i have a pic of traffic i can get the map.png file from the output directory of weathermap. so i developped an application to get this map and i check the max-bandwidth from text file named in my case bbtt_data.txt. i modified the weathermap.class.php to get from cacti the max-bandwidth and store this value into text file. the application work fine but recently i installed this version of weathermap 0.98 and i can't find the same files and code.

this is the older code from the weathermap.class.php 0.92 version

Code: Select all

var $my_bb_tt_res = array();

if (!is_null($q1_x))
		{
			$outbound=array
				(
					$q1_x,
					$q1_y,
					0,
					0,
					$this->outpercent,
					$this->bandwidth_out,
					$q1_angle
				);

			$inbound=array
				(
					$q3_x,
					$q3_y,
					0,
					0,
					$this->inpercent,
					$this->bandwidth_in,
					$q3_angle
				);


foreach (array($inbound, $outbound)as $task)
			{
				$thelabel="";

				if ($this->labelstyle != 'none')
				{
					debug("Bandwidth is ".$task[5]."\n");
					
					if ($this->labelstyle == 'bits') { $thelabel=nice_bandwidth($task[5], $this->owner->kilo); $this->my_bb_tt_res[] = nice_bandwidth($task[5], $this->owner->kilo); }
					elseif ($this->labelstyle == 'unformatted') { $thelabel=$task[5]; $this->my_bb_tt_res[] = $task[5];}
					elseif ($this->labelstyle == 'percent') { $thelabel=format_number($task[4]) . "%"; $this->my_bb_tt_res[] = format_number($task[4]) . "%"; }

					$padding = intval($this->get_hint('bwlabel_padding'));		

					if($this->labelboxstyle == 'angled')
					{
						$map->DrawLabelRotated($im, $task[0],            $task[1],$task[6],           $thelabel, $this->bwfont, $padding,
							$this->name,  $this->bwfontcolour, $this->bwboxcolour, $this->bwoutlinecolour,$map);
					}
					else
					{
						$map->DrawLabel($im, $task[0],            $task[1],           $thelabel, $this->bwfont, $padding,
							$this->name,  $this->bwfontcolour, $this->bwboxcolour, $this->bwoutlinecolour,$map);
					}
					
				}
			}
		}
	}


// this code is inserted in the function MakeHTML

$html .= '<div id="bbttel" style="display:none;">';
$bbtt_max = 0;
foreach($this->links as $link){
	foreach($link->my_bb_tt_res as $key => $value){
		if(substr($value, -1) == 'G'){
		if(floatval($value) > $bbtt_max){
			$bbtt_max = floatval($value);
		}
		}
		//$html .= $value . '|';
	}
}
$html .= $bbtt_max;
file_put_contents('output/bbtt_data.txt',$bbtt_max);
$html .= '</div>';


how can i adapt this code to weathermap 0.98 :(

User avatar
Howie
Cacti Guru User
Posts: 5333
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: export_link_value_to_texte_file

#8 Post by Howie » Fri Apr 13, 2018 5:18 pm

It has already changed again in 1.0.0.

But the output from DATAOUTPUTFILE will remain the same.
Weathermap 0.98 is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

klaud
Posts: 10
Joined: Sun Jun 26, 2016 4:12 am

Re: export_link_value_to_texte_file

#9 Post by klaud » Sat Apr 14, 2018 12:34 am

yes but the output from this file is like that:

Code: Select all

L_T4000-Level3-Ouerdia  6679088203.600000   1523.208000
L_T4000-Level3-Ouerdiaa 8230141220.800000   1526.263200
L_T4000-nodeATI_Wardiaa 444039671.536000    4091589798.080000
L_T4000-node_TIS    6663189651.680000   2080241494.000000
L_T4000-node_TISa   6636796103.440000   2044580242.080000
L_International_node-globe  115911592756.879990 22433604426.723553
L_CRS_X-node06788   4801933455.200000   1329.232178
L_CRS_X-node06852   7100165206.800000   1630.996089
L_CRS_X-node06852a  7841650889.760000   1176446198.640000
i will make a script shell to get the value from this file every poller period. the value displayed of the bandwidth is on float ? :roll:

Post Reply