Re: Re: Working Version of Net_Monitor - Please Review :)

From: Date: Thu, 09 Dec 2004 04:44:02 +0000
Subject: Re: Re: Working Version of Net_Monitor - Please Review :)
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-34936@lists.php.net to get a copy of this message
Hi Bertrand, bertrand Gugger wrote:
Anyway, I don't understand where this resetState() could be used, as it's just acting on some internal properties which only exist in mean Monitor object life.
This function came in very handy when creating my test files. By setting my state file to be a relatively unique file name, then using Net_Monitor::resetState() before and after the Net_Monitor::checkAll() call, I can guarantee the same results every time, which is exactly what I want to do to test that the system was installed correctly and, moving forward, to test backwards compatability. Furthermore, because I am using a different state file than the default, I do not impact existing state files for installations that could be already in production.
It should be possible to reset only one service for example.
This is now possible using Net_Monitor::resetHostState(). This works for both a host (all host results are reset) or a host and service combination (just that host/service combination is reset).
The stateDiff() method could follow both arrays in one loop not need to double loop and reset !
By using a series of flags, the primary array now no longer needs to be reset -- data is copied directly to the return array. For the secondary array, because it is nested within the primary loop, it can actually be more efficient to act destructively on this array and then go back to change the message and code components before putting them in the return array. This is because acting destructively on the array diminishes the array size, decreasing the size of the secondary loop every time a duplicate is found. Given that a common scenario will be that a variety of services are down and stay down through the course of multiple calls to Net_Monitor, there will be a lot of duplicates and therefore removing them as soon as they are found and then going back for the ones that are unique will actually be faster than trying to copy them out to a second array. Best, Robert

« previous php.pear.dev (#34936) next »