@@ -0,0 +1,2557 @@
+#!/usr/bin/env python%0A%22%22%22 Node taints check for OpenShift V3 %22%22%22%0A%0A# Adding the ignore because it does not like the naming of the script%0A# to be different than the class name%0A# pylint: disable=invalid-name%0A%0A# pylint: disable=wrong-import-position%0A# pylint: disable=broad-except%0A# pylint: disable=line-too-long%0A%0Aimport argparse%0Aimport time%0A%0Aimport logging%0Alogging.basicConfig(%0A    format='%25(asctime)s - %25(relativeCreated)6d - %25(levelname)-8s - %25(message)s',%0A)%0Alogger = logging.getLogger()%0Alogger.setLevel(logging.WARN)%0A%0A# Our jenkins server does not include these rpms.%0A# In the future we might move this to a container where these%0A# libs might exist%0A#pylint: disable=import-error%0A%0Afrom openshift_tools.monitoring.ocutil import OCUtil%0Afrom openshift_tools.monitoring.metric_sender import MetricSender%0A%0Aocutil = OCUtil()%0A%0Adef runOCcmd_yaml(cmd, base_cmd='oc'):%0A    %22%22%22 log commands through ocutil %22%22%22%0A    logger.info(base_cmd + %22 %22 + cmd)%0A    ocy_time = time.time()%0A    ocy_result = ocutil.run_user_cmd_yaml(cmd, base_cmd=base_cmd, )%0A    logger.info(%22oc command took %25s seconds%22, str(time.time() - ocy_time))%0A    return ocy_result%0A%0Adef parse_args():%0A    %22%22%22 parse the args from the cli %22%22%22%0A    parser = argparse.ArgumentParser(description='Check all the nodes taints Status')%0A    parser.add_argument('-v', '--verbose', action='count', default=0,%0A                        help='verbosity level, specify multiple')%0A%0A    args = parser.parse_args()%0A%0A    if args.verbose %3E 0:%0A        logger.setLevel(logging.INFO)%0A%0A    if args.verbose %3E 1:%0A        logger.setLevel(logging.DEBUG)%0A%0A    return args%0A%0Adef check_taint_status():%0A    %22%22%22get all the info of all node %22%22%22%0A    result_status = 0%0A    node_info = runOCcmd_yaml(%22get node %22)%0A    for item in node_info%5B'items'%5D:%0A        logger.info(%22Checking node: %25s%22, item%5B'metadata'%5D%5B'name'%5D)%0A        if %22taints%22 in item%5B'spec'%5D:%0A            taints = item%5B'spec'%5D%5B'taints'%5D%0A            for taint in taints:%0A                result_status = result_status + 1%0A                logger.warn(%22Node: %25s, have unexpected taint: %25s=%25s:%25s%22, item%5B'metadata'%5D%5B'name'%5D, taint%5B'key'%5D, taint%5B'value'%5D, taint%5B'effect'%5D)%0A    return result_status%0A%0Adef main():%0A    %22%22%22 check all the node taints see if any node have problem %22%22%22%0A    args = parse_args()%0A    logger.debug(%22args: %22)%0A    logger.debug(args)%0A%0A    taint_status = check_taint_status()%0A%0A    #send the value to zabbix%0A    mts = MetricSender(verbose=args.verbose)%0A    mts.add_metric(%7B'openshift.nodes.taint.status': taint_status%7D)%0A    mts.send_metrics()%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Add monitor script for taints