Quick and dirty script to add devices to cacti

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

Moderators: Developers, Moderators

Post Reply
melanie_pfefer
Posts: 5
Joined: Wed Feb 27, 2008 4:55 pm

Post by melanie_pfefer »

Hello

So I understand from you that 0.8.7 has the scripts that can add 150 hosts + their graphs in one shot. True?

actually I am trying to find an automatic way to add 150 hosts + their graphs. I need to know how to do it in cacti without manually adding these hosts and graphs in the web interface.

thanks
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

melanie_pfefer wrote:So I understand from you that 0.8.7 has the scripts that can add 150 hosts + their graphs in one shot. True?
yes
Rael
Cacti User
Posts: 129
Joined: Thu Apr 05, 2007 9:28 am

Post by Rael »

These tools have proved a god send for the long term support of our cacti instance, however I don't see a way of removing hosts from cacti in the cli? Am I missing something?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

What are you aiming add when talking about "moving". What do you want to move?
Reinhard
Rael
Cacti User
Posts: 129
Joined: Thu Apr 05, 2007 9:28 am

Post by Rael »

I'm sorry gandalf, we're you talking to me or someone else?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Rael wrote:I'm sorry gandalf, we're you talking to me or someone else?
I was talking to you, but I must have been drunk. I was reading "moving" instead of "removing".
So it's simply a matter of a feature request. Not that difficult
Reinhard
ibrahim
Posts: 27
Joined: Tue May 27, 2008 1:28 pm

Post by ibrahim »

hello Reinhard

i have a list of hosts that i have to monitor. can you please tell me how to use this script ( after i installed it in the cacti dir ) in order to insert those hosts with their graphs automatically ( by steps)

i ll really appreciate

thx in advance
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please see http://docs.cacti.net/node/529
There have been some contributions of wrapper scripts around those cacti cli stuff. Please search the forum for them
Reinhard
killshoot
Cacti User
Posts: 84
Joined: Wed Mar 26, 2008 2:51 am

Post by killshoot »

@Gandalf

I've used these scripts to insert my 2000 appliances into cacti.
I've also make a quick dirty script to automake threshold.

But I can't find a solution to automatically delete grapgh in the same way that we create it ( specifying interface if oper status = down for exemple ).

Can you help me? Which php file is used to delete graph with wich parameter?

Best regards,

Vince
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please use the cli scripts provided by cacti since 087
Reinhard
killshoot
Cacti User
Posts: 84
Joined: Wed Mar 26, 2008 2:51 am

Post by killshoot »

@Gandalf

I've used the script provided in release 0.87.

But there is no script to delete graph. In fact I don't want to create a graph for vlan interface even if operstatus=up.

So what I currently do is create all graph with operstatus=up and after deleting all graph that I don't need.

My goal is to have a script that can delete graph according to the ifdescr value.

Thank you for your help
rujipars
Posts: 39
Joined: Fri Nov 02, 2007 11:25 am

Post by rujipars »

As I can see, the speed of unrouted vlan is 0. Can we add filtering by ifSpeed when create graph? At least we can reduce unwanted process to create unrouted vlans that appear as interfaces.

Looking carefully into the ifType code may also help to gain more precise filtering.

I don't have 0.8.7 at hand but like to offer an idea that may help. (I'm using cisco)
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Automatic filtering is not (yet) provided by cacti. But when scanning the interface list manually, you'll notice those with correct ifSpeed. Then, please select only those
Reinhard
TheBigOne
Posts: 45
Joined: Mon Sep 29, 2008 8:57 am
Location: Basel

Post by TheBigOne »

Hi, my problem was to add new graphs associated to a host template after adding the device with add_device.php.

I added some dirty lines to the add_graph.php to get all graph template ids associated to a special host template. After getting theese ids its easy to add theese graphs.
I use it in combination with a shell script so all i need is the output of the ids.
Of course there is a workaround getting all ids but this was for me the easiest way.
Hope this is useful for someone.

this must be added into the switch

Code: Select all

 
break;
case "--list-graph-template-id":
$listGraphTemplateID = TRUE;   
this can be added somewhere in the file (its really dirty :) )

Code: Select all

 
if ($listGraphTemplateID) {
                if ($hostTemplateId > 0) {
                        function displayGraphTemplateIDs($hostTemplateId) {
                                $ids = array();
                                $tmparray  = db_fetch_assoc("SELECT graph_template_id FROM host_template_graph WHERE host_template_id = $hostTemplateId");
                                foreach ($tmparray as $tmp) {
                                $tmp["graph_template_id"];
                                $ids[] = $tmp["graph_template_id"];
                                echo $tmp["graph_template_id"]."\n";
                                }

                                return $ids;
                        }

                        displayGraphTemplateIDs($hostTemplateId);
                } else {
                        echo "ERROR: You must supply an host-template-id before you can list its graph templates\n";
                        echo "Try --host-template-id=[ID] --list-graph-template-id\n";
                        exit(1);
                }

                exit(0);
        }

this can be added to the display_help() function

Code: Select all

echo "    --list-graph-template-id --host-template-id=[ID]\n";

if you execute now

Code: Select all

./add_graphs.php --host-template-id=14 --list-graph-template-id
the output looks like:
13
30
31
42

thats a snipped of my shell code

Code: Select all

  ids=`php -q ../cli/add_graphs.php  --list-graph-template-id --host-template-id=$solarisID`
  for a in $ids
  do
     php -q ../cli/add_graphs.php --host-id=$hostID --graph-type=cg --graph-template-id=$a
  done
EDIT// feature request created
Last edited by TheBigOne on Wed Oct 15, 2008 2:49 am, edited 1 time in total.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please create a feature request using http://ww.cacti.net/bugs.php adding your code there
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests