if args.show_timestamp:
        info['show_timestamp'] = True

    # Windows terminal cannot show colors the way we use...
    if args.no_colors or os.name == 'nt':
        info['show_colors'] = False

    # disable buffering for stdin
    sys.stdin = os.fdopen(sys.stdin.fileno(), "r", 0)

    # spec
    spec = GetModelSpec(sshc.get_info()['serial'])
    if spec == None:
        print >> sys.stderr, "This model is not yet supported. Contact Ondrej Holecek <*****@*****.**> to add support for SN %s." % (
            sshc.get_info()['serial'], )
        sys.exit(0)

    try:
        cycle(do, {
            'sshc': sshc,
            'ifaces': args.iface,
            'spec': spec,
            'info': info,
        },
              args.cycle_time,
              cycles_left=[args.max_cycles],
              debug=args.debug)
    except KeyboardInterrupt:
        sshc.destroy()
示例#2
0
        print prepend_timestamp(old_line, etime, 'pkttop')

    cache['history'].insert(0, (etime.as_timestamp(), pdiff, total))
    if len(cache['history']) > history:
        cache['history'] = cache['history'][:history]
    cache['last']['packets'] = packets
    cache['last']['cpu'] = usage
    cache['last']['collected_on'] = etime.as_timestamp()

    sys.stdout.flush()
    return etime


if __name__ == '__main__':
    cache = {'history': []}
    try:
        cycle(do, {
            'sshc': sshc,
            'cache': cache,
            'history': args.history,
            'hz': args.hz,
            'raw': args.raw,
            'percentage': args.percentage,
        },
              args.collect_time,
              cycles_left=[args.max_cycles],
              debug=args.debug,
              interactive=args.interactive)
    except KeyboardInterrupt:
        sshc.destroy()
示例#3
0
		old_line = " %7i " % ( -int(round(etime.as_timestamp()-odata[0])),)
		for k in ('ReasmReqds', 'ReasmOKs', 'ReasmTimeout', 'ReasmFails', 'FragOKs', 'FragCreates', 'FragFails'):
			old_line += "| %9i " % (odata[1][k],)
		old_line += "|"
		if show_cpu: old_line += " %8i | %8i | %8i |" % (odata[2], odata[3], odata[4],)
		print prepend_timestamp(old_line, etime, 'fragtop')
		
	cache['history'].insert(0, (etime.as_timestamp(), pdiff, overall_cpus['system'], overall_cpus['irq'], overall_cpus['softirq'],) )
	if len(cache['history']) > history: cache['history'] = cache['history'][:history]
	cache['last']['frags'] = frags
	cache['last']['cpu'] = usage
	cache['last']['collected_on'] = etime.as_timestamp()

	sys.stdout.flush()
	return etime

if __name__ == '__main__':
	cache = {'history':[]}
	try:
		cycle(do, {
			'sshc': sshc, 
			'cache': cache,
			'history': args.history,
			'hz': args.hz,
			'raw': args.raw,
			'show_cpu': not args.no_cpu,
		}, args.collect_time, cycles_left=[args.max_cycles], debug=args.debug, interactive=args.interactive)
	except KeyboardInterrupt:
		sshc.destroy()

示例#4
0
""")


def do(sshc, process_re):
    etime = ParserCurrentTime(sshc).get()

    processes = ParserProcesses(sshc).get()
    for process in processes:
        if not process_re.search(process['cmd']): continue
        print simple_command_with_timestamp(
            sshc, etime, "fnsysctl cat /proc/%i/stack" % (process['PID'], ),
            "'%s':%i:%s" % (
                process['cmd'],
                process['PID'],
                process['state'],
            ))
        sys.stdout.flush()


if __name__ == '__main__':
    try:
        cycle(do, {
            'sshc': sshc,
            'process_re': re.compile(args.process_name),
        },
              args.cycle_time,
              cycles_left=[args.max_cycles],
              debug=args.debug)
    except KeyboardInterrupt:
        sshc.destroy()
        matched_sessions[session] = True

    # manage removed sessions
    for known in known_sessions.keys():
        if known not in matched_sessions:
            if max_age == None or gw['created_ago'] <= max_age:
                print prepend_timestamp(
                    "{deleted} " + known + " %10i" %
                    (known_sessions[known]['created_ago'], ), etime, 'ikegw')

            del known_sessions[known]


if __name__ == '__main__':
    try:
        known_sessions = {}

        cycle(do, {
            'sshc': sshc,
            'known_sessions': known_sessions,
            'status': args.status,
            'direction': args.direction,
            'max_age': args.max_age,
        },
              args.cycle_time,
              cycles_left=[args.max_cycles],
              debug=args.debug)
    except KeyboardInterrupt:
        sshc.destroy()
示例#6
0
		info['show']['tcp_sessions_active'] = True
	if args.udp_sessions_active:
		info['show']['udp_sessions_active'] = True
	if args.icmp_sessions_active:
		info['show']['icmp_sessions_active'] = True
	if args.ip_sessions_active:
		info['show']['ip_sessions_active'] = True
	if args.tcp_sessions_per_second:
		info['show']['tcp_sessions_per_second'] = True
	if args.udp_sessions_per_second:
		info['show']['udp_sessions_per_second'] = True
	if args.icmp_sessions_per_second:
		info['show']['icmp_sessions_per_second'] = True
	if args.ip_sessions_per_second:
		info['show']['ip_sessions_per_second'] = True
	if args.all_sessions_per_second:
		info['show']['all_sessions_per_second'] = True

	if args.all_counters:
		for k in info['show'].keys():
			info['show'][k] = True

	try:
		cycle(do, {
			'sshc': sshc, 
			'info': info,
		}, args.cycle_time, cycles_left=[args.max_cycles], debug=args.debug)
	except KeyboardInterrupt:
		sshc.destroy()

示例#7
0
	}
	sys.stdout.flush()
	return etime

if __name__ == '__main__':
	itype = 'each'
	if args.summarize: itype = 'total'
	elif len(args.cpu) > 0: itype = tuple(args.cpu)

	soft = True
	if args.no_soft: soft = False
	hard = True
	if args.no_hard: hard = False

	cache = {}
	try:
		cycle(do, {
			'sshc': sshc, 
			'cache': cache,
			'max_lines': args.max,
			'display_type': itype,
			'hz': args.hz,
			'soft': soft,
			'hard': hard,
			'show_zeros': args.show_zeros,
			'description': args.desc,
		}, args.collect_time, cycles_left=[args.max_cycles], debug=args.debug, interactive=args.interactive)
	except KeyboardInterrupt:
		sshc.destroy()

示例#8
0
        print p
        known['printed'] += 1


if __name__ == '__main__':
    try:
        known = {
            'iters': 0,
            'printed': 0,
            'header': None,
            'appeared': {},
        }

        cycle(do, {
            'sshc': sshc,
            'known': known,
            'status': args.status,
            'direction': args.direction,
            'phase': args.phase,
            'age': args.age,
            'use': args.use,
            'colors': not args.no_colors,
            'repeat_header': args.repeat_header,
        },
              args.cycle_time,
              cycles_left=[args.max_cycles],
              debug=args.debug)
    except KeyboardInterrupt:
        sshc.destroy()
示例#9
0
        negate = True
    else:
        ppid = args.ppid
        negate = args.negate_pid

    cache = {
        'previous': None,
    }

    try:
        cycle(do, {
            'sshc': sshc,
            'cache': cache,
            'pid_group_count': args.pid_group,
            'max_lines': args.max,
            'sort_by': args.sort_by,
            'process_name': args.process_name,
            'cpus': args.cpu,
            'states': args.state,
            'hz': args.hz,
            'ppid': ppid,
            'tpid': args.pid,
            'negate': negate,
        },
              args.collect_time,
              cycles_left=[args.max_cycles],
              debug=args.debug,
              interactive=args.interactive)
    except KeyboardInterrupt:
        sshc.destroy()
                stat['name'],
                stat['state'],
                stat['PID'],
            ))

    etime = ParserCurrentTime(sshc).get()

    for cpu in sorted(cpus.keys()):
        print "[%s] CPU#%i: %s" % (
            etime,
            cpu,
            " ".join(cpus[cpu]),
        )

    sys.stdout.flush()
    return etime


if __name__ == '__main__':
    try:
        cycle(do, {
            'sshc': sshc,
            'pid_group_count': args.pid_group,
        },
              args.cycle_time,
              cycles_left=[args.max_cycles],
              debug=args.debug,
              interactive=args.interactive)
    except KeyboardInterrupt:
        sshc.destroy()