From: Michael Goldish Subject: [KVM-AUTOTEST PATCH 10/28] KVM test: avoid printing address cache messages too often Date: Mon, 27 Dec 2010 18:01:37 +0200 Message-ID: <1293465715-16599-10-git-send-email-mgoldish@redhat.com> References: <1293465715-16599-1-git-send-email-mgoldish@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: In-Reply-To: <1293465715-16599-1-git-send-email-mgoldish@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org Currently, messages such as (address cache) Adding cache entry: 11:22:33:44:55:66 ---> 10.20.30.40 are displayed for every IP address assignment caught by tcpdump. These often occur in clusters. Therefore, to avoid bloating the log files, print a message only if the last message for the same MAC address was printed more than 5 seconds ago. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_preprocessing.py | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index d2f94cd..90382cc 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -384,9 +384,11 @@ def _update_address_cache(address_cache, line): matches = re.findall(r"\w*:\w*:\w*:\w*:\w*:\w*", line) if matches and address_cache.get("last_seen"): mac_address = matches[0].lower() - logging.debug("(address cache) Adding cache entry: %s ---> %s", - mac_address, address_cache.get("last_seen")) + if time.time() - address_cache.get("time_%s" % mac_address, 0) > 5: + logging.debug("(address cache) Adding cache entry: %s ---> %s", + mac_address, address_cache.get("last_seen")) address_cache[mac_address] = address_cache.get("last_seen") + address_cache["time_%s" % mac_address] = time.time() del address_cache["last_seen"] -- 1.7.3.3