Sorry I did not post this on Monday been busy at work.
Here is what I came up with in trying to deal with the Host saved Configs
blowing away the last and only config after the expiration period. I have
been running this change since late last week and all seems fine. I am not
the best php programmer and there may be a better way to write this.. Tests
from Command line do not show any significant delays when running.
//Hosts Config Cleanup
//
// Moidified by Jim Hribnak Nov 4 2005
// Changed the way expiration works. If there were no new updates to your
configs, Your one and only saved config will be deleted.
// This change will ensure they will always be one config left and will not
expire if there is only 1 config saved.
// I have tested this with my live data, I lowered my expiration from 7 to 4
days, ran an update to get some new configs and then ran the expire.
// backup your Mysql before implementing this code <grin> It worked for
me.
$config_days = get_config_option("host_configs_store");
if ($config_days > 0) {
$count=0; # Added by Jim Hribnak
$period=time()-(60*60*24*$config_days);
$dtdelete=date("Y-m-d 00:00:00",$period);
logger ("Cleaning up Host Configs older than $dtdelete ($config_days
days)...\n");
$query = "Select * from hosts_config";
$result_id = db_query ($query) or die ("Query failed - TC1 -
".db_error());
$temphost = array();
while ($rows_id = db_fetch_array($result_id)) {
$id[$count] = $rows_id['id'];
$host[$count] = $rows_id['host'];
$tmpHost = $host[$count];
#logger ("Test $id[$count]\n");
if (array_key_exists($tmpHost, $temphost))
{
$temphost[$tmpHost]++;
$query = "delete from hosts_config where date <= '$dtdelete'
and id > 1 and host=$host[$count] limit 1";
$result_del_config = db_query ($query) or die ("Query
failed: CC1 - Delete hosts_config - ".db_error());
logger ("Removing Host Config for Host $host[$count]\n"); }
else
{
$temphost[$tmpHost]++;
logger ("No Host configs to remove\n");
}
$count=$count+1;
}
# $query = "delete from hosts_config where date <= '$dtdelete' and id > 1
and host=$host[$count] limit 1";
# $result_del_config = db_query ($query) or die ("Query failed: CC1 -
Delete hosts_config - ".db_error());
logger ("Cleanup of hosts_config table finished...
($result_del_config)\n");
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of JimH
Sent: Friday, November 04, 2005 4:03 PM
To: [email protected]
Subject: RE: [jffnms-users] Hosts Saved Configs Possible bug?
Those who may of been following this thread.. I did come up with a solution
and forwarded it to Javier, hopefully he will incorporate it into the next
release. If yhou want this before drop me an email
Jim
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Javier
Szyszlican
Sent: Friday, November 04, 2005 12:02 PM
Cc: [email protected]
Subject: Re: [jffnms-users] Hosts Saved Configs Possible bug?
You are right.
You are also welcome to implement the change in the cleanup_raw_tables
script.
Thanks,
Javier
JimH wrote:
> I am using the Hosts Saved Configs part of JFFNMS I currently have it
set
> for 14 days. Today one of my router configs was removed. Should JFFNMS
> look to see if its the only config remaining and leave it even if it
exceeds
> 14 days old (in my example)?
>
>
> What happened if the device you save your configs for died the same day
> JFFNMS purged it from its saved tables.. your hoped :)
>
> I think if there are no changes to a config (IE router) it should keep the
> last known copy it had on file.
>
> Once its gone it will grab it again (I know I manually ran the cronevent)
> but what happens on the off chance the router or switch died?
>
>
> Thanks
>
> Jim
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> jffnms-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jffnms-users
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Javier Szyszlican, Project Leader, JFFNMS
[EMAIL PROTECTED]
I hope JFFNMS or I were helpful to you, if you
can, please donate at http://jffnms.org/donate
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jffnms-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jffnms-users
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jffnms-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jffnms-users
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jffnms-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jffnms-users