X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Fmonitor.py;h=bc22b1eab93cc35fcdd494793bc92d70d1621ec8;hb=5e00dc425941c2b1971030122eaab83b95eede84;hp=2a78cb66c7cd68ccedc363d9cba77bcff92f2fd2;hpb=be640e1f465e4628b3b7cf73ebd954fa5deea941;p=doctor.git diff --git a/tests/monitor.py b/tests/monitor.py index 2a78cb66..bc22b1ea 100644 --- a/tests/monitor.py +++ b/tests/monitor.py @@ -1,17 +1,11 @@ +############################################################################## +# Copyright (c) 2016 NEC Corporation and others. # -# Copyright 2016 NEC Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## import argparse import json @@ -34,10 +28,11 @@ class DoctorMonitorSample(object): def __init__(self, args): self.hostname = args.hostname self.inspector = args.inspector - self.ip_addr = socket.gethostbyname(self.hostname) + self.ip_addr = args.ip or socket.gethostbyname(self.hostname) def start_loop(self): - print "start ping to host %s" % self.hostname + print "start ping to host %(h)s (ip=$(i)s)" % {'h': self.hostname, + 'i': self.ip_addr} sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) sock.settimeout(self.timeout) @@ -63,6 +58,8 @@ def get_args(): parser = argparse.ArgumentParser(description='Doctor Sample Monitor') parser.add_argument('hostname', metavar='HOSTNAME', type=str, nargs='?', help='a hostname to monitor connectivity') + parser.add_argument('ip', metavar='IP', type=str, nargs='?', + help='an IP address to monitor connectivity') parser.add_argument('inspector', metavar='INSPECTOR', type=str, nargs='?', help='inspector url to report error', default='http://127.0.0.1:12345/events')