Ejemplo n.º 1
0
def main():
    args = parse_cmdargs()

    try:
        stat = sadf.getLatestStat(sadf.sadfExecCmd(_sadfNetCommand),
                                  args.interval)
        (rc, msg) = _getStatMessage(stat, all=args.all,
                                    includes=args.include,
                                    excludes=args.exclude)
        print msg
        sys.exit(rc)
    except (sadf.SadfCmdExecFailedException,
            sadf.SadfXmlErrorException,
            KeyError) as e:
        logging.error("unable to get network status: %s" % e)
        print "UNKNOWN"
        sys.exit(utils.PluginStatusCode.UNKNOWN)
Ejemplo n.º 2
0
                            "| num_of_cpu=%s %s" % (
                                totalCpuUsage, idleCpu,
                                len(s['cpu-load']['cpu']) - 1,
                                " ".join(perfLines)))
        pl_op['exit_status'] = utils.PluginStatusCode.WARNING
    else:
        pl_op["message"] = ("CPU Status OK: Total CPU:%s%% Idle CPU:%s%% "
                            "| num_of_cpu=%s %s" % (
                                totalCpuUsage, idleCpu,
                                len(s['cpu-load']['cpu']) - 1,
                                " ".join(perfLines)))
        pl_op['exit_status'] = utils.PluginStatusCode.OK
    return pl_op


if __name__ == '__main__':
    args = parse_input()
    if args.critical <= args.warning:
        print "UNKNOWN:Critical must be greater than Warning."
        sys.exit(utils.PluginStatusCode.UNKNOWN)
    try:
        st = sadf.getLatestStat(sadf.sadfExecCmd(_sadfCpuCommand),
                                args.interval if args.interval else 1)
    except (sadf.SadfCmdExecFailedException,
            sadf.SadfXmlErrorException) as e:
        print str(e)
        exit(utils.PluginStatusCode.UNKNOWN)
    d = showCpuStat(args.warning, args.critical, st)
    print d["message"]
    exit(d['exit_status'])
Ejemplo n.º 3
0
            "CPU Status WARNING: Total CPU"
            ":%s%% Idle CPU:%s%% "
            "| num_of_cpu=%s %s" %
            (totalCpuUsage, idleCpu, len(s['cpu-load']['cpu']) - 1,
             " ".join(perfLines)))
        pl_op['exit_status'] = utils.PluginStatusCode.WARNING
    else:
        pl_op["message"] = (
            "CPU Status OK: Total CPU:%s%% Idle CPU:%s%% "
            "| num_of_cpu=%s %s" %
            (totalCpuUsage, idleCpu, len(s['cpu-load']['cpu']) - 1,
             " ".join(perfLines)))
        pl_op['exit_status'] = utils.PluginStatusCode.OK
    return pl_op


if __name__ == '__main__':
    args = parse_input()
    if args.critical <= args.warning:
        print "UNKNOWN:Critical must be greater than Warning."
        sys.exit(utils.PluginStatusCode.UNKNOWN)
    try:
        st = sadf.getLatestStat(sadf.sadfExecCmd(_sadfCpuCommand),
                                args.interval if args.interval else 1)
    except (sadf.SadfCmdExecFailedException, sadf.SadfXmlErrorException) as e:
        print str(e)
        exit(utils.PluginStatusCode.UNKNOWN)
    d = showCpuStat(args.warning, args.critical, st)
    print d["message"]
    exit(d['exit_status'])
Ejemplo n.º 4
0
                                 float(s['memory']['swpused-percent']),
                                 utils.convertSize(int(s['memory']['swpused']),
                                                   "KB", "GB"),
                                 totalSwap,
                                 utils.convertSize(int(s['memory']['swpused']),
                                                   "KB", "GB"),
                                 war_value,
                                 crit_value,
                                 totalSwap))
    except (KeyError, ValueError, TypeError) as e:
        pl_op["message"] = "key: %s not found" % str(e)
        pl_op["exit_status"] = utils.PluginStatusCode.UNKNOWN
        return pl_op
    return pl_op

if __name__ == '__main__':
    args = parse_input()
    if args.critical <= args.warning:
        print "UNKNOWN:Critical must be greater than Warning."
        sys.exit(utils.PluginStatusCode.UNKNOWN)
    try:
        st = sadf.getLatestStat(sadf.sadfExecCmd(_sadfSwapCommand),
                                args.interval if args.interval else 1)
    except (sadf.SadfCmdExecFailedException,
            sadf.SadfXmlErrorException) as e:
        print str(e)
        exit(utils.PluginStatusCode.UNKNOWN)
    d = showSwapStat(args.warning, args.critical, st)
    print d["message"]
    exit(d['exit_status'])