def main():
    client = Client(['localhost'])
    plugins = None

    if args.plugin:
        if args.category or args.component or args.health:
            lg.warn("Plugins specified by name, ignoring --category, --component and --health")

        plugins = client.get_plugins([args.plugin])
    elif args.category or args.component or args.health:
        filter = []
        if args.category:
            filter.append({'key': 'Category', 'value': args.category})
        if args.component:
            filter.append({'key': 'Component', 'value': args.component})
        if args.health:
            filter.append({'key': 'Type', 'value': 'healthCheck'})
        plugins = client.get_plugins(filter)
    else:
        nagios.exit_unknown("invalid startup configuration - neither plugin nor --category nor --component "
                            "nor --health specified")

    # No plugin found
    if not plugins:
        if args.plugin:
            message = "plugin %s not found" % args.plugin
        else:
            message = "no plugin found by category %s and component %s, health: %s" % \
                      (args.category, args.component, args.health)
        nagios.exit_unknown(message)

    if args.force:
        plugins = client.force_run(plugins, progress=False)

    status_methods_pairs = [(ERROR, nagios.exit_critical), (UNKNOWN, nagios.exit_unknown),
                            (WARN, nagios.exit_warning), (OK, nagios.exit_ok)]

    # Manage plugin result. We can't return much data to Nagios, so just say if it's alright or not
    results = dict((s, []) for s, _ in status_methods_pairs)

    for plugin in plugins.values()[0]['plugins'].itervalues():
        plugin_name = plugin['name']
        if not plugin['lastResult']:
            results[UNKNOWN].append({'name': plugin_name, 'message': "plugin has no last result"})
        else:
            last_status = plugin['lastResult']['status']

            if last_status in [ERROR, WARN, OK]:
                try:
                    results[last_status].append({'name': plugin_name,
                                                 'message': plugin['lastResult']['messages'][last_status.lower()][0]})
                except (KeyError, __HOLE__, TypeError):
                    if last_status == OK:
                        results[last_status].append(
                            {'name': plugin_name,
                             'message': "smoke test %s succeeded at %s" %
                                        (plugin['name'], plugin['lastResult']['lastRun'])})
                    else:
                        results[last_status].append({'name': plugin_name, 'message': parse_issue(plugin)})
            else:
                results[UNKNOWN].append({'name': plugin_name,
                                         'message': "unknown status %s at %s" %
                                                    (plugin['lastResult']['status'], plugin['lastResult']['lastRun'])})

    for status, exit_method in status_methods_pairs:
        if results[status]:
            if len(plugins.values()[0]['plugins']) == 1:
                # if only one plugin has been executed, do not print summary
                exit_method(results[status][0]['message'])
            else:
                summary = ', '.join(["%s: %s" % (s, len(results[s])) for s, _ in status_methods_pairs if results[s]])
                messages = ['\n'.join(["%s - %s - %s" % (s, item['name'], item['message']) for item in list])
                            for s, list in results.iteritems() if list]
                exit_method("%s\n%s" % (summary, '\n'.join(messages)))
dataset/ETHPy150Open gooddata/smoker/bin/check_smoker_plugin.py/main