who command

This commit is contained in:
Doug MacEachern 2005-02-22 01:52:07 +00:00
parent 921a20182d
commit db846e1557
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package net.hyperic.sigar.cmd;
import java.util.Date;
import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;
public class Who extends SigarCommandBase {
public Who(Shell shell) {
super(shell);
}
public Who() {
super();
}
public String getUsageShort() {
return "Show who is logged on";
}
public void output(String[] args) throws SigarException {
net.hyperic.sigar.Who[] who = this.sigar.getWhoList();
for (int i=0; i<who.length; i++) {
println(who[i].getUser() + "\t" +
who[i].getDevice() + "\t" +
new Date(who[i].getTime() * 1000) + "\t" +
who[i].getHost());
}
}
public static void main(String[] args) throws Exception {
new Who().processCommand(args);
}
}