Exemplo n.º 1
0
func uptime(fname string, opts int) {
	entries := uint64(0)
	us, err := utmp.ReadUtmp(fname, &entries, 0, opts)
	if err != nil {
		fatal.Fatalln(err)
	}

	printUptime(us)
}
Exemplo n.º 2
0
func who(fname string, opts int) {
	var users uint64
	ub := make(utmp.UtmpBuffer)

	if err := utmp.ReadUtmp(fname, users, &ub, opts); err != nil {
		log.Fatalf("%s %s\n", fname, err)
	}

	if *count {
		listEntriesWho(users, &ub)
	} else {
		scanEntries(users, &ub)
	}
}
Exemplo n.º 3
0
func users(file string, opts int) {
	utmps, err := utmp.ReadUtmp(utmp.UtmpxFile, utmp.CheckPIDs)
	if err != nil {
		log.Fatalln(err)
	}

	var names []string
	for _, u := range utmps {
		if u.IsUserProcess() {
			names = append(names, u.ExtractTrimmedName())
		}
	}
	sort.Strings(names)
	for _, name := range names {
		fmt.Println(name)
	}
}