rrdCleaner - cleans cactis rrd dir from unused rrd's

Announcements concerning Plugins for Cacti

Moderators: Developers, Moderators

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

Post by gandalf »

I'd like to volunteer for that task (cause I'm waiting for the 0.9 stuff :wink: ). But let me first have a look at the current code, cause my php knowledge is not that of an expert. For testing purpose: is 0.8.6 branch compatible with 0.8.6f mysql structure? And how to get new code into the branch?
I'd even like to introduce something like a "confirmation" checkbox. Only confirmed deletes should be worked on. So there's a chance to have a look at them with more care. Or am I mistaken?
Reinhard
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

For testing purpose: is 0.8.6 branch compatible with 0.8.6f mysql structure?
Yes
And how to get new code into the branch?
E-mail me
I'd even like to introduce something like a "confirmation" checkbox. Only confirmed deletes should be worked on. So there's a chance to have a look at them with more care. Or am I mistaken?
If you look at host.php you will see a real good skeleton for code. It provides dropdowns, filters and the like. Not too bad.

Larry
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?
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

I have toyed with the idea of making a Plugin out of this. The user would be able to remove any unreferenced RRDs that haven't been updated in X number of days, either by selecting then for immediate removal, or automatically by setting a schedule.

How I see the scheduler working would be like this. The user sets it to archive old rrds after X days, in which it will move the RRDs to a seperate directory. From there, it will delete items after they are X+Y days old. Have it run immediately after the poller at midnight everynight (configurable ofcourse). You can even have it email you a list of all RRDs that it moved and deleted after that nights purging. Almost everything would be configurable ofcourse, you could set it not to delete, or not to archive, email, the amount of time, ect...

Write access to directory wouldn't be a problem, since it would run in the context of the normal poller process. I think you should also be able to set exclusions, so that certain files will never be removed.
Tut`
Posts: 11
Joined: Thu Jul 21, 2005 7:39 am

Post by Tut` »

I did a quick and dirty plugin based on rrdcleanr.php by ottob
It requires the Plugin Architecture

Do NOT forget to give correct permissions for apache user on rras folder

Also, fill in Backup path in :
Console > settings > paths > Backup directory

And give yourself some permissions :p (console > utilies > user managment > Clean rra)
Attachments
rrdclean.tar.gz
(2.11 KiB) Downloaded 752 times
spignataro
Posts: 41
Joined: Mon Nov 07, 2005 11:21 pm

Post by spignataro »

lvm wrote:
spignataro wrote:yes it is in my root directory. I only run cacti on this machine.
To be sure: you placed rrdcleaner into C:\apache2\Apache2\htdocs\rrdcleaner.php. But it must go into something like C:\apache2\Apache2\cacti\rrdcleaner.php where C:\apache2\Apache2\cacti is assumed to be your cacti directory (e.g. where poller.php sits).
Reinhard
my cacti installation resides in c:\apache2\Apache2\htdocs

that is the root of my cacti. I dont have a folder called cacti because there was no need for this.

poller.php resides in this folder as well. Does that help?
spignataro
Posts: 41
Joined: Mon Nov 07, 2005 11:21 pm

Post by spignataro »

Tut` wrote:I did a quick and dirty plugin based on rrdcleanr.php by ottob
It requires the Plugin Architecture

Do NOT forget to give correct permissions for apache user on rras folder

Also, fill in Backup path in :
Console > settings > paths > Backup directory

And give yourself some permissions :p (console > utilies > user managment > Clean rra)
i have the plugin architecture installed. But i am having a problem with this plugin. Might be that it was compressed wrong...is it possible to make it .zip instead of .tar.gz

Here is the code after i uncompressed it:

Code: Select all

<?
/*
Plugin RRDCleaner by Tut`
based on RRDcleanr.php by berger@hk-net.de ( 12/2004 )
(http://forums.cacti.net/viewtopic.php?t=5852)

Do NOT forget to add "$plugins['rrdclean'];" in include/config.php  :)

*/


chdir('../../');
include("./include/auth.php");

$ds_actions = array(
	1 => "Delete",
	2 => "Backup"
);

$rra_path = $config["base_path"] . "/rra";


if (isset($_POST['drp_action'])) {
	do_rrd();
}else{
	lr])) {
);
l"h funp_act {
	lr])) {lseglobal ;

$ds_acti,;

$rra_pra"	"./incl_onclude("./incluiew_headeaner.php"	html_ust_box("<strong>on              t t= array(
yT%
y["blors["php"	h"]y4
ycent	h"yust_box(php"	h_checkng>o	1 => "File name"yLast modified"ysize")a_pa	$files_unuRRDc= add_files(a_pa	$ic= 0ustet($sizeof($files_unuRRD) > 0_rrdpa	to each($files_unuRRD as $unuRRD_file_rrd(	d(	 0_rrd stfiles_unuR}(th = $conf";

"f";$unuRRD_file_;d(	 nuR}s[]fig[es_unuR};d(	 0_rrmtimtfiles_umtimt(th = $conf";

"f";$unuRRD_file_;dd(	to m_alt	hnate_row_"blor(["blors["to m_alt	hnate1"]y["blors["to m_alt	hnate2"]y[i);?>d(		<td>d(			<?

*/print;$unuRRD_file;?>d(		</td>d(		<td>d(			<?

*/print;dateox( ttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttttdttt_hp"	h"st mot	hnate1")ttdttttdttttdttttdttttdttttdttttdttttround((row_"blor/1024/1024), 2); ?> MB (<?tdttttdtow_"blor( ?>)ttttdttttdttttdt style="ttdttttdttttnuRR	$ic= 0u_style()ttd" width="1%" align="right"tttdtttinpunclype='	$ic= 0u' style='marp"): 0px;'($fil='	$k_tdttttdttttdttttdttttdttttd' title="ttdttttdttttttttdttttdttttd"dttttdttttdtttt/tr>ttdttdttt$i++(["b}tdttt<tbgd>d(	='#6d88ad'tdttttdt class='textSubHs(a_pDark' d>dspan="2">	h_checkTotalFile namedttttdttttdt class='textSubHs(a_pDark' d>dspan="2">	h_check<?techotround(tet($_sum(_alt	h)/1024/1024, 2); ?> MBFile namedttttdttt/tr> ttdttdtt_actrst_tg.phe()t
	./inclui	tdtttt"<tr>tttt<em>No  nuR}s[et(s</em>dttttt/tr>\n"t
	.
add_filendx(phpfainc)t
	draw        _dropdown(           )t
	tdtttt"<de/cm>\n"t
	
yT%
y["blors["php"	bottom_footycent	h"}"	html_usnuRRD_file_rong>on     t= arrayd(	result_almysql_quer$siSELECT[etdlors["FROM poll_paitem. "/r	wheof((rold_almysql_fetch
*/p(	result./incliles_unudbnate_suble (le rchr(rold[0)a_p/"),1 "/r	.
ad$handlm_alopendup"  t= ar); r	wheof((roilm_alRRDddup((rhandlm./in r	rd stfuble (roilm,-3) == "etd"/in r	rrd st!in_tet($sroilm, les_unudb./incli	iles_unuRRD asnate_row_"(["b	.
b	. r	.
t_ao asup" handlm.(["return les_unuRRD aser.phphtml_us_oncluderong>on     t= arrayiles_unuRRD as $unuRRD_file_rrt_actrst_tg.phe()t
rrd st_acti,;

$rra_pra"	" == "2")ncliletdlmovm_aldb_fetch
cell(eletdlm 'Pct value from acttings wherles_un ='ovm_aldb'",''_alt	acti,ovm_aldb_f= ''_iles_movm_aldb_feors["to m_a"/s $unu"tdttt
t!in_tet/in t= am_aldb)_iles_mkn t= am_aldb)tdttt
        }T%
y["blors["php"	h"]y4
ycent	h"yu((roilm("<s($var,$val"et le_;d(;

$rli	ilesin_terlg("^dttt(.*)eron$	hnavar, $mhe(h024i	iles_$(phude/= $mhe(h02[1) {ls.in r; st!in(t($sroilm,(phude,unuRRD aser.phli	iles_uswie(hti,;

$rra_pra"	" == "_iles_trst { "1" :les_trsin_taselinklors["to m_alt	hnate(phude)_iles_trttt"<tr>$(phude/alt on']))d!	
ylui	tdttt_trttt"<tr>$(phude/alt Error :}s[aboilautdn']))!	
ylbup(k;les_trst { "2" :les_trsin(res_unlors["to m_alt	hnate(phude, movm_aldb_alt	hnate(phude)_iles_trttt"<tr>$(phude/alt Mldbd!	
ylui	tdttt_trttt"<tr>$(phude/alt Error :}s[aboilautaldb!	
ylbup(k;
llui	tdttt_t"<t
doest look right huh!
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Tut` wrote:I did a quick and dirty plugin based on rrdcleanr.php by ottob
It requires the Plugin Architecture

Do NOT forget to give correct permissions for apache user on rras folder

Also, fill in Backup path in :
Console > settings > paths > Backup directory

And give yourself some permissions :p (console > utilies > user managment > Clean rra)
Ya, something seems to be wrong with the archive. Would you mind re-upping it?
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Looks like it was ftp transfered ascii mode.. :)
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
spignataro
Posts: 41
Joined: Mon Nov 07, 2005 11:21 pm

Post by spignataro »

no i didnt ftp it...that is an exact extract....
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

spignataro wrote:no i didnt ftp it...that is an exact extract....
I don't think he was referring to you :)
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

I'm not, I have seen this before, ascii mode used on a tar.gz file.. :)

Someone did it, just don't know who.. :D
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
spignataro
Posts: 41
Joined: Mon Nov 07, 2005 11:21 pm

Post by spignataro »

cigamit wrote:
spignataro wrote:no i didnt ftp it...that is an exact extract....
I don't think he was referring to you :)
o....doh!
Tut`
Posts: 11
Joined: Thu Jul 21, 2005 7:39 am

Post by Tut` »

oops =)

i said it was 'dirty' :p


There is a zip archive!
Attachments
rrdclean.zip
(2.35 KiB) Downloaded 552 times
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

"dirty" :lol:
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Thanks for getting this up and running as a plugin. Let me see if I can grab a broom and see if I can clean up some of the "dirt".

I have attached a cleaned up version of the plugin. The realm settings were slightly off, causing the link to not show. I also changed it to show the moved / deleted items in a nicer table at the top. I even did some simple code cleaning :)

Let me know how its works for you.
Attachments
rrdclean.zip
RRD Cleaner (minus the dirt)
(2.41 KiB) Downloaded 616 times
Locked

Who is online

Users browsing this forum: No registered users and 0 guests