Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue Jul 16, 2019 1:17 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 140 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next
Author Message
 Post subject:
PostPosted: Tue Nov 28, 2006 1:02 pm 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22376
Location: Muenster, Germany
Wow, cool. I'm not a MRTG user, but sth like this was asked often. I'll surely link to this post from time to time :lol:
Reinhard

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject: add_tree.php
PostPosted: Wed Nov 29, 2006 3:25 pm 
Offline

Joined: Wed Nov 29, 2006 3:12 pm
Posts: 1
Location: Ohio
I have added close to 300 devices and 1500 graphs, but I am having problems with the add_tree.php.

What I would like to do is make new Tree Item underneath an already made Graph Tree under the root tree, and then add the specific location graphs to that tree. Can anyone help me with the command?

Example:

Remote Sites -> Location 304 -> Location 304 Graphs

Also, is there a later version of the add_tree with the new features listed below:

Other Options: --list-hosts
--list-trees *
--tree-id [ID] --list-nodes *
--list-rras *
--host-id [ID] --list-graphs *

Thanks,
Jamie


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 4:45 am 
Offline
Cacti User

Joined: Mon Nov 24, 2003 10:22 am
Posts: 91
Location: Hungary
Hi,


I upgraded cacti from 0.8.6.g > 0.8.6i and the add_graph.php script does not work anymore...
Every time I execute the script its gives me the help output, although I use the same parameters like I used with 0.8.6g.
Does anyone use this script with success on 0.8.6i ??

_________________
Sini


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 2:41 pm 
Offline

Joined: Tue Feb 13, 2007 5:14 pm
Posts: 6
Location: Columbus, OH
It's been a little quiet around here but thought I'd ask anyway.

These scripts run wonderfully for my on 0.8.6i but on 0.8.6j they seem to run REALLY slow, and somewhat unreliably. I have a PERL script wrapper thing that I use to call the add_device.php script. It can take upwards of 5 or 6 minutes to add some hosts. Others seem to fail altogether. This took seconds on the previous versions.

When I run the command directly on the console, I get the same symptoms so I'm fairly confident it has nothing to do with my usage via my wrapper. I also don't suspect it's the host I'm running it on as it's a fairly powerful HP ProLiant with a ton of RAM and really not much else to be working on.

Before I get started digging in, figured I check if anyone had similar issues, tips, or fixes they'd like to share.

-melvin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 2:27 pm 
Offline

Joined: Tue Feb 13, 2007 5:14 pm
Posts: 6
Location: Columbus, OH
Solved my previously posted issue somewhat - I found I was missing a PHP memory error. Upped that a bit in /etc/php5/cli/php.cfg and seems to be completing now, though slower than I would like.

score one for the good guys

-melvin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 11, 2007 2:08 am 
Offline

Joined: Mon Mar 19, 2007 12:43 am
Posts: 10
We needed a mechanism for automaticly (using scripts) adding alot of data sources and graphs to cacti. So I've implemented an additional data input method (data_input.php). The changes also add data validation in database functions. The mechanism works like a black-box but requires PHP4. It works with any GUI (is not tied into a specific GUI). This way one can easily write a data input tool, it can be a command line, SOAP, Cacti GUI, .... One only needs to use the following functions to implement data input:
-method_add, method_edit, mehod_delete,
-input_add, input_edit, input_delete,
-output_add, output_edit, output_delete.

Methods return values or throw exceptions. Exceptions should be catched by "if ($throwExceptionArray)"

There are 4 files in cati-data_input.zip:
data_input_cmd.php // for command line calls
data_input_function.php // implemented functions from cacti
data_input_validate.php // input validations, database validations
error_Exception.php // error exception

Knowing these are quite extensive changes I would welcome your input. Hopefully I've also managed to make code a bit more readable.


Attachments:
cacti-data_input.zip [7.08 KiB]
Downloaded 602 times


Last edited by glista on Wed Apr 11, 2007 4:59 am, edited 1 time in total.
Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 11, 2007 3:19 am 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22376
Location: Muenster, Germany
Hey, interesting.
Would you please be so kind to post some application examples?
Reinhard

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 11, 2007 5:07 am 
Offline

Joined: Mon Mar 19, 2007 12:43 am
Posts: 10
Here is sample to use command line data_input_cmd.php UI:

C:\cacti>php data_input_cmd.php --type method --do add --name TestMethod --inputType scriptcommand --inputString c:/phptest/random2.pl
Method Created - method-id: (33)

#set --methodID 33
C:\cacti>php data_input_cmd.php --type output --do add --name OutputField --methodID 33 --dataName friendlyName --updateRRA
Output Created - output-id: (67)


php data_input_cmd.php --type method --do show
php data_input_cmd.php --type output --do show
The changes should be visible in cacti GUI "data input methods"


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 9:04 am 
Offline
Cacti User

Joined: Thu May 03, 2007 9:03 am
Posts: 127
peolple hie!!!

I have read all the topic and I think that the solution to my problem is there. But I am still asking myself this question : how can i run the commands like ./add_device.php? I think that thoose commands are Linux ones. So do thoose scripts work one windows. And if the answer is yes how can I run thoose script?

Thanks for all


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 2:54 pm 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22376
Location: Muenster, Germany
php -q add_device.php ...
at least I suppose so. It's quite a time that I windozed last
Reinhard

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 7:22 am 
Offline
Cacti User

Joined: Thu May 03, 2007 9:03 am
Posts: 127
hello again.

I would like to know where i have to copy paste the files for add_device. Is it in the cacti folder or in a sub-folder like for plug ins?
I am a totaly new user so i don't know anything.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 3:24 pm 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22376
Location: Muenster, Germany
I put them into main directory and it worked well for me
Reinhard

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 19, 2007 1:43 pm 
Offline
User avatar

Joined: Mon Sep 11, 2006 3:26 pm
Posts: 12
Location: Atlanta, GA
Updated the add_tree.php to include the --list-trees and --tree-id [ID] --list-nodes options. I'm not an expert with patching, so not sure if this will work on all systems so please backup your original.

apply by copying the code below to a patch file...for instance add_tree.patch. Then from the directory you have add_tree.php in execute:
patch -p0 < add_tree.patch

Test by trying it out: ./add_tree.php --list-trees

./add_tree.php --list-trees
Known Trees:(id, name)
9 Testing
12 Points of Presence
13 Firewall testing


Code:
--- add_tree.php        Sat May 19 18:36:16 2007
+++ add_tree.php.new    Sat May 19 18:37:35 2007
@@ -44,8 +44,9 @@
             (Host group styles: 1 = Graph template, 2 = Data Query Index)

     Other Options: --list-hosts
-                   --list-trees *
-                   --tree-id [ID] --list-nodes *
+                   --list-trees
+                   --tree-id [ID] --list-nodes
+                       (--tree-id must be set before --list-nodes)
                    --list-rras *
                    --host-id [ID] --list-graphs *

@@ -121,6 +122,21 @@
             case "--list-hosts":
                 displayHosts($hosts);
                 return 0;
+            case "--list-trees":
+               $trees          = getTrees();
+                displayTrees($trees);
+                return 0;
+           case "--list-nodes":
+               if (isset($treeId))
+               {
+                       $treeNodes = getTreeNodes($treeId);
+                       displayTreeNodes($treeNodes,$treeId);
+               }
+               else
+               {
+                       usage();
+               }
+                return 0;
             case "--host-group-style":
                 $i++;
                 $hostGroupStyle = $_SERVER["argv"][$i];
@@ -241,6 +257,7 @@

function getHosts()
{
+    $hosts = array();
     $tmpArray = db_fetch_assoc("select id, hostname from host order by id");
     foreach ($tmpArray as $host)
       $hosts[$host["id"]] = $host["hostname"];
@@ -256,4 +273,40 @@
     }
}

+function getTrees()
+{
+   $trees = array();
+   $tmpArray = db_fetch_assoc("select id, name from graph_tree order by id");
+   foreach ($tmpArray as $tree)
+     $trees[$tree["id"]] = $tree["name"];
+   return $trees;
+}
+
+function displayTrees($trees)
+{
+   echo "Known Trees:(id, name)\n";
+   while (list($id, $tree) = each ($trees))
+   {
+       echo "\t" . $id . "\t" . $tree . "\n";
+   }
+}
+
+function getTreeNodes($treeId)
+{
+       $nodes = array();
+       $tmpArray = db_fetch_assoc("select id, title from graph_tree_items WHERE graph_tree_id = $treeId AND title != ''");
+       foreach ($tmpArray as $node)
+               $nodes[$node["id"]] = $node["title"];
+       return $nodes;
+}
+
+function displayTreeNodes($treeNodes,$treeId)
+{
+       echo "Known Tree Nodes for Tree ID $treeId:(id, title)\n";
+       while (list($id,$title) = each ($treeNodes))
+       {
+               echo "\t" . $id . "\t" . $title . "\n";
+       }
+}
?>
+


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 5:52 am 
Offline

Joined: Mon Mar 19, 2007 12:43 am
Posts: 10
It would be very nice if this script could make it into official Cacti distribution becouse of the future compatibility. A nice approch might be to seperate the work API functions from the GUI.


Top
 Profile  
 
 Post subject: dirty way to add hosts from discover, using this script
PostPosted: Sun May 27, 2007 10:47 am 
Offline

Joined: Sun May 27, 2007 10:42 am
Posts: 1
create a php script to loop through the newly added hosts:

Code:
<?
$db = "cacti";
$h = "localhost";
$user = "whoever";
$pass = "cactipass";

$go = mysql_connect($h,$user,$pass);
$SQL = "SELECT * from plugin_discover_hosts where ip like '10.10.%'";
$result = mysql_db_query($db,$SQL,$go);

while($row = mysql_fetch_array($result)) {
$ip = $row['ip'];
$sysname = $row['sysName'];

echo "found Customer-YourDescription-$sysname with ip $ip\n";
$addhost = passthru("/usr/bin/php /path/to/add_device.php 9 \"customer-whatever-$sysname\" $ip COMMUNITY 2 0");
// add add_graph command line here, or whatever else
}
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 140 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 10  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 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