Ejemplo n.º 1
0
def main(isy):


    nodefmt="%-18s";
    commfmt="%-10s";

    header = [ "Node", "Control", "Action", "Time", "UID", "Log Type" ]

    if opt_nonames :
	nodefmt="{:<12}"
	commfmt="{:<4}"

    fmt = nodefmt + " " + commfmt + " {:<20} {:<15} {:<15} {:<15}"
    # fmt = "{0} {1} {2} {3} {4} {5}"

    time_offset = log_time_offset()

   # llimit = 200

    # print "{0} {1} {2} {3} {4} {5}".format(*header)
    print fmt.format(*header)
    for log_line in isy.log_iter(error = opt_errorlog) :
	col = str(log_line).split("\t")

	newtime = int(col[3]) - time_const - time_offset
	ti = time.localtime(newtime)
	col[3] = time.strftime("%b %d %H:%M:%S", ti)
	col[4] = int(col[4])
	if col[4] < len(LOG_USERID) : col[4] = LOG_USERID[col[4]]
	if col[5] in LOG_TYPES : col[5] = LOG_TYPES[col[5]]

	print fmt.format( *col )
Ejemplo n.º 2
0
def log_sys(isy):

    nodefmt = "{:<12}"
    commfmt = "{:<4}"

    header = ["Node", "Control", "Action", "Time", "UID", "Log Type"]

    if opt_names:
        nodefmt = "{:<18}"
        commfmt = "{:<10}"
        print "opt_names = ", opt_names

    if opt_tab:
        fmt = "{0}\t{1}\t{2}\t{3}\t{4}\t{5}"
    else:
        fmt = nodefmt + " " + commfmt + " {:<20} {:<15} {:<15} {:<15}"

    if opt_nosec:
        time_fmt = "%b %d %H:%M"
    else:
        time_fmt = "%b %d %H:%M:%S"

    # fmt = "{0} {1} {2} {3} {4} {5}"

    time_offset = log_time_offset()

    # llimit = 200

    # print "{0} {1} {2} {3} {4} {5}".format(*header)
    print fmt.format(*header)
    for log_line in isy.log_iter(error=opt_errorlog):
        col = str(log_line).split("\t")

        if opt_names:
            gn = isy._node_get_name(col[0])
            # print "n / gn = ", col[0], " / ", gn
            if gn[1] is not None:
                col[0] = gn[1]

        newtime = int(col[3]) - time_const - time_offset
        ti = time.localtime(newtime)
        col[3] = time.strftime(time_fmt, ti)
        col[4] = int(col[4])
        if col[4] < len(LOG_USERID):
            col[4] = LOG_USERID[col[4]]
        if col[5] in LOG_TYPES:
            col[5] = LOG_TYPES[col[5]]

        print fmt.format(*col)
Ejemplo n.º 3
0
def log_sys(isy) :

    nodefmt="{:<12}"
    commfmt="{:<4}"

    header = [ "Node", "Control", "Action", "Time", "UID", "Log Type" ]

    if opt_names :
        nodefmt="{:<18}"
        commfmt="{:<10}"
        print "opt_names = ", opt_names

    if opt_tab :
        fmt = "{0}\t{1}\t{2}\t{3}\t{4}\t{5}"
    else :
        fmt = nodefmt + " " + commfmt + " {:<20} {:<15} {:<15} {:<15}"

    if opt_nosec :
        time_fmt = "%b %d %H:%M"
    else :
        time_fmt = "%b %d %H:%M:%S"

    # fmt = "{0} {1} {2} {3} {4} {5}"

    time_offset = log_time_offset()

   # llimit = 200

    # print "{0} {1} {2} {3} {4} {5}".format(*header)
    print fmt.format(*header)
    for log_line in isy.log_iter(error = opt_errorlog) :
        col = str(log_line).split("\t")

        if opt_names :
            gn = isy._node_get_name(col[0])
            # print "n / gn = ", col[0], " / ", gn
            if gn[1] is not None :
                col[0] = gn[1]

        newtime = int(col[3]) - time_const - time_offset
        ti = time.localtime(newtime)
        col[3] = time.strftime(time_fmt, ti)
        col[4] = int(col[4])
        if col[4] < len(LOG_USERID) : col[4] = LOG_USERID[col[4]]
        if col[5] in LOG_TYPES : col[5] = LOG_TYPES[col[5]]

        print fmt.format( *col )
Ejemplo n.º 4
0
def log_err(isy):

    header = ["Time", "UID", "Log Type", "Error Message"]

    if opt_tab:
        fmt = "{0}\t{1}\t{2}\t{3}"
    else:
        fmt = "{:<15} {:<24} {:<38} {!s}"

    if opt_nosec:
        time_fmt = "%b %d %H:%M"
    else:
        time_fmt = "%b %d %H:%M:%S"

    time_offset = log_time_offset()

    # llimit = 200

    # print "{0} {1} {2} {3}".format(*header)
    print fmt.format(*header)
    for log_line in isy.log_iter(error=1):
        col = str(log_line).split("\t")

        # print "log_line : ", len(col), " : ", "|".join(col)
        if len(col) < 4:
            print "BAD log_line : ", len(col), " : ", "|".join(col)
            continue

        newtime = int(col[0]) - time_const - time_offset
        ti = time.localtime(newtime)
        col[0] = time.strftime(time_fmt, ti)
        col[1] = int(col[1])
        if col[1] < len(LOG_USERID):
            col[1] = LOG_USERID[col[1]]
        if col[2] in LOG_TYPES:
            col[2] = LOG_TYPES[col[2]]

        print fmt.format(*col)
Ejemplo n.º 5
0
def log_err(isy):

    header = ["Time", "UID", "Log Type", "Error Message"]

    if opt_tab:
        fmt = "{0}\t{1}\t{2}\t{3}"
    else:
        fmt = "{:<15} {:<24} {:<38} {!s}"

    if opt_nosec:
        time_fmt = "%b %d %H:%M"
    else:
        time_fmt = "%b %d %H:%M:%S"

    time_offset = log_time_offset()

    # llimit = 200

    #print "{0} {1} {2} {3}".format(*header)
    print(fmt.format(*header))
    for log_line in isy.log_iter(error=1):
        col = str(log_line).split("\t")

        # print "log_line : ", len(col), " : ", "|".join(col)
        if (len(col) < 4):
            print("BAD log_line : ", len(col), " : ", "|".join(col))
            continue

        newtime = int(col[0]) - time_const - time_offset
        ti = time.localtime(newtime)
        col[0] = time.strftime(time_fmt, ti)
        col[1] = int(col[1])
        if col[1] < len(LOG_USERID): col[1] = LOG_USERID[col[1]]
        if col[2] in LOG_TYPES: col[2] = LOG_TYPES[col[2]]

        print(fmt.format(*col))