Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Fri Apr 27, 2018 4:01 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: export_link_value_to_texte_file
PostPosted: Thu Apr 12, 2018 9:27 am 
Offline

Joined: Sun Jun 26, 2016 4:12 am
Posts: 10
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


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Thu Apr 12, 2018 11:27 am 
Offline

Joined: Sun Jun 26, 2016 4:12 am
Posts: 10
can i modify the source code of weathermap classes and get the value of link bandwidth. In this case which file i should modify.


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Thu Apr 12, 2018 11:54 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 5213
Location: United Kingdom
The DATAOUTPUTFILE command will do that for you:

Code:
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 0.2. Superlinks is over there now.
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!)


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Fri Apr 13, 2018 4:57 am 
Offline

Joined: Sun Jun 26, 2016 4:12 am
Posts: 10
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:

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


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Fri Apr 13, 2018 10:07 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 5213
Location: United Kingdom
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 0.2. Superlinks is over there now.
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!)


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Fri Apr 13, 2018 10:09 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 5213
Location: United Kingdom
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 0.2. Superlinks is over there now.
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!)


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Fri Apr 13, 2018 4:22 pm 
Offline

Joined: Sun Jun 26, 2016 4:12 am
Posts: 10
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:
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 :(


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Fri Apr 13, 2018 5:18 pm 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 5213
Location: United Kingdom
It has already changed again in 1.0.0.

But the output from DATAOUTPUTFILE will remain the same.

_________________
Weathermap 0.98 is out! & QuickTree 0.2. Superlinks is over there now.
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!)


Top
 Profile  
 
 Post subject: Re: export_link_value_to_texte_file
PostPosted: Sat Apr 14, 2018 12:34 am 
Offline

Joined: Sun Jun 26, 2016 4:12 am
Posts: 10
yes but the output from this file is like that:

Code:
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group