remove_device.php & remove_graph.php CLI scripts

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

aimonb
Posts: 6
Joined: Tue Jun 10, 2008 2:59 am

remove_device.php & remove_graph.php CLI scripts

Post by aimonb »

Given the advent of cloud computing and the ultimate reality that servers will disappear forever having the ability to use the CLI to remove devices and graphs has become quite useful. So I have created remove_device.php & remove_graph.php CLI files which i would like to contribute. I used as much as possible the programming style of the add_device.php and add_graph.php files.

I will add the remove_graph.php file soon.

Code: Select all

A very simple command line utility to remove a device or multiple devices from Cacti

Remove device usage: remove_device.php --device-id=[device ids] 
Required:
    --device-id    comma separated list of host/device IDs.

List devices usage: remove_device.php --list-devices

List Options:
    --list-devices    Lists all devices
Attachments
remove_device.php.zip
1.0.1 tag. This contains minor fix to help output.

uncompress and drop in the CLI folder in your cacti install
(1.17 KiB) Downloaded 1386 times
satish_kumarp2k1
Posts: 9
Joined: Tue Mar 25, 2008 7:53 am
Location: Bangalore
Contact:

Post by satish_kumarp2k1 »

Hi,

Can you also upload the script to delete graphs?

Thanks
aimonb
Posts: 6
Joined: Tue Jun 10, 2008 2:59 am

Post by aimonb »

satish_kumarp2k1 wrote:Hi,

Can you also upload the script to delete graphs?

Thanks
I have yet to write it. The other script only took me a couple of hours. This should be about as easy. I am mid sprint for a release though. I will get it up after Oct 1st.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Make sure you provide an option to either Delete Graphs and Data Sources for both scripts. The default should be "yes", even though the default in Cacti for deleting Graphs is "no".

You should also allow specifying either a substring range, or regular expression, and provide the user the ability to confirm before delete. Like do the query, show the rows and then delete if the response comes back to proceed. Provide an option to "force".

There are lot's of example on how I have written argument handling in the add* scripts.

Thanks for contributing.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
aimonb
Posts: 6
Joined: Tue Jun 10, 2008 2:59 am

Post by aimonb »

TheWitness wrote:Make sure you provide an option to either Delete Graphs and Data Sources for both scripts. The default should be "yes", even though the default in Cacti for deleting Graphs is "no".

You should also allow specifying either a substring range, or regular expression, and provide the user the ability to confirm before delete. Like do the query, show the rows and then delete if the response comes back to proceed. Provide an option to "force".

There are lot's of example on how I have written argument handling in the add* scripts.

Thanks for contributing.

TheWitness
Thanks for the info. I have very limited time to work on this, but i certainly will add these features if nobody beats me to it. I finally had a chance last night to do the remove_graph.php. I will upload it shortly.

Aimon
aimonb
Posts: 6
Joined: Tue Jun 10, 2008 2:59 am

Post by aimonb »

satish_kumarp2k1 wrote:Hi,

Can you also upload the script to delete graphs?

Thanks
Hi I finally had a chance to work on this. I will be uploading the remove_graph.php shortly.
sluke
Posts: 22
Joined: Mon Apr 21, 2008 2:49 pm

Post by sluke »

Was this remove_graph.php ever posted?

I'm running 0.8.7b and the SVN version seems to be for a later release (and I'm not up to upgrading just yet) :)

Thanks!
aimonb
Posts: 6
Joined: Tue Jun 10, 2008 2:59 am

remove_graphs.php

Post by aimonb »

this project died a bit internally, but we need it again. I will post soon.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I'm just reworking ALL cli scripts for 088.
So code and/or ideas are welcome just NOW.
R.
rgreening
Posts: 4
Joined: Thu Apr 22, 2010 11:28 am

Post by rgreening »

I would love the ability to delete graphs from cli. THe delete device is great also.
billcooper
Posts: 2
Joined: Mon Jul 12, 2010 10:19 am

remove interface

Post by billcooper »

remove interface graphing from cacti, basically copied the other script and changed it a bit :o


Remove Interface Script 0.1

CLI utility to remove interface from Cacti

Remove interface usage: remove_interface.php --device-id=[device id] --snmp-index=[snmp id]
Required:
--device-id host/device ID.

--snmp-index snmp index / if index.

List devices usage: remove_device.php --list-devices

List Options:
--list-devices Lists all devices
Attachments
remove_interface.zip
cacti remove interface graph script cli ifindex
(1.3 KiB) Downloaded 683 times
billcooper
Posts: 2
Joined: Mon Jul 12, 2010 10:19 am

Post by billcooper »

nothing.
User avatar
neovox
Cacti User
Posts: 52
Joined: Tue Jan 02, 2007 8:22 am
Location: MI

Post by neovox »

TheWitness wrote:Make sure you provide an option to either Delete Graphs and Data Sources for both scripts. The default should be "yes", even though the default in Cacti for deleting Graphs is "no".

You should also allow specifying either a substring range, or regular expression, and provide the user the ability to confirm before delete. Like do the query, show the rows and then delete if the response comes back to proceed. Provide an option to "force".

There are lot's of example on how I have written argument handling in the add* scripts.

Thanks for contributing.

TheWitness
Was there ever an update to this cli script that incorporated these items?
mithandra
Posts: 46
Joined: Wed Jul 14, 2010 8:19 am

Post by mithandra »

testing the scrtipt against 8.7g and it seems to remove the graph, although when going back into the interfaces on the device and choosing 64 bit counters the interface which had the 64 bit graph running on it is still greyed out so i am assuming that there are more modifications required to the db to remove this lock?

Looks like the data source has not been remove so that is why the lock is still in place.

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

Post by gandalf »

In this case, the cli script seems to delete the graph only, not the data source. As long as the data source exists, the according line will be greyed out.
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest