예제 #1
0
            % (SUPPORTED_VERSIONS, version)
        )


def main():
    if len(sys.argv[1:]) != 2:
        args = ' '.join(sys.argv[1:])
        status_err(
            'Requires 2 arguments, arguments provided: "%s"' % args
        )

    report_type = sys.argv[1].lower()
    report_request = sys.argv[2].lower()

    # If we're not using the correct version of OpenManage, error out
    check_openmanage_version()

    try:
        report = hardware_report(report_type, report_request)
    except (OSError, subprocess.CalledProcessError) as e:
        status_err(str(e))

    status_ok()
    metric_bool('hardware_%s_status' % report_request,
                all_okay(report, regex[report_type]))


if __name__ == '__main__':
    with print_output():
        main()
예제 #2
0
    version = match.groups()[0]
    if version not in SUPPORTED_VERSIONS:
        status_err('Expected version in %s to be installed but found %s' %
                   (SUPPORTED_VERSIONS, version))


def main():
    if len(sys.argv[1:]) != 2:
        args = ' '.join(sys.argv[1:])
        status_err('Requires 2 arguments, arguments provided: "%s"' % args)

    report_type = sys.argv[1].lower()
    report_request = sys.argv[2].lower()

    # If we're not using the correct version of OpenManage, error out
    check_openmanage_version()

    try:
        report = hardware_report(report_type, report_request)
    except (OSError, subprocess.CalledProcessError) as e:
        status_err(str(e))

    status_ok()
    metric_bool('hardware_%s_status' % report_request,
                all_okay(report, regex[report_type]))


if __name__ == '__main__':
    with print_output():
        main()
    holland_bs = args.holland_backupset

    today = datetime.date.today().strftime('%Y%m%d')
    yesterday = (datetime.date.today() -
                 datetime.timedelta(days=1)).strftime('%Y%m%d')

    # Get completed Holland backup set
    backupsets = \
        holland_lb_check(galera_hostname, holland_bin, holland_bs)

    if len(
        [backup
         for backup in backupsets if yesterday or today in backup[0]]) > 0:
        status_ok(m_name='maas_holland')
        metric_bool('holland_backup_status', True, m_name='maas_holland')
    else:
        metric_bool('holland_backup_status', False, m_name='maas_holland')
        status_err('Could not find Holland backup from %s or %s' %
                   (yesterday, today),
                   m_name='maas_holland')

    # Print metric about last backup
    print_metrics('holland_backup_size',
                  "{0:.1f}".format(float(backupsets[-1][1]) / 1024))


if __name__ == '__main__':
    args = parse_args()
    with print_output(print_telegraf=args.telegraf_output):
        main()
예제 #4
0
        maas_common.status_err('Could not parse dispersion report output')

    maas_common.status_ok()
    print_metrics('object', object_match)
    print_metrics('container', container_match)


# Example output::
# $ python swift-dispersion.py
# > status okay
# > metric object_retries uint64 0
# > metric object_seconds uint64 0 s
# > metric object_num_partitions uint64 2
# > metric object_num_objects uint64 2
# > metric object_percent double 100.00
# > metric object_copies_found uint64 10
# > metric object_partition_copies uint64 0
# > metric object_partition_percent double 0.78
# > metric object_total_copies uint64 10
# > metric container_retries uint64 0
# > metric container_seconds uint64 0 s
# > metric container_num_objects uint64 3
# > metric container_percent double 100.00
# > metric container_copies_found uint64 6
# > metric container_partition_percent double 1.17
# > metric container_total_copies uint64 6

if __name__ == '__main__':
    with maas_common.print_output():
        main()
예제 #5
0
    metrics = {}
    session = requests.Session()  # Make a Session to store the auth creds
    session.auth = (options.username, options.password)

    protocol = 'https' if options.https else 'http'

    _get_connection_metrics(session, metrics, protocol,
                            options.host, options.port)
    _get_overview_metrics(session, metrics, protocol,
                          options.host, options.port)
    _get_node_metrics(session, metrics, protocol, options.host,
                      options.port, options.name)
    _get_queue_metrics(session, metrics, protocol, options.host,
                       options.port)
    _get_consumer_metrics(session, metrics, protocol, options.host,
                          options.port)

    status_ok(m_name='maas_rabbitmq')

    for k, v in metrics.items():
        if v['value'] is True or v['value'] is False:
            metric_bool('rabbitmq_%s_status' % k, not v['value'])
        else:
            metric('rabbitmq_%s' % k, 'int64', v['value'], v['unit'])


if __name__ == "__main__":
    args = options = parse_args()
    with print_output(print_telegraf=args.telegraf_output):
        main()
예제 #6
0
        else:
            logger.info("{} - rally task {} "
                        "completed".format(args.task, task_uuid))

        os.rmdir(LOCK_PATH + '/' + task_uuid)
        os.rmdir(LOCK_PATH)
        logger.debug("{} - removed lock for rally task "
                     "{}".format(args.task, task_uuid))

    parse_task_results(task_uuid, results, logger)

    end = time.time()
    metric('maas_check_duration', 'double', "{:.2f}".format((end - start) * 1))

    if args.influxdb:
        try:
            send_metrics_to_influxdb(plugin_config, logger)
        except:
            metric('influxdb_success', 'uint32', 0)
        else:
            metric('influxdb_success', 'uint32', 1)

    return


if __name__ == '__main__':
    parser = make_parser()
    args = parser.parse_args()
    with maas_common.print_output(print_telegraf=args.telegraf_output):
        main()
예제 #7
0

def get_controller_cache_status():
    return check_command(('hpssacli', 'ctrl', 'all', 'show', 'status'),
                         'Cache Status', 'OK')


def get_controller_battery_status():
    return check_command(('hpssacli', 'ctrl', 'all', 'show', 'status'),
                         'Battery/Capacitor Status', 'OK')


def main():
    status = {}
    status['hardware_processors_status'] = get_hpasmcli_status('server')
    status['hardware_memory_status'] = get_hpasmcli_status('dimm')
    status['hardware_disk_status'] = get_drive_status()
    status['hardware_controller_status'] = get_controller_status()
    status['hardware_controller_cache_status'] = get_controller_cache_status()
    status['hardware_controller_battery_status'] = \
        get_controller_battery_status()

    maas_common.status_ok()
    for name, value in status.viewitems():
        maas_common.metric_bool(name, value)


if __name__ == '__main__':
    with maas_common.print_output():
        main()
예제 #8
0
        else:
            logger.info("{} - rally task {} "
                        "completed".format(args.task, task_uuid))

        os.rmdir(LOCK_PATH + '/' + task_uuid)
        os.rmdir(LOCK_PATH)
        logger.debug("{} - removed lock for rally task "
                     "{}".format(args.task, task_uuid))

    parse_task_results(task_uuid, results, logger)

    end = time.time()
    metric('maas_check_duration', 'double', "{:.2f}".format((end - start) * 1))

    if args.influxdb:
        try:
            send_metrics_to_influxdb(plugin_config, logger)
        except:
            metric('influxdb_success', 'uint32', 0)
        else:
            metric('influxdb_success', 'uint32', 1)

    return


if __name__ == '__main__':
    parser = make_parser()
    args = parser.parse_args()
    with maas_common.print_output(print_telegraf=args.telegraf_output):
        main()
예제 #9
0
                    iptables_exist = True

    if bridge_sysctl is True and iptables_exist is True:
        metric_bool('iptables_status', True, m_name='iptables_active')
        status_ok(m_name='iptables_active')
    else:
        metric_bool('iptables_status', False, m_name='iptables_active')

    metric('bridge-nf-call-arptables', 'int64',
           bridge_param_metrics.get('bridge-nf-call-arptables', 0))
    metric('bridge-nf-call-iptables', 'int64',
           bridge_param_metrics.get('bridge-nf-call-iptables', 0))
    metric('bridge-nf-call-ip6tables', 'int64',
           bridge_param_metrics.get('bridge-nf-call-ip6tables', 0))


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Ensure that security groups are being actively '
                    'enforced on a hypervisor.')
    parser.add_argument('host', nargs='?',
                        type=str,
                        help='Compute host to filter')
    parser.add_argument('--telegraf-output',
                        action='store_true',
                        default=False,
                        help='Set the output format to telegraf')
    args = parser.parse_args()
    with print_output(print_telegraf=False):
        main()
예제 #10
0
    # Check that iptables rules are in place
    iptables_rules = ''
    try:
        iptables_rules = str(subprocess.check_output(['iptables-save'
                                                      ])).split('\n')
    except Exception as e:
        status('error', str(e), force_print=False)

    iptables_exist = False
    for rule in iptables_rules:
        if "DROP" in rule:
            iptables_exist = True

    if bridge_sysctl is True and iptables_exist is True:
        metric_bool('iptables_status', True, m_name='iptables_active')
        status_ok(m_name='iptables_active')
    else:
        metric_bool('iptables_status', False, m_name='iptables_active')

    metric('bridge-nf-call-arptables', 'int64',
           bridge_param_metrics.get('bridge-nf-call-arptables', 0))
    metric('bridge-nf-call-iptables', 'int64',
           bridge_param_metrics.get('bridge-nf-call-iptables', 0))
    metric('bridge-nf-call-ip6tables', 'int64',
           bridge_param_metrics.get('bridge-nf-call-ip6tables', 0))


if __name__ == '__main__':
    with print_output(print_telegraf=False):
        main()