Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Quick and dirty script to add devices to cacti
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
ymartin59



Joined: 17 Feb 2006
Posts: 40

PostPosted: Mon Feb 20, 2006 3:39 am    Post subject: Must have scripts ! Reply with quote

That script set is wonderful and powerful. And I do not find them so "quick and dirty".
I really think that scripts must be included in cacti !
Back to top
ymartin59



Joined: 17 Feb 2006
Posts: 40

PostPosted: Mon Feb 20, 2006 4:45 am    Post subject: Issue with multiple data sources graph creation Reply with quote

Hello,

I'm trying to create "ucd/net Available Disk Space" with the command:
add_graphs.php --graph-type cg --graph-template-id 3 --host-id 8
--snmp-query-id 2 --snmp-query-type-id 6 --snmp-field dskPath --snmp-value "/"
--graph-title "grenade - Disk Space - /"

Where:
Known Graph Templates:(id, name)
3 ucd/net - Available Disk Space
Known SNMP Queries:(id, name)
2 ucd/net - Get Monitored Partitions
Known SNMP Query Types:(id, name)
6 Available/Used Disk Space

Two datasources are created for the graph but their custom data fields (index type, index value and output type ID) are not set automatically - in addition, the datasource name is "|host_description| - Hard Drive Space" instead of "|host_description| - Partion - |query_dskDevice|"


Last edited by ymartin59 on Mon Feb 20, 2006 6:17 am; edited 1 time in total
Back to top
ymartin59



Joined: 17 Feb 2006
Posts: 40

PostPosted: Mon Feb 20, 2006 6:15 am    Post subject: Re: Issue with multiple data sources graph creation Reply with quote

ymartin59 wrote:
I'm trying to create "ucd/net Available Disk Space" with the command:
add_graphs.php --graph-type cg --graph-template-id 3 --host-id 8
--snmp-query-id 2 --snmp-query-type-id 6 --snmp-field dskPath --snmp-value "/"
--graph-title "grenade - Disk Space - /"


Sorry, I made a big mistake... graph-type must be 'ds' !! It works perfectly.
Back to top
tclark



Joined: 11 Jul 2005
Posts: 26

PostPosted: Sun Feb 26, 2006 3:23 am    Post subject: Any plans to update add_device script to support snmpv3? Reply with quote

The current version of cacti only supports AuthNoPriv. In the environment I support, we enforced an AuthPriv snmpv3 policy on our servers. To enable cacti to work properly, an update to $auth_snmp in ./lib/snmp.php was done. The updated syntax for $auth_snmp now looks like this.

$snmp_auth = "-u $username -l authPriv -a MD5 -A $password -x DES -X $password"; /* v3 - username/password */

It would be great to be able to use some of these scripts to save work : )
Back to top
imbezol



Joined: 12 Apr 2006
Posts: 1

PostPosted: Wed Apr 12, 2006 7:16 pm    Post subject: Reply with quote

This patch adds the ability for add_graphs.php to tell if a graph exists already even if the type is cg.

Code:
--- add_graphs.php      Tue Dec 13 05:53:46 2005
+++ add_graphs.php.new  Wed Apr 12 18:06:02 2006
@@ -245,6 +245,23 @@
     if ($graph_type == "cg")
     {
         $empty = array(); /* Suggested Values are not been implemented */
+
+        $existsAlready = db_fetch_cell("select id from graph_local where graph_template_id = $templateId AND host_id = $hostId");
+        if (isset($existsAlready) && $existsAlready > 0)
+        {
+            if ($graphTitle != "")
+            {
+                db_execute("update graph_templates_graph set title = \"$graphTitle\" where local_graph_id = $existsAlready");
+                update_graph_title_cache($existsAlready);
+            }
+            $dataSourceId = db_fetch_cell("SELECT DISTINCT data_template_rrd.local_data_id
+                                             FROM graph_templates_item, data_template_rrd
+                                           WHERE graph_templates_item.local_graph_id = " . $existsAlready .
+                                           " AND graph_templates_item.task_item_id = data_template_rrd.id");
+            echo "Not Adding Graph - this graph already exists - graph-id: ($existsAlready) - data-source-id: ($dataSourceId)\n";
+            return(1);
+        }
+
         $returnArray = create_complete_graph_from_template($templateId, $hostId, "", $empty);
     }


Save this to add_graphs.php.patch and run
Code:
patch -p0 < add_graphs.php.patch
Back to top
deltaforce



Joined: 14 Apr 2006
Posts: 1
Location: Grenoble - FRANCE

PostPosted: Wed Apr 19, 2006 10:26 am    Post subject: Reply with quote

About add_tree.php, some functions weren't implemented like --list-trees ; --list-nodes...
Does somebody know if these scripts are finished today ? (I'm triing to complete them, but it doesn't work).
Thank you.
Back to top
cdukes
Cacti User


Joined: 26 Mar 2002
Posts: 54
Location: Tampa, FL

PostPosted: Thu Apr 20, 2006 10:25 am    Post subject: Awesome! Reply with quote

Thank you so much for writing this.
I just imported 1k devices perfectly!
On to adding graphs now
Back to top
manaf
Cacti User


Joined: 16 Apr 2006
Posts: 50

PostPosted: Sun Apr 23, 2006 1:54 am    Post subject: Reply with quote

How can i use it in windows??
Back to top
shadowk



Joined: 24 Apr 2006
Posts: 3

PostPosted: Mon Apr 24, 2006 8:23 am    Post subject: patch Reply with quote

Here is a patch to prevent adding hosts to the graph tree if they are in the specified tree already.

Code:

--- add_tree.php        Fri Apr 21 16:44:38 2006
+++ add_tree.php.new    Fri Apr 21 17:29:35 2006
@@ -208,6 +208,12 @@
             $rra_id         = 0;
             $name           = '';

+            $hostNodeExists = db_fetch_cell("SELECT id FROM graph_tree_items WHERE graph_tree_id = $treeId AND host_id = $hostId");
+            if (isset($hostNodeExists))
+            {
+               echo "Not adding host, host-id ($hostId) is already in graph tree ($treeId)\n";
+               return 1;
+            }
             if (!isset($hosts[$hostId]))
             {
                 printf("No such host-id (%s) exists. Try --list-hosts\n", $hostId);


Save this to add_tree.php.patch and run:

Code:

patch -p0 < add_tree.php.patch


Andrew
Back to top
stutz



Joined: 21 Apr 2006
Posts: 4
Location: London. UK

PostPosted: Thu May 04, 2006 4:03 am    Post subject: A wrapper for Bradley's scripts Reply with quote

Firstly thanks to Bradley et al for the php import scripts. I have written my first ever script (so don't be to harsh - comments for improvements appreciated!) to successfully transfer 1500 devices from CastleRock SNMPc to Cacti. This can be modified to read in pretty much any CSV file and populate Cacti with the Tree, Devices and Graphs all asociated with the relevant Nodes.

One question I have is when creating a CG graph, is there any way to populate the custom fields?

For example for a graph 'Host Availability' in the 'Data Sources' menu in the 'Supplemental Data Template Data' section is a 'Custom Data' field for 'IP Address'. At the moment I have to manually add the address for each device.



import.zip
 Description:
Feel free to use/modify this wrapper script for your own use. Do share any improvements though!

Download
 Filename:  import.zip
 Filesize:  945 Bytes
 Downloaded:  731 Time(s)

Back to top
schlabschi



Joined: 08 May 2006
Posts: 2

PostPosted: Mon May 08, 2006 10:50 am    Post subject: Reply with quote

Awesom scripts! Really saved me a lot of work.
But I have the same problem as "stutz" above: Can someone who is smarter in scripting than me provide a way to populate the custom fields like ip address?
I also have to put it in by hand for over 1500 entries

Thanks a lot,
Schlabschi
Back to top
sini
Cacti User


Joined: 24 Nov 2003
Posts: 55
Location: Hungary

PostPosted: Tue May 16, 2006 7:01 am    Post subject: Reply with quote

Hi,

Nice work! Just one question.
How can I add a grap with space in its ifDescr like "ATM2/0.1007-aal5 layer"?

thx
Back to top
kanada
Cacti User


Joined: 28 Aug 2005
Posts: 125

PostPosted: Fri Jun 09, 2006 4:28 am    Post subject: Reply with quote

I have in logs some errors when i try add to sql var with speed interface.

CMDPHP: Poller[0] ERROR: SQL Exec Failed "update data_template_data set rrd_maximum='|query_ifSpeed|' where local_data_id=8787"

any ideas?

Thanks.
Back to top
jbajc



Joined: 21 Apr 2006
Posts: 6

PostPosted: Thu Jun 22, 2006 6:35 am    Post subject: Reply with quote

Hello,

I have a problem with script add_graphs.php. The script seems to be working properly if I use cmd.php as a poller. If I use cactid it doesn't create any new rrds.

Have any ideas?

Tnx for reply

Janko
Back to top
gninja
Cacti User


Joined: 24 Aug 2004
Posts: 293
Location: San Francisco, CA

PostPosted: Mon Jun 26, 2006 8:24 pm    Post subject: Reply with quote

I'm having a problem with this.. It doesn't seem to execute the queries properly when setting up. If I add a host with snmp disk graphs, when I go into the device, instead of the mount points, I see the mount numbers... Any way to fix that?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 2 of 8

 



Powered by phpBB © 2001, 2005 phpBB Group