This commit is contained in:
Doug MacEachern committed 2009-02-09 13:28:00 -08:00
1 parent 93afe26132
commit 2e3c302f4f
7 files changed
+768 -768

No files matched your search

@@ -16,54 +16,54 @@
* USA.
*/
package org.hyperic.jni;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Copy;
public class CopyDependsTask extends Copy {
private File depends;
protected void validateAttributes()
throws BuildException {
super.validateAttributes();
if (this.depends == null) {
throw new BuildException("missing depends attribute");
}
}
public void execute()
throws BuildException {
if (this.destFile.exists()) {
String state;
if (this.depends.lastModified() >
this.destFile.lastModified())
{
this.setOverwrite(true);
state = "out of date";
}
else {
state = "up to date";
}
log(this.destFile +
" " + state + " with " +
this.depends);
}
super.execute();
}
public File getDepends() {
return this.depends;
}
public void setDepends(String depends) {
this.depends = new File(depends);
}
}
package org.hyperic.jni;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Copy;
public class CopyDependsTask extends Copy {
private File depends;
protected void validateAttributes()
throws BuildException {
super.validateAttributes();
if (this.depends == null) {
throw new BuildException("missing depends attribute");
}
}
public void execute()
throws BuildException {
if (this.destFile.exists()) {
String state;
if (this.depends.lastModified() >
this.destFile.lastModified())
{
this.setOverwrite(true);
state = "out of date";
}
else {
state = "up to date";
}
log(this.destFile +
" " + state + " with " +
this.depends);
}
super.execute();
}
public File getDepends() {
return this.depends;
}
public void setDepends(String depends) {
this.depends = new File(depends);
}
}
@@ -1,81 +1,81 @@
/*
* 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 org.hyperic.sigar.cmd;
import org.hyperic.sigar.win32.EventLog;
import org.hyperic.sigar.win32.EventLogNotification;
import org.hyperic.sigar.win32.EventLogRecord;
import org.hyperic.sigar.win32.EventLogThread;
import org.hyperic.sigar.win32.Win32Exception;
public class EventLogTail {
private static void tail(String name, Tail tail) throws Win32Exception {
EventLog log = new EventLog();
log.open(name);
int max = log.getNumberOfRecords();
if (tail.number < max) {
max = tail.number;
}
int last = log.getNewestRecord()+1;
int first = last - max;
for (int i=first; i<last; i++) {
EventLogRecord record = log.read(i);
System.out.println(record);
}
log.close();
}
private static class TailNotification implements EventLogNotification {
public void handleNotification(EventLogRecord event) {
System.out.println(event);
}
public boolean matches(EventLogRecord event) {
return true;
}
}
public static void main(String[] args) throws Exception {
Tail tail = new Tail();
tail.parseArgs(args);
if (tail.files.size() == 0) {
tail.files.add(EventLog.SYSTEM);
}
for (int i=0; i<tail.files.size(); i++) {
String name = (String)tail.files.get(i);
tail(name, tail);
if (tail.follow) {
TailNotification notifier = new TailNotification();
EventLogThread thread =
EventLogThread.getInstance(name);
thread.add(notifier);
thread.doStart();
}
}
if (tail.follow) {
System.in.read();
}
}
}
/*
* 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 org.hyperic.sigar.cmd;
import org.hyperic.sigar.win32.EventLog;
import org.hyperic.sigar.win32.EventLogNotification;
import org.hyperic.sigar.win32.EventLogRecord;
import org.hyperic.sigar.win32.EventLogThread;
import org.hyperic.sigar.win32.Win32Exception;
public class EventLogTail {
private static void tail(String name, Tail tail) throws Win32Exception {
EventLog log = new EventLog();
log.open(name);
int max = log.getNumberOfRecords();
if (tail.number < max) {
max = tail.number;
}
int last = log.getNewestRecord()+1;
int first = last - max;
for (int i=first; i<last; i++) {
EventLogRecord record = log.read(i);
System.out.println(record);
}
log.close();
}
private static class TailNotification implements EventLogNotification {
public void handleNotification(EventLogRecord event) {
System.out.println(event);
}
public boolean matches(EventLogRecord event) {
return true;
}
}
public static void main(String[] args) throws Exception {
Tail tail = new Tail();
tail.parseArgs(args);
if (tail.files.size() == 0) {
tail.files.add(EventLog.SYSTEM);
}
for (int i=0; i<tail.files.size(); i++) {
String name = (String)tail.files.get(i);
tail(name, tail);
if (tail.follow) {
TailNotification notifier = new TailNotification();
EventLogThread thread =
EventLogThread.getInstance(name);
thread.add(notifier);
thread.doStart();
}
}
if (tail.follow) {
System.in.read();
}
}
}
@@ -1,100 +1,100 @@
/*
* 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 org.hyperic.sigar.cmd;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.ProcExe;
import org.hyperic.sigar.win32.Win32;
import org.hyperic.sigar.win32.FileVersion;
/**
* Display process file information.
*/
public class FileVersionInfo extends SigarCommandBase {
public FileVersionInfo(Shell shell) {
super(shell);
}
public FileVersionInfo() {
super();
}
protected boolean validateArgs(String[] args) {
return args.length >= 1;
}
public String getUsageShort() {
return "Display file version info";
}
public void output(String[] args) throws SigarException {
for (int i=0; i<args.length; i++) {
String exe = args[i];
if (new File(exe).exists()) {
output(exe);
}
else {
long[] pids = this.shell.findPids(exe);
for (int j=0; j<pids.length; j++) {
try {
output(sigar.getProcExe(pids[j]).getName());
} catch (SigarException e) {
println(exe + ": " + e.getMessage());
}
}
}
}
}
private void output(String key, String val) {
final int max = 20;
int len = max - key.length();
StringBuffer sb = new StringBuffer();
sb.append(" ").append(key);
while (len-- > 0) {
sb.append('.');
}
sb.append(val);
println(sb.toString());
}
public void output(String exe) throws SigarException {
FileVersion info = Win32.getFileVersion(exe);
if (info == null) {
return;
}
println("Version info for file '" + exe + "':");
output("FileVersion", info.getFileVersion());
output("ProductVersion", info.getProductVersion());
for (Iterator it = info.getInfo().entrySet().iterator();
it.hasNext();)
{
Map.Entry entry = (Map.Entry)it.next();
output((String)entry.getKey(), (String)entry.getValue());
}
}
public static void main(String[] args) throws Exception {
new FileVersionInfo().processCommand(args);
}
}
/*
* 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 org.hyperic.sigar.cmd;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.ProcExe;
import org.hyperic.sigar.win32.Win32;
import org.hyperic.sigar.win32.FileVersion;
/**
* Display process file information.
*/
public class FileVersionInfo extends SigarCommandBase {
public FileVersionInfo(Shell shell) {
super(shell);
}
public FileVersionInfo() {
super();
}
protected boolean validateArgs(String[] args) {
return args.length >= 1;
}
public String getUsageShort() {
return "Display file version info";
}
public void output(String[] args) throws SigarException {
for (int i=0; i<args.length; i++) {
String exe = args[i];
if (new File(exe).exists()) {
output(exe);
}
else {
long[] pids = this.shell.findPids(exe);
for (int j=0; j<pids.length; j++) {
try {
output(sigar.getProcExe(pids[j]).getName());
} catch (SigarException e) {
println(exe + ": " + e.getMessage());
}
}
}
}
}
private void output(String key, String val) {
final int max = 20;
int len = max - key.length();
StringBuffer sb = new StringBuffer();
sb.append(" ").append(key);
while (len-- > 0) {
sb.append('.');
}
sb.append(val);
println(sb.toString());
}
public void output(String exe) throws SigarException {
FileVersion info = Win32.getFileVersion(exe);
if (info == null) {
return;
}
println("Version info for file '" + exe + "':");
output("FileVersion", info.getFileVersion());
output("ProductVersion", info.getProductVersion());
for (Iterator it = info.getInfo().entrySet().iterator();
it.hasNext();)
{
Map.Entry entry = (Map.Entry)it.next();
output((String)entry.getKey(), (String)entry.getValue());
}
}
public static void main(String[] args) throws Exception {
new FileVersionInfo().processCommand(args);
}
}
@@ -1,41 +1,41 @@
/*
* 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 org.hyperic.sigar.test;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException;
public class TestSignal extends SigarTestCase {
public TestSignal(String name) {
super(name);
}
public void testCreate() throws Exception {
String[] signals = {
"HUP", "INT", "KILL", "QUIT",
"TERM", "USR1", "USR2"
};
for (int i=0; i<signals.length; i++) {
String sig = signals[i];
traceln(sig + "=" + Sigar.getSigNum(sig));
}
}
}
/*
* 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 org.hyperic.sigar.test;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarNotImplementedException;
public class TestSignal extends SigarTestCase {
public TestSignal(String name) {
super(name);
}
public void testCreate() throws Exception {
String[] signals = {
"HUP", "INT", "KILL", "QUIT",
"TERM", "USR1", "USR2"
};
for (int i=0; i<signals.length; i++) {
String sig = signals[i];
traceln(sig + "=" + Sigar.getSigNum(sig));
}
}
}
@@ -1,64 +1,64 @@
/*
* 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 org.hyperic.sigar.win32.test;
import java.io.File;
import org.hyperic.sigar.test.SigarTestCase;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.ProcExe;
import org.hyperic.sigar.win32.Win32;
import org.hyperic.sigar.win32.FileVersion;
public class TestFileVersion extends SigarTestCase {
public TestFileVersion(String name) {
super(name);
}
private void printExe(long pid) {
traceln("\npid=" + pid);
String name;
try {
name = getSigar().getProcExe(pid).getName();
} catch (SigarException e) {
return;
}
FileVersion info = Win32.getFileVersion(name);
if (info != null) {
traceln("exe='" + name + "'");
traceln("version=" + info.getProductVersion());
}
}
public void testCreate() throws Exception {
assertTrue(Win32.getFileVersion("DoEsNoTeXist.exe") == null);
long[] pids = getSigar().getProcList();
//go through all just to make sure no crashes
for (int i=0; i<pids.length; i++) {
printExe(pids[i]);
}
}
}
/*
* 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 org.hyperic.sigar.win32.test;
import java.io.File;
import org.hyperic.sigar.test.SigarTestCase;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.ProcExe;
import org.hyperic.sigar.win32.Win32;
import org.hyperic.sigar.win32.FileVersion;
public class TestFileVersion extends SigarTestCase {
public TestFileVersion(String name) {
super(name);
}
private void printExe(long pid) {
traceln("\npid=" + pid);
String name;
try {
name = getSigar().getProcExe(pid).getName();
} catch (SigarException e) {
return;
}
FileVersion info = Win32.getFileVersion(name);
if (info != null) {
traceln("exe='" + name + "'");
traceln("version=" + info.getProductVersion());
}
}
public void testCreate() throws Exception {
assertTrue(Win32.getFileVersion("DoEsNoTeXist.exe") == null);
long[] pids = getSigar().getProcList();
//go through all just to make sure no crashes
for (int i=0; i<pids.length; i++) {
printExe(pids[i]);
}
}
}