@@ -0,0 +1,2065 @@
+#!/usr/bin/env python%0A%0A# Copyright 2014, Rackspace US, Inc.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport argparse%0Aimport requests%0Afrom ipaddr import IPv4Address%0Afrom maas_common import (status_ok, status_err, metric, metric_bool)%0Afrom requests import exceptions as exc%0A%0A%0Adef check(args):%0A    metadata_endpoint = ('http://%7Bip%7D:8775'.format(ip=args.ip))%0A    is_up = True%0A%0A    s = requests.Session()%0A%0A    try:%0A        # looks like we can only get / (ec2 versions) without specifying%0A        # an instance ID and other headers%0A        versions = s.get('%25s/' %25 metadata_endpoint,%0A                         verify=False,%0A                         timeout=10)%0A        milliseconds = versions.elapsed.total_seconds() * 1000%0A        if not versions.ok or '1.0' not in versions.content.splitlines():%0A            is_up = False%0A    except (exc.ConnectionError, exc.HTTPError, exc.Timeout) as e:%0A        is_up = False%0A    except Exception as e:%0A        status_err(str(e))%0A%0A    status_ok()%0A    metric_bool('nova_api_metadata_local_status', is_up)%0A    # only want to send other metrics if api is up%0A    if is_up:%0A        metric('nova_api_metadata_local_response_time',%0A               'uint32',%0A               '%25.3f' %25 milliseconds,%0A               'ms')%0A%0A%0Adef main(args):%0A    check(args)%0A%0Aif __name__ == %22__main__%22:%0A    parser = argparse.ArgumentParser(description='Check nova-api-metdata API')%0A    parser.add_argument('ip',%0A                        type=IPv4Address,%0A                        help='nova-api-metadata IP address')%0A    args = parser.parse_args()%0A    main(args)%0A

Add nova_api_metadata_local_check.py script