/* * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of SIGAR. * * SIGAR is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. */ package test; import org.hyperic.sigar.*; import org.hyperic.sigar.cmd.Shell; import org.hyperic.sigar.cmd.SigarCommandBase; import org.hyperic.sigar.shell.FileCompleter; import org.hyperic.sigar.util.GetlineCompleter; import java.util.ArrayList; /** * Report filesytem disk space usage. */ public class Iostat extends SigarCommandBase { private static final String OUTPUT_FORMAT = "%-15s %-15s %10s %10s %7s %7s %5s %5s"; private static final String[] HEADER = new String[] { "Filesystem", "Mounted on", "Reads", "Writes", "R-bytes", "W-bytes", "Queue", "Svctm", }; private GetlineCompleter completer; public Iostat(Shell shell) { super(shell); setOutputFormat(OUTPUT_FORMAT); this.completer = new FileCompleter(shell); } public Iostat() { super(); setOutputFormat(OUTPUT_FORMAT); } public GetlineCompleter getCompleter() { return this.completer; } protected boolean validateArgs(String[] args) { return args.length <= 1; } public String getSyntaxArgs() { return "[filesystem]"; } public String getUsageShort() { return "Report filesystem disk i/o"; } public void printHeader() { printf(HEADER); } private String svctm(double val) { return sprintf("%3.2f", new Object[] { new Double(val) }); } public void output(String[] args) throws SigarException { if (args.length == 1) { String arg = args[0]; if ((arg.indexOf('/') != -1) || (arg.indexOf('\\') != -1)) { outputFileSystem(arg); } else { outputDisk(arg); } } else { FileSystem[] fslist = this.proxy.getFileSystemList(); printHeader(); for (int i=0; i