You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
(927) |
Apr
(419) |
May
(352) |
Jun
(431) |
Jul
(463) |
Aug
(345) |
Sep
(304) |
Oct
(596) |
Nov
(466) |
Dec
(414) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(348) |
Feb
(313) |
Mar
(665) |
Apr
(688) |
May
(434) |
Jun
(311) |
Jul
(540) |
Aug
(554) |
Sep
(467) |
Oct
(341) |
Nov
(365) |
Dec
(272) |
| 2009 |
Jan
(386) |
Feb
(293) |
Mar
(279) |
Apr
(239) |
May
(229) |
Jun
(199) |
Jul
(186) |
Aug
(111) |
Sep
(196) |
Oct
(146) |
Nov
(116) |
Dec
(140) |
| 2010 |
Jan
(170) |
Feb
(159) |
Mar
(151) |
Apr
(161) |
May
(90) |
Jun
(56) |
Jul
(28) |
Aug
(22) |
Sep
(5) |
Oct
|
Nov
(23) |
Dec
(12) |
| 2011 |
Jan
(8) |
Feb
(8) |
Mar
(22) |
Apr
(24) |
May
(4) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
(5) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Charles L. <cl...@hy...> - 2007-03-25 05:01:32
|
Hah! Ms. Noah. We have identified a possible bug with HQ 3.0 that potentially affects Server types which get auto-discovered. It's logged as: http://jira.hyperic.com/browse/HHQ-765?page=all. Charles |
|
From: Charles L. <cl...@hy...> - 2007-03-25 04:55:59
|
Hi Devi, To integrate multiple applications for single sign-on is pretty involved. If you are looking to sign into HQ via an URL without worrying about security, then you can set that URL to: http://[HQSERVER]:7080/j_security_check.do?j_username=[USERNAME]&j_password=[PASSWORD] Charles |
|
From: Charles L. <cl...@hy...> - 2007-03-25 04:48:38
|
Actually, Thomas, When a resource is available, it is 100%. The availability value collected at any one time is either 0% or 100%. Whenever you see availability <100%, that is an average availability value over time. If you want to define an alert for when the database becomes available, you can simply set an alert up for either availability >0% or =100%. Charles |
|
From: Charles L. <cl...@hy...> - 2007-03-25 04:43:37
|
What do you mean by when there is only one alert entry in the alerts table? If you hover over the "<< Return to Alerts", can you see what the URL is? Charles |
|
From: <rm...@hy...> - 2007-03-25 04:26:02
|
Author: rmorgan Date: 2007-03-24 20:26:00 -0800 (Sat, 24 Mar 2007) New Revision: 3878 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3878 Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/LiveDataHelper.groovy Log: Adjust for livedata API change. Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/LiveDataHelper.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/LiveDataHelper.groovy 2007-03-25 04:25:34 UTC (rev 3877) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/LiveDataHelper.groovy 2007-03-25 04:26:00 UTC (rev 3878) @@ -4,7 +4,7 @@ import org.hyperic.util.config.ConfigResponse import org.hyperic.hq.livedata.server.session.LiveDataManagerEJBImpl import org.hyperic.hq.livedata.shared.LiveDataResult -import org.json.JSONArray +import org.hyperic.hq.livedata.shared.LiveDataCommand class LiveDataHelper extends BaseHelper @@ -21,9 +21,10 @@ LiveDataResult getData(AppdefResourceValue resource, String command, config) - { - dataMan.getData(userVal, resource.entityId, command, - config as ConfigResponse) + { + LiveDataCommand cmd = new LiveDataCommand(resource.entityId, command, + config as ConfigResponse) + dataMan.getData(userVal, cmd) } } |
|
From: <rm...@hy...> - 2007-03-25 04:25:37
|
Author: rmorgan Date: 2007-03-24 20:25:34 -0800 (Sat, 24 Mar 2007) New Revision: 3877 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3877 Added: trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutor.java trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutorCommand.java trunk/src/org/hyperic/hq/livedata/shared/LiveDataCommand.java Modified: trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShellEntityFetcher.java trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_livedata_get.java trunk/src/org/hyperic/hq/bizapp/server/session/LiveDataBossEJBImpl.java trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java trunk/src/org/hyperic/hq/livedata/server/session/LiveDataManagerEJBImpl.java trunk/src/org/hyperic/hq/livedata/shared/LiveDataResult.java Log: Add batch processing for livedata commands. Commands are bucketed by agent connection and executed in parallel using a ThreadPoolExecutor. Modified: trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShellEntityFetcher.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShellEntityFetcher.java 2007-03-25 04:24:27 UTC (rev 3876) +++ trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShellEntityFetcher.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -119,6 +119,7 @@ import org.hyperic.hq.scheduler.ScheduleValue; import org.hyperic.hq.livedata.shared.LiveDataException; import org.hyperic.hq.livedata.shared.LiveDataResult; +import org.hyperic.hq.livedata.shared.LiveDataCommand; import org.hyperic.util.ConfigPropertyException; import org.hyperic.util.StringUtil; import org.hyperic.util.config.ConfigResponse; @@ -1160,21 +1161,32 @@ return (0 == numInvalid); } - public LiveDataResult getLiveData(AppdefEntityID id, String command, - ConfigResponse config) + public LiveDataResult getLiveData(LiveDataCommand command) throws NamingException, ClientShellAuthenticationException, - PermissionException, AgentConnectionException, RemoteException, - AgentRemoteException, AgentNotFoundException, LiveDataException, - AppdefEntityNotFoundException, SessionTimeoutException, - SessionNotFoundException + PermissionException, RemoteException, AgentNotFoundException, + LiveDataException, AppdefEntityNotFoundException, + SessionTimeoutException, SessionNotFoundException { LiveDataBoss boss; boss = this.bossManager.getLiveDataBoss(); - return boss.getLiveData(auth.getAuthToken(), id, command, config); + return boss.getLiveData(auth.getAuthToken(), command); } + public LiveDataResult[] getLiveData(LiveDataCommand[] commands) + throws NamingException, ClientShellAuthenticationException, + PermissionException, RemoteException, AgentNotFoundException, + LiveDataException, AppdefEntityNotFoundException, + SessionTimeoutException, SessionNotFoundException + { + LiveDataBoss boss; + + boss = this.bossManager.getLiveDataBoss(); + + return boss.getLiveData(auth.getAuthToken(), commands); + } + public String[] getLiveDataCommands(AppdefEntityID id) throws RemoteException, NamingException, ClientShellAuthenticationException, PluginException, Modified: trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_livedata_get.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_livedata_get.java 2007-03-25 04:24:27 UTC (rev 3876) +++ trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_livedata_get.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -32,7 +32,10 @@ import org.hyperic.util.config.ConfigSchema; import org.hyperic.hq.appdef.shared.AppdefEntityID; import org.hyperic.hq.livedata.shared.LiveDataResult; +import org.hyperic.hq.livedata.shared.LiveDataCommand; +import java.io.PrintStream; + public class ClientShell_livedata_get extends ShellCommandBase { private static final int[] PARAM_VALID_RESOURCE = { @@ -64,13 +67,16 @@ ConfigResponse response = ((ClientShell)this.getShell()).processConfigSchema(schema); - LiveDataResult res = _entityFetcher.getLiveData(id, args[2], - response); + LiveDataCommand cmd = new LiveDataCommand(id, args[2], response); + LiveDataResult res = _entityFetcher.getLiveData(cmd); - this.getShell().getOutStream().println("Printing XML output from " + - args[2] + " command:"); - this.getShell().getOutStream().println(res.getXMLResult()); - + PrintStream ps = this.getShell().getOutStream(); + ps.println("Printing XML output from " + args[2] + " command:"); + if (res.hasError()) { + ps.println("Error: " + res.getErrorMessage()); + } else { + ps.println(res.getXMLResult()); + } } catch (Exception e) { throw new ShellCommandExecException(e); } Modified: trunk/src/org/hyperic/hq/bizapp/server/session/LiveDataBossEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/server/session/LiveDataBossEJBImpl.java 2007-03-25 04:24:27 UTC (rev 3876) +++ trunk/src/org/hyperic/hq/bizapp/server/session/LiveDataBossEJBImpl.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -35,6 +35,7 @@ import org.hyperic.hq.livedata.shared.LiveDataException; import org.hyperic.hq.livedata.shared.LiveDataManagerLocal; import org.hyperic.hq.livedata.shared.LiveDataResult; +import org.hyperic.hq.livedata.shared.LiveDataCommand; import org.hyperic.hq.livedata.server.session.LiveDataManagerEJBImpl; import org.hyperic.hq.product.PluginException; import org.hyperic.hq.auth.shared.SessionManager; @@ -76,19 +77,33 @@ * * @ejb:interface-method */ - public LiveDataResult getLiveData(int sessionId, AppdefEntityID id, - String command, ConfigResponse config) - throws PermissionException, AgentConnectionException, - AgentRemoteException, AgentNotFoundException, - AppdefEntityNotFoundException, LiveDataException, - SessionTimeoutException, SessionNotFoundException + public LiveDataResult getLiveData(int sessionId, LiveDataCommand command) + throws PermissionException, AgentNotFoundException, + AppdefEntityNotFoundException, LiveDataException, + SessionTimeoutException, SessionNotFoundException { AuthzSubjectValue subject = _manager.getSubject(sessionId); LiveDataManagerLocal manager = LiveDataManagerEJBImpl.getOne(); - return manager.getData(subject, id, command, config); + return manager.getData(subject, command); } /** + * Get live data for the given commands + * + * @ejb:interface-method + */ + public LiveDataResult[] getLiveData(int sessionId, + LiveDataCommand[] commands) + throws PermissionException, AgentNotFoundException, + AppdefEntityNotFoundException, LiveDataException, + SessionTimeoutException, SessionNotFoundException + { + AuthzSubjectValue subject = _manager.getSubject(sessionId); + LiveDataManagerLocal manager = LiveDataManagerEJBImpl.getOne(); + return manager.getData(subject, commands); + } + + /** * Get the commands for a given resource. * * @ejb:interface-method Modified: trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java 2007-03-25 04:24:27 UTC (rev 3876) +++ trunk/src/org/hyperic/hq/livedata/agent/client/LiveDataClient.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -28,40 +28,37 @@ import org.hyperic.hq.livedata.agent.LiveDataCommandsAPI; import org.hyperic.hq.livedata.agent.commands.LiveData_args; import org.hyperic.hq.livedata.agent.commands.LiveData_result; -import org.hyperic.hq.livedata.shared.LiveDataException; import org.hyperic.hq.livedata.shared.LiveDataResult; import org.hyperic.hq.agent.client.AgentConnection; -import org.hyperic.hq.agent.AgentConnectionException; -import org.hyperic.hq.agent.AgentRemoteException; import org.hyperic.hq.agent.AgentRemoteValue; import org.hyperic.util.config.ConfigResponse; public class LiveDataClient { private LiveDataCommandsAPI _api; - private AgentConnection _agentConnection; + private AgentConnection _conn; public LiveDataClient(AgentConnection agentConnection) { - _agentConnection = agentConnection; + _conn = agentConnection; _api = new LiveDataCommandsAPI(); } public LiveDataResult getData(String type, String command, ConfigResponse config) - throws AgentConnectionException, AgentRemoteException, - LiveDataException { - LiveData_args args = new LiveData_args(); + try { + LiveData_args args = new LiveData_args(); - args.setConfig(type, command, config); + args.setConfig(type, command, config); - AgentRemoteValue res = - _agentConnection.sendCommand(LiveDataCommandsAPI.command_getData, - _api.getVersion(), args); - LiveData_result val = new LiveData_result(res); - - String xml = val.getResult(); - - return new LiveDataResult(xml); + AgentRemoteValue res = + _conn.sendCommand(LiveDataCommandsAPI.command_getData, + _api.getVersion(), args); + LiveData_result val = new LiveData_result(res); + String xml = val.getResult(); + return new LiveDataResult(xml); + } catch (Exception e) { + return new LiveDataResult(e, e.getMessage()); + } } } Added: trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutor.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutor.java (rev 0) +++ trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutor.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -0,0 +1,93 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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.hq.livedata.server.session; + +import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor; +import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit; +import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue; +import org.hyperic.hq.livedata.agent.client.LiveDataClient; +import org.hyperic.hq.livedata.shared.LiveDataResult; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; +import java.util.ArrayList; +import java.util.Iterator; + +public class LiveDataExecutor extends ThreadPoolExecutor { + + private static Log _log = LogFactory.getLog(LiveDataExecutor.class); + + private static final int THREAD_MIN = 1; + private static final int THREAD_MAX = 30; + + private List _results; + + public LiveDataExecutor() { + super(THREAD_MIN, THREAD_MAX, 1, TimeUnit.HOURS, + new LinkedBlockingQueue()); + _results = new ArrayList(); + } + + public void getData(LiveDataClient client, List commands) { + execute(new LiveDataGatherer(client, commands)); + } + + public LiveDataResult[] getResult() { + try { + awaitTermination(1, TimeUnit.MINUTES); + } catch (InterruptedException e) { + _log.warn("Executor interrputed!"); + } + + _log.debug("Returning results for " + _results.size() + " elements"); + return (LiveDataResult[])_results.toArray(new LiveDataResult[0]); + } + + private class LiveDataGatherer implements Runnable { + + private LiveDataClient _client; + private List _commands; + + LiveDataGatherer(LiveDataClient client, List commands) { + _client = client; + _commands = commands; + } + + public void run() { + _log.debug("Starting gather thread..."); + for (Iterator i = _commands.iterator(); i.hasNext(); ) { + LiveDataExecutorCommand cmd = (LiveDataExecutorCommand)i.next(); + _log.debug("Running cmd '" + cmd + "' in thread " + + Thread.currentThread().getName()); + LiveDataResult res = _client.getData(cmd.getType(), + cmd.getCommand(), + cmd.getConfig()); + _results.add(res); + } + } + } +} Added: trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutorCommand.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutorCommand.java (rev 0) +++ trunk/src/org/hyperic/hq/livedata/server/session/LiveDataExecutorCommand.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -0,0 +1,53 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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.hq.livedata.server.session; + +import org.hyperic.util.config.ConfigResponse; + +class LiveDataExecutorCommand { + private String _type; + private String _command; + private ConfigResponse _config; + + public LiveDataExecutorCommand(String type, String command, + ConfigResponse config) { + _type = type; + _command = command; + _config = config; + } + + public String getType() { + return _type; + } + + public String getCommand() { + return _command; + } + + public ConfigResponse getConfig() { + return _config; + } +} Modified: trunk/src/org/hyperic/hq/livedata/server/session/LiveDataManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/server/session/LiveDataManagerEJBImpl.java 2007-03-25 04:24:27 UTC (rev 3876) +++ trunk/src/org/hyperic/hq/livedata/server/session/LiveDataManagerEJBImpl.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -43,18 +43,22 @@ import org.hyperic.hq.appdef.server.session.ConfigManagerEJBImpl; import org.hyperic.hq.authz.shared.PermissionException; import org.hyperic.hq.authz.shared.AuthzSubjectValue; -import org.hyperic.hq.agent.AgentConnectionException; -import org.hyperic.hq.agent.AgentRemoteException; import org.hyperic.hq.common.SystemException; import org.hyperic.hq.livedata.shared.LiveDataManagerLocal; import org.hyperic.hq.livedata.shared.LiveDataManagerUtil; import org.hyperic.hq.livedata.shared.LiveDataException; import org.hyperic.hq.livedata.shared.LiveDataResult; +import org.hyperic.hq.livedata.shared.LiveDataCommand; +import org.hyperic.hq.agent.client.AgentConnection; import org.hyperic.util.config.ConfigResponse; import org.hyperic.util.config.ConfigSchema; import javax.ejb.SessionContext; import javax.ejb.SessionBean; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Iterator; /** * @ejb:bean name="LiveDataManager" @@ -98,44 +102,100 @@ /** * Live data subsystem uses measurement configs. */ - private ConfigResponse getMeasurementConfig(AuthzSubjectValue subject, - AppdefEntityID id) + private ConfigResponse getConfig(AuthzSubjectValue subject, + LiveDataCommand command) throws LiveDataException { ConfigManagerLocal cManager = ConfigManagerEJBImpl.getOne(); try { - return cManager.getMergedConfigResponse(subject, - ProductPlugin.TYPE_MEASUREMENT, - id, true); + AppdefEntityID id = command.getAppdefEntityID(); + ConfigResponse config = command.getConfig(); + ConfigResponse mConfig = cManager. + getMergedConfigResponse(subject, ProductPlugin.TYPE_MEASUREMENT, + id, true); + config.merge(mConfig, false); + return config; } catch (Exception e) { throw new LiveDataException(e); } } /** - * Get live data for a given resource. + * Get the appdef type for a given entity id. + */ + private String getType(AuthzSubjectValue subject, LiveDataCommand cmd) + throws AppdefEntityNotFoundException, PermissionException + { + AppdefEntityID id = cmd.getAppdefEntityID(); + AppdefEntityValue val = new AppdefEntityValue(id, subject); + AppdefResourceTypeValue typeVal = val.getResourceTypeValue(); + return typeVal.getName(); + } + + /** + * Run the given live data command. * * @ejb:interface-method */ public LiveDataResult getData(AuthzSubjectValue subject, - AppdefEntityID id, String command, - ConfigResponse config) + LiveDataCommand cmd) throws PermissionException, AgentNotFoundException, - AgentConnectionException, AgentRemoteException, - AppdefEntityNotFoundException, LiveDataException + AppdefEntityNotFoundException, LiveDataException { - LiveDataClient client = - new LiveDataClient(AgentConnectionUtil.getClient(id)); + AppdefEntityID id = cmd.getAppdefEntityID(); + AgentConnection conn = AgentConnectionUtil.getClient(id); + LiveDataClient client = new LiveDataClient(conn); - ConfigResponse measurementConfig = getMeasurementConfig(subject, id); + ConfigResponse config = getConfig(subject, cmd); + String type = getType(subject, cmd); - config.merge(measurementConfig, false); - - AppdefEntityValue val = new AppdefEntityValue(id, subject); - AppdefResourceTypeValue tVal = val.getResourceTypeValue(); + return client.getData(type, cmd.getCommand(), config); + } - return client.getData(tVal.getName(), command, config); + /** + * Run a list of live data commands in batch. + * + * @ejb:interface-method + */ + public LiveDataResult[] getData(AuthzSubjectValue subject, + LiveDataCommand[] commands) + throws PermissionException, AppdefEntityNotFoundException, + AgentNotFoundException, LiveDataException + { + HashMap buckets = new HashMap(); + + for (int i = 0; i < commands.length; i++) { + LiveDataCommand cmd = commands[i]; + AppdefEntityID id = cmd.getAppdefEntityID(); + AgentConnection conn = AgentConnectionUtil.getClient(id); + + ConfigResponse config = getConfig(subject, cmd); + String type = getType(subject, cmd); + + LiveDataExecutorCommand exec = + new LiveDataExecutorCommand(type, cmd.getCommand(), config); + + List queue = (List)buckets.get(conn); + if (queue == null) { + queue = new ArrayList(); + queue.add(exec); + buckets.put(conn, queue); + } else { + queue.add(exec); + } + } + + LiveDataExecutor executor = new LiveDataExecutor(); + for (Iterator i = buckets.keySet().iterator(); i.hasNext(); ) { + AgentConnection conn = (AgentConnection)i.next(); + List cmds = (List)buckets.get(conn); + executor.getData(new LiveDataClient(conn), cmds); + } + + executor.shutdown(); + + return executor.getResult(); } /** Added: trunk/src/org/hyperic/hq/livedata/shared/LiveDataCommand.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/shared/LiveDataCommand.java (rev 0) +++ trunk/src/org/hyperic/hq/livedata/shared/LiveDataCommand.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -0,0 +1,61 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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.hq.livedata.shared; + +import org.hyperic.util.config.ConfigResponse; +import org.hyperic.hq.appdef.shared.AppdefEntityID; + +import java.io.Serializable; + +public class LiveDataCommand implements Serializable { + + private AppdefEntityID _id; + private String _command; + private ConfigResponse _config; + + public LiveDataCommand(AppdefEntityID id, String command, + ConfigResponse config) { + _id = id; + _command = command; + _config = config; + } + + public AppdefEntityID getAppdefEntityID() { + return _id; + } + + public String getCommand() { + return _command; + } + + public ConfigResponse getConfig() { + return _config; + } + + public String toString() { + return _id + ":" + _command; + } +} Modified: trunk/src/org/hyperic/hq/livedata/shared/LiveDataResult.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/shared/LiveDataResult.java 2007-03-25 04:24:27 UTC (rev 3876) +++ trunk/src/org/hyperic/hq/livedata/shared/LiveDataResult.java 2007-03-25 04:25:34 UTC (rev 3877) @@ -9,12 +9,22 @@ */ public class LiveDataResult implements Serializable { + private boolean _error; + private Throwable _cause; + private String _errorMsg; private String _xml; public LiveDataResult(String xml) { + _error = false; _xml = xml; } + public LiveDataResult(Throwable t, String errorMsg) { + _error = true; + _errorMsg = errorMsg; + _cause = t; + } + /** * Get the raw XML result for this request. */ @@ -29,4 +39,26 @@ XStream xstream = new XStream(); return xstream.fromXML(_xml); } + + /** + * Get the error (if it exists) for this command. Not always guaranteed + * to be non-null if hasError() is true. + */ + public Throwable getCause() { + return _cause; + } + + /** + * Get the error string for this result. + */ + public String getErrorMessage() { + return _errorMsg; + } + + /** + * True if an error occured collecting the live data + */ + public boolean hasError() { + return _error; + } } |
|
From: <rm...@hy...> - 2007-03-25 04:24:30
|
Author: rmorgan Date: 2007-03-24 20:24:27 -0800 (Sat, 24 Mar 2007) New Revision: 3876 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3876 Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy Log: Fix resource id parsing. Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy 2007-03-25 03:57:59 UTC (rev 3875) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy 2007-03-25 04:24:27 UTC (rev 3876) @@ -88,7 +88,7 @@ def argType = (resourceVal instanceof String) ? 'str' : 'int' try { // If it's a string with an integer inside, try that - resourceVal = Integer.parseInt(resourceVal) + resourceVal = Integer.valueOf(resourceVal) argType = 'int' } catch(NumberFormatException e) { } |
|
From: <rm...@hy...> - 2007-03-25 03:58:02
|
Author: rmorgan Date: 2007-03-24 19:57:59 -0800 (Sat, 24 Mar 2007) New Revision: 3875 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3875 Modified: trunk/src/org/hyperic/hq/livedata/agent/server/LiveDataCommandsServer.java Log: Include error message on error. Modified: trunk/src/org/hyperic/hq/livedata/agent/server/LiveDataCommandsServer.java =================================================================== --- trunk/src/org/hyperic/hq/livedata/agent/server/LiveDataCommandsServer.java 2007-03-25 02:42:01 UTC (rev 3874) +++ trunk/src/org/hyperic/hq/livedata/agent/server/LiveDataCommandsServer.java 2007-03-25 03:57:59 UTC (rev 3875) @@ -97,7 +97,8 @@ res.setResult(s); return res; } catch (Exception e) { - throw new AgentRemoteException("Unable to invoke command", e); + throw new AgentRemoteException("Unable to invoke command: " + + e.getMessage(), e); } } } |
|
From: <do...@hy...> - 2007-03-25 02:42:38
|
Author: dougm Date: 2007-03-24 18:42:01 -0800 (Sat, 24 Mar 2007) New Revision: 3874 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3874 Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetConnectionData.java trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetstatData.java Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java Log: add netstat livedata command Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetConnectionData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetConnectionData.java (rev 0) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetConnectionData.java 2007-03-25 02:42:01 UTC (rev 3874) @@ -0,0 +1,164 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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. + */ +//XXX move this class to sigar +package org.hyperic.hq.plugin.system; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.hyperic.sigar.NetConnection; +import org.hyperic.sigar.NetFlags; +import org.hyperic.sigar.NetServices; +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; + +public class NetConnectionData { + + private NetConnection _conn; + private boolean _isNumeric; + private String _proto; + private int _maxLocalAddrLen = -1; + private int _maxRemoteAddrLen = -1; + private long _processPid = -1; + private String _processName; + + public NetConnectionData(NetConnection conn, + boolean isNumeric) { + _conn = conn; + _isNumeric = isNumeric; + _proto = conn.getTypeString(); + } + + public void setMaxLocalAddrLen(int len) { + _maxLocalAddrLen = len; + } + + public void setMaxRemoteAddrLen(int len) { + _maxRemoteAddrLen = len; + } + + public String getProtocol() { + return _proto; + } + + public String getFormattedPort(long port) { + if (port == 0) { + return "*"; + } + if (!_isNumeric) { + String service = + NetServices.getName(_proto, port); + if (service != null) { + return service; + } + } + + return String.valueOf(port); + } + + public String getFormattedAddress(String ip, + long port, + int max) { + + String fport = getFormattedPort(port); + String address; + + if (NetFlags.isAnyAddress(ip)) { + address = "*"; + } + else if (_isNumeric) { + address = ip; + } + else { + try { + address = InetAddress.getByName(ip).getHostName(); + } catch (UnknownHostException e) { + address = ip; + } + } + + if (max != -1) { + max -= fport.length() + 1; + if (address.length() > max) { + address = address.substring(0, max); + } + } + + return address + ":" + fport; + } + + public String getFormattedLocalAddress() { + return getFormattedAddress(_conn.getLocalAddress(), + _conn.getLocalPort(), + _maxLocalAddrLen); + } + + public String getFormattedRemoteAddress() { + return getFormattedAddress(_conn.getRemoteAddress(), + _conn.getRemotePort(), + _maxRemoteAddrLen); + } + + public String getFormattedState() { + if (_conn.getType() == NetFlags.CONN_UDP) { + return ""; + } + else { + return _conn.getStateString(); + } + } + + public long getProcessPid() { + return _processPid; + } + + public String getProcessName() { + return _processName; + } + + public String getFormattedProcessName() { + if (_processPid == -1) { + return ""; + } + return _processPid + "/" + _processName; + } + + public void lookupProcessInfo(Sigar sigar) { + if (_conn.getState() != NetFlags.TCP_LISTEN) { + return; + } + try { + long pid = + sigar.getProcPort(_conn.getType(), + _conn.getLocalPort()); + if (pid != 0) { //XXX another bug + _processPid = pid; + _processName = + sigar.getProcState(pid).getName(); + } + } catch (SigarException e) { + } + } +} Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetstatData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetstatData.java (rev 0) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/NetstatData.java 2007-03-25 02:42:01 UTC (rev 3874) @@ -0,0 +1,181 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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. + */ +//XXX move this class to sigar +package org.hyperic.hq.plugin.system; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; + +import org.hyperic.sigar.NetConnection; +import org.hyperic.sigar.NetFlags; +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; + +public class NetstatData { + public static final String LABEL_PROTO = "Proto"; + public static final String LABEL_LADDR = "Local Address"; + public static final String LABEL_RADDR = "Foreign Address"; + public static final String LABEL_STATE = "State"; + + private boolean _isNumeric = false; + private boolean _wantPid = false; + private int _flags = + NetFlags.CONN_CLIENT | NetFlags.CONN_PROTOCOLS; + private List _connections; + + public NetstatData() {} + + public void populate(Sigar sigar) throws SigarException { + _connections = new ArrayList(); + NetConnection[] connections = + sigar.getNetConnectionList(_flags); + + for (int i=0; i<connections.length; i++) { + NetConnectionData data = + new NetConnectionData(connections[i], _isNumeric); + + if (_wantPid) { + data.lookupProcessInfo(sigar); + } + + _connections.add(data); + } + } + + public List getConnections() { + return _connections; + } + + public boolean isNumeric() { + return _isNumeric; + } + + public void setIsNumeric(boolean isNumeric) { + _isNumeric = isNumeric; + } + + public boolean wantPid() { + return _wantPid; + } + + public void setWantPid(boolean wantPid) { + _wantPid = wantPid; + } + + public int getFlags() { + return _flags; + } + + public void setFlags(int flags) { + _flags = flags; + } + + public void setFlags(String flags) { + setFlags(new String[] { flags }); + } + + public void setFlags(String[] args) { + int proto_flags = 0; + + for (int i=0; i<args.length; i++) { + String arg = args[i]; + int j = 0; + + while (j<arg.length()) { + switch (arg.charAt(j++)) { + case '-': + continue; + case 'l': + _flags &= ~NetFlags.CONN_CLIENT; + _flags |= NetFlags.CONN_SERVER; + break; + case 'a': + _flags |= NetFlags.CONN_SERVER | NetFlags.CONN_CLIENT; + break; + case 'n': + _isNumeric = true; + break; + case 'p': + _wantPid = true; + break; + case 't': + proto_flags |= NetFlags.CONN_TCP; + break; + case 'u': + proto_flags |= NetFlags.CONN_UDP; + break; + case 'w': + proto_flags |= NetFlags.CONN_RAW; + break; + case 'x': + proto_flags |= NetFlags.CONN_UNIX; + break; + default: + } + } + } + + if (proto_flags != 0) { + _flags &= ~NetFlags.CONN_PROTOCOLS; + _flags |= proto_flags; + } + } + + public void print(PrintStream out) { + final String header = + LABEL_PROTO + "\t" + + LABEL_LADDR + "\t" + + LABEL_RADDR + "\t" + + LABEL_STATE; + out.println(header); + + List connections = getConnections(); + for (int i=0; i<connections.size(); i++) { + NetConnectionData data = + (NetConnectionData)connections.get(i); + + String conn = + data.getProtocol() + "\t" + + data.getFormattedLocalAddress() + "\t" + + data.getFormattedRemoteAddress() + "\t" + + data.getFormattedState() + "\t" + + data.getFormattedProcessName(); + + out.println(conn); + } + } + + public static void main(String[] args) throws Exception { + Sigar sigar = new Sigar(); + NetstatData data = new NetstatData(); + if (args.length != 0) { + data.setFlags(args); + } + data.populate(sigar); + data.print(System.out); + sigar.close(); + } +} Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java 2007-03-25 00:08:05 UTC (rev 3873) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java 2007-03-25 02:42:01 UTC (rev 3874) @@ -40,13 +40,15 @@ private static final String CMD_CPUPERC = "cpuperc"; private static final String CMD_FILESYSTEM = "filesystem"; private static final String CMD_TOP = "top"; + private static final String CMD_NETSTAT = "netstat"; private static final String _COMMANDS[] = { CMD_CPUINFO, CMD_CPU, CMD_CPUPERC, CMD_FILESYSTEM, - CMD_TOP + CMD_TOP, + CMD_NETSTAT }; public Object getData(String command, ConfigResponse config) @@ -67,6 +69,14 @@ String filter = config.getValue(SigarMeasurementPlugin.PTQL_CONFIG); return TopData.gather(sigar, filter); + } else if (command.equals(CMD_NETSTAT)) { + NetstatData data = new NetstatData(); + String flags = config.getValue("netstat.flags"); + if (flags != null) { + data.setFlags(flags); + } + data.populate(sigar); + return data; } else { throw new PluginException("Unknown command '" + command + "'"); } |
|
From: <rm...@hy...> - 2007-03-25 00:08:09
|
Author: rmorgan Date: 2007-03-24 16:08:05 -0800 (Sat, 24 Mar 2007) New Revision: 3873 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3873 Modified: trunk/src/org/hyperic/hq/agent/client/AgentConnection.java Log: Add equals() and hashCode(). Modified: trunk/src/org/hyperic/hq/agent/client/AgentConnection.java =================================================================== --- trunk/src/org/hyperic/hq/agent/client/AgentConnection.java 2007-03-24 23:19:21 UTC (rev 3872) +++ trunk/src/org/hyperic/hq/agent/client/AgentConnection.java 2007-03-25 00:08:05 UTC (rev 3873) @@ -68,6 +68,14 @@ _agentAPI = new AgentAPI(); } + public String getAgentAddress() { + return _agentAddress; + } + + public int getAgentPort() { + return _agentPort; + } + protected Socket getSocket() throws AgentConnectionException { @@ -213,4 +221,14 @@ } } } + + public boolean equals(Object o) { + return o instanceof AgentConnection && + ((AgentConnection)o).getAgentAddress().equals(getAgentAddress()) && + ((AgentConnection)o).getAgentPort() == getAgentPort(); + } + + public int hashCode() { + return getAgentAddress().hashCode() + getAgentPort(); + } } |
|
From: Jon T. <jt...@hy...> - 2007-03-24 23:54:14
|
Josh, Have you configured your SMTP server? Check out this page: http://support.hyperic.com/confluence/display/DOCSHQ30/SMTP+server Though I would expect you'd get errors in your logs if you hadn't set it up. -- Jon On Mar 24, 2007, at 4:47 PM, Josh Jondle wrote: > Hello, > I've went through a bunch of the links in the documentation > and I can't find the answer to my question. > > My email alerts don't work. I assume it needs further > configuration or something but I don't see any documentation that > tells how to get it working. I get my alerts in the interface, but > I don't receive my email alert that I've set up and I've checked my > junk mail to make sure it's not getting stuck there. Can you tell > me how to get that working? > > > > Thanks, > > Josh > |
|
From: Josh J. <jj...@gc...> - 2007-03-24 23:48:09
|
Hello,
I've went through a bunch of the links in the documentation and I can't find the answer to my question.
My email alerts don't work. I assume it needs further configuration or something but I don't see any documentation that tells how to get it working. I get my alerts in the interface, but I don't receive my email alert that I've set up and I've checked my junk mail to make sure it's not getting stuck there. Can you tell me how to get that working?
Thanks,
Josh
|
|
From: <do...@hy...> - 2007-03-24 23:19:24
|
Author: dougm Date: 2007-03-24 15:19:21 -0800 (Sat, 24 Mar 2007) New Revision: 3872 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3872 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java Log: improve sec formating Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 22:57:36 UTC (rev 3871) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 23:19:21 UTC (rev 3872) @@ -232,7 +232,11 @@ return NA; } long t = total / 1000; - return t/60 + ":" + t%60; + String sec = String.valueOf(t%60); + if (sec.length() == 1) { + sec = "0" + sec; + } + return t/60 + ":" + sec; } public String getFormattedCpuPerc() { |
|
From: <do...@hy...> - 2007-03-24 22:57:40
|
Author: dougm Date: 2007-03-24 14:57:36 -0800 (Sat, 24 Mar 2007) New Revision: 3871 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3871 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java Log: try both file seps Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 22:49:27 UTC (rev 3870) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 22:57:36 UTC (rev 3871) @@ -25,7 +25,6 @@ //XXX move this class to sigar package org.hyperic.hq.plugin.system; -import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; @@ -178,8 +177,11 @@ } public String getBaseName() { - int ix = _name.lastIndexOf(File.separator); + int ix = _name.lastIndexOf("/"); if (ix == -1) { + ix = _name.lastIndexOf("\\"); + } + if (ix == -1) { return _name; } else { |
|
From: <do...@hy...> - 2007-03-24 22:49:40
|
Author: dougm Date: 2007-03-24 14:49:27 -0800 (Sat, 24 Mar 2007) New Revision: 3870 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3870 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java Log: add getBaseName method Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 21:39:10 UTC (rev 3869) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 22:49:27 UTC (rev 3870) @@ -25,6 +25,7 @@ //XXX move this class to sigar package org.hyperic.hq.plugin.system; +import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; @@ -176,6 +177,16 @@ return _name; } + public String getBaseName() { + int ix = _name.lastIndexOf(File.separator); + if (ix == -1) { + return _name; + } + else { + return _name.substring(ix+1); + } + } + public String getFormattedStartTime() { return getFormattedStartTime(_startTime); } @@ -240,7 +251,7 @@ _state + delim + getFormattedCpuTotal() + delim + getFormattedCpuPerc() + delim + - _name; + getBaseName(); } public String toString() { |
|
From: <do...@hy...> - 2007-03-24 21:39:11
|
Author: dougm Date: 2007-03-24 13:39:10 -0800 (Sat, 24 Mar 2007) New Revision: 3869 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3869 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java Log: add print+main methods Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java 2007-03-24 21:38:33 UTC (rev 3868) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java 2007-03-24 21:39:10 UTC (rev 3869) @@ -25,6 +25,7 @@ //XXX move this class to sigar package org.hyperic.hq.plugin.system; +import java.io.PrintStream; import java.util.ArrayList; import java.util.List; @@ -110,4 +111,34 @@ public List getProcesses() { return _processes; } + + public void print(PrintStream out) { + out.println(getUptime()); + out.println(getCurrentProcessSummary()); + out.println(getCpu()); + out.println(getMem()); + out.println(getSwap()); + out.println(); + out.println(ProcessData.PS_HEADER); + List processes = getProcesses(); + for (int i=0; i<processes.size(); i++) { + ProcessData process = (ProcessData)processes.get(i); + out.println(process.toString("\t")); + } + } + + public static void main(String[] args) throws Exception { + String filter; + if (args.length == 1) { + filter = args[0]; + } + else { + filter = null; + } + + Sigar sigar = new Sigar(); + TopData top = TopData.gather(sigar, filter); + top.print(System.out); + sigar.close(); + } } |
|
From: <do...@hy...> - 2007-03-24 21:38:36
|
Author: dougm Date: 2007-03-24 13:38:33 -0800 (Sat, 24 Mar 2007) New Revision: 3868 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3868 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java Log: add formatting helpers Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 21:12:27 UTC (rev 3867) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 21:38:33 UTC (rev 3868) @@ -25,6 +25,10 @@ //XXX move this class to sigar package org.hyperic.hq.plugin.system; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.hyperic.sigar.CpuPerc; import org.hyperic.sigar.ProcCpu; import org.hyperic.sigar.ProcCredName; import org.hyperic.sigar.ProcMem; @@ -35,7 +39,31 @@ import org.hyperic.sigar.SigarException; public class ProcessData { + public static final String NA = "-"; + public static final String LABEL_PID = "PID"; + public static final String LABEL_USER = "USER"; + public static final String LABEL_STIME = "STIME"; + public static final String LABEL_SIZE = "SIZE"; + public static final String LABEL_RSS = "RSS"; + public static final String LABEL_SHARE = "SHARE"; + public static final String LABEL_STATE = "STATE"; + public static final String LABEL_TIME = "TIME"; + public static final String LABEL_CPU = "%CPU"; + public static final String LABEL_NAME = "COMMAND"; + + public static final String PS_HEADER = + LABEL_PID + "\t" + + LABEL_USER + "\t" + + LABEL_STIME + "\t" + + LABEL_SIZE + "\t" + + LABEL_RSS + "\t" + + LABEL_SHARE + "\t" + + LABEL_STATE + "\t" + + LABEL_TIME + "\t" + + LABEL_CPU + "\t" + + LABEL_NAME; + private long _pid; private String _owner; private long _startTime; @@ -147,4 +175,75 @@ public String getName() { return _name; } + + public String getFormattedStartTime() { + return getFormattedStartTime(_startTime); + } + + public static String getFormattedStartTime(long time) { + if (time == 0) { + return "00:00"; + } + else if (time == Sigar.FIELD_NOTIMPL) { + return NA; + } + + long timeNow = System.currentTimeMillis(); + String fmt = "MMMd"; + + if ((timeNow - time) < ((60*60*24) * 1000)) { + fmt = "HH:mm"; + } + + return new SimpleDateFormat(fmt).format(new Date(time)); + } + + public String getFormattedSize() { + return Sigar.formatSize(_size); + } + + public String getFormattedShare() { + return Sigar.formatSize(_share); + } + + public String getFormattedResident() { + return Sigar.formatSize(_resident); + } + + public String getFormattedCpuTotal() { + return getFormattedCpuTotal(_cpuTotal); + } + + public static String getFormattedCpuTotal(long total) { + if (total == Sigar.FIELD_NOTIMPL) { + return NA; + } + long t = total / 1000; + return t/60 + ":" + t%60; + } + + public String getFormattedCpuPerc() { + if (_cpuPerc == Sigar.FIELD_NOTIMPL) { + return NA; + } + return CpuPerc.format(_cpuPerc); + } + + public String toString(String delim) { + return + _pid + delim + + _owner + delim + + getFormattedStartTime() + delim + + getFormattedSize() + delim + + getFormattedResident() + delim + + getFormattedShare() + delim + + _state + delim + + getFormattedCpuTotal() + delim + + getFormattedCpuPerc() + delim + + _name; + } + + public String toString() { + return toString(","); + } } |
|
From: <do...@hy...> - 2007-03-24 21:12:30
|
Author: dougm Date: 2007-03-24 13:12:27 -0800 (Sat, 24 Mar 2007) New Revision: 3867 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3867 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java Log: add formatting helpers Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java 2007-03-24 20:58:04 UTC (rev 3866) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java 2007-03-24 21:12:27 UTC (rev 3867) @@ -25,9 +25,13 @@ //XXX move this class to sigar package org.hyperic.hq.plugin.system; +import java.text.SimpleDateFormat; +import java.util.Date; + import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarNotImplementedException; +import org.hyperic.sigar.util.PrintfFormat; public class UptimeData { @@ -64,4 +68,69 @@ public double[] getLoadavg() { return _loadavg; } + + public String getFormattedTime() { + return getFormattedTime(_time); + } + + public static String getFormattedTime(long time) { + return new SimpleDateFormat("h:mm a").format(new Date(time)); + } + + public String getFormattedUptime() { + return getFormattedUptime(_uptime); + } + + public static String getFormattedUptime(double uptime) { + String retval = ""; + + int days = (int)uptime / (60*60*24); + int minutes, hours; + + if (days != 0) { + retval += days + " " + ((days > 1) ? "days" : "day") + ", "; + } + + minutes = (int)uptime / 60; + hours = minutes / 60; + hours %= 24; + minutes %= 60; + + if (hours != 0) { + retval += hours + ":" + minutes; + } + else { + retval += minutes + " min"; + } + + return retval; + } + + public String getFormattedLoadavg() { + return getFormattedLoadavg(_loadavg); + } + + public static String getFormattedLoadavg(double[] loadavg) { + if (loadavg == null) { + return "(load average unknown)"; //windows + } + + final String format = + "%.2f, %.2f, %.2f"; + + Object[] avg = new Double[] { + new Double(loadavg[0]), + new Double(loadavg[1]), + new Double(loadavg[2]), + }; + + return new PrintfFormat(format).sprintf(avg); + } + + public String toString() { + return + getFormattedTime() + + " up " + getFormattedUptime() + + ", " + getFormattedLoadavg(); + } } |
|
From: <jt...@hy...> - 2007-03-24 20:58:06
|
Author: jtravis Date: 2007-03-24 12:58:04 -0800 (Sat, 24 Mar 2007) New Revision: 3866 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3866 Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy Log: Fix typo, allow strings to contain integers for finding by Id .. fix url bounds problem Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-24 20:56:03 UTC (rev 3865) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-24 20:58:04 UTC (rev 3866) @@ -81,7 +81,7 @@ URLEncoder.encode("" + o.value, "UTF-8") + "&" } - if (url[-1] == '?' || url[-1] == '&') + if (url.length() > 0 && (url[-1] == '?' || url[-1] == '&')) url = url[0..-2] return "<a href=\"$url\">$text</a>" }, Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy 2007-03-24 20:56:03 UTC (rev 3865) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy 2007-03-24 20:58:04 UTC (rev 3866) @@ -17,7 +17,7 @@ str: {name -> platMan.findPlatformTypeByName(name)}, int: {id -> platMan.findPlatformTypeValueById(id)}], group: [ - str: {name -> groupMap.findGroupByName(userVal, name)}, + str: {name -> groupMan.findGroupByName(userVal, name)}, int: {id -> groupMan.findGroup(userVal, id)}], ] @@ -86,6 +86,12 @@ def resourceVal = args[resourceType] def argType = (resourceVal instanceof String) ? 'str' : 'int' + + try { // If it's a string with an integer inside, try that + resourceVal = Integer.parseInt(resourceVal) + argType = 'int' + } catch(NumberFormatException e) { + } NAME_FINDERS[resourceType][argType](resourceVal) } } |
|
From: <do...@hy...> - 2007-03-24 20:56:06
|
Author: dougm Date: 2007-03-24 12:56:03 -0800 (Sat, 24 Mar 2007) New Revision: 3865 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3865 Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java Log: add top command Modified: trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java 2007-03-24 20:55:36 UTC (rev 3864) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/SystemLiveDataPlugin.java 2007-03-24 20:56:03 UTC (rev 3865) @@ -27,6 +27,7 @@ import org.hyperic.hq.product.LiveDataPlugin; import org.hyperic.hq.product.PluginException; +import org.hyperic.hq.product.SigarMeasurementPlugin; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; import org.hyperic.util.config.ConfigResponse; @@ -38,12 +39,14 @@ private static final String CMD_CPU = "cpu"; private static final String CMD_CPUPERC = "cpuperc"; private static final String CMD_FILESYSTEM = "filesystem"; + private static final String CMD_TOP = "top"; private static final String _COMMANDS[] = { CMD_CPUINFO, CMD_CPU, CMD_CPUPERC, - CMD_FILESYSTEM + CMD_FILESYSTEM, + CMD_TOP }; public Object getData(String command, ConfigResponse config) @@ -60,6 +63,10 @@ return sigar.getCpuPercList(); } else if (command.equals(CMD_FILESYSTEM)) { return sigar.getFileSystemList(); + } else if (command.equals(CMD_TOP)) { + String filter = + config.getValue(SigarMeasurementPlugin.PTQL_CONFIG); + return TopData.gather(sigar, filter); } else { throw new PluginException("Unknown command '" + command + "'"); } |
|
From: <do...@hy...> - 2007-03-24 20:55:39
|
Author: dougm Date: 2007-03-24 12:55:36 -0800 (Sat, 24 Mar 2007) New Revision: 3864 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3864 Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java Log: wrapper classes for top command Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java (rev 0) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/ProcessData.java 2007-03-24 20:55:36 UTC (rev 3864) @@ -0,0 +1,150 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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. + */ +//XXX move this class to sigar +package org.hyperic.hq.plugin.system; + +import org.hyperic.sigar.ProcCpu; +import org.hyperic.sigar.ProcCredName; +import org.hyperic.sigar.ProcMem; +import org.hyperic.sigar.ProcState; +import org.hyperic.sigar.ProcTime; +import org.hyperic.sigar.ProcUtil; +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; + +public class ProcessData { + + private long _pid; + private String _owner; + private long _startTime; + private long _size; + private long _resident; + private long _share; + private char _state; + private long _cpuTotal; + private double _cpuPerc; + private String _name; + + public ProcessData() {} + + public void populate(Sigar sigar, long pid) + throws SigarException { + + ProcState state = sigar.getProcState(pid); + ProcTime time = null; + final String unknown = "???"; + + _pid = pid; + + try { + ProcCredName cred = sigar.getProcCredName(pid); + _owner = cred.getUser(); + } catch (SigarException e) { + _owner = unknown; + } + + try { + time = sigar.getProcTime(pid); + _startTime = time.getStartTime(); + } catch (SigarException e) { + _startTime = Sigar.FIELD_NOTIMPL; + } + + try { + ProcMem mem = sigar.getProcMem(pid); + _size = mem.getSize(); + _resident = mem.getResident(); + _share = mem.getShare(); + } catch (SigarException e) { + _size = _resident = _share = Sigar.FIELD_NOTIMPL; + } + + _state = state.getState(); + + if (time != null) { + _cpuTotal = time.getTotal(); + } + else { + _cpuTotal = Sigar.FIELD_NOTIMPL; + } + + try { + ProcCpu cpu = sigar.getProcCpu(pid); + _cpuPerc = cpu.getPercent(); + } catch (SigarException e) { + _cpuPerc = Sigar.FIELD_NOTIMPL; + } + + _name = ProcUtil.getDescription(sigar, pid); + } + + public static ProcessData gather(Sigar sigar, long pid) + throws SigarException { + + ProcessData data = new ProcessData(); + data.populate(sigar, pid); + return data; + } + + public long getPid() { + return _pid; + } + + public String getOwner() { + return _owner; + } + + public long getStartTime() { + return _startTime; + } + + public long getSize() { + return _size; + } + + public long getShare() { + return _share; + } + + public long getResident() { + return _resident; + } + + public char getState() { + return _state; + } + + public long getCpuTotal() { + return _cpuTotal; + } + + public double getCpuPerc() { + return _cpuPerc; + } + + public String getName() { + return _name; + } +} Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java (rev 0) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/TopData.java 2007-03-24 20:55:36 UTC (rev 3864) @@ -0,0 +1,113 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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. + */ +//XXX move this class to sigar +package org.hyperic.hq.plugin.system; + +import java.util.ArrayList; +import java.util.List; + +import org.hyperic.sigar.CpuPerc; +import org.hyperic.sigar.CurrentProcessSummary; +import org.hyperic.sigar.Mem; +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; +import org.hyperic.sigar.Swap; +import org.hyperic.sigar.ptql.ProcessFinder; + +public class TopData { + + private UptimeData _uptime; + private CurrentProcessSummary _currentProcessSummary; + private CpuPerc _cpu; + private Mem _mem; + private Swap _swap; + private List _processes; + + public TopData() {} + + public void populate(Sigar sigar, String filter) + throws SigarException { + + _uptime = UptimeData.gather(sigar); + _currentProcessSummary = CurrentProcessSummary.get(sigar); + _cpu = sigar.getCpuPerc(); + _mem = sigar.getMem(); + _swap = sigar.getSwap(); + + ps(sigar, filter); + } + + private void ps(Sigar sigar, String filter) throws SigarException { + _processes = new ArrayList(); + long[] pids; + if (filter == null) { + pids = sigar.getProcList(); + } + else { + pids = ProcessFinder.find(sigar, filter); + } + + for (int i=0; i<pids.length; i++) { + long pid = pids[i]; + try { + _processes.add(ProcessData.gather(sigar, pid)); + } catch (SigarException e) { + + } + } + } + + public static TopData gather(Sigar sigar, String filter) + throws SigarException { + + TopData data = new TopData(); + data.populate(sigar, filter); + return data; + } + + public UptimeData getUptime() { + return _uptime; + } + + public CurrentProcessSummary getCurrentProcessSummary() { + return _currentProcessSummary; + } + + public CpuPerc getCpu() { + return _cpu; + } + + public Mem getMem() { + return _mem; + } + + public Swap getSwap() { + return _swap; + } + + public List getProcesses() { + return _processes; + } +} Added: trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java =================================================================== --- trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java (rev 0) +++ trunk/plugins/system/src/org/hyperic/hq/plugin/system/UptimeData.java 2007-03-24 20:55:36 UTC (rev 3864) @@ -0,0 +1,67 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * This file is part of HQ. + * + * HQ 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. + */ +//XXX move this class to sigar +package org.hyperic.hq.plugin.system; + +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.SigarException; +import org.hyperic.sigar.SigarNotImplementedException; + +public class UptimeData { + + private long _time; + private double _uptime; + private double[] _loadavg; + + public UptimeData() {} + + public void populate(Sigar sigar) throws SigarException { + _time = System.currentTimeMillis(); + _uptime = sigar.getUptime().getUptime(); + try { + _loadavg = sigar.getLoadAverage(); + } catch (SigarNotImplementedException e) { + _loadavg = null; + } + } + + public static UptimeData gather(Sigar sigar) throws SigarException { + UptimeData data = new UptimeData(); + data.populate(sigar); + return data; + } + + public long getTime() { + return _time; + } + + public double getUptime() { + return _uptime; + } + + public double[] getLoadavg() { + return _loadavg; + } +} |
|
From: <jt...@hy...> - 2007-03-24 20:32:20
|
Author: jtravis Date: 2007-03-24 12:32:19 -0800 (Sat, 24 Mar 2007) New Revision: 3863 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3863 Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy Log: Add find for groups Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy 2007-03-24 20:23:30 UTC (rev 3862) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/ResourceHelper.groovy 2007-03-24 20:32:19 UTC (rev 3863) @@ -3,6 +3,7 @@ import org.hyperic.util.pager.PageControl import org.hyperic.hq.appdef.shared.AppdefResourceValue +import org.hyperic.hq.appdef.server.session.AppdefGroupManagerEJBImpl import org.hyperic.hq.appdef.server.session.PlatformManagerEJBImpl class ResourceHelper @@ -15,10 +16,14 @@ platformType: [ str: {name -> platMan.findPlatformTypeByName(name)}, int: {id -> platMan.findPlatformTypeValueById(id)}], + group: [ + str: {name -> groupMap.findGroupByName(userVal, name)}, + int: {id -> groupMan.findGroup(userVal, id)}], ] private final ALL_FINDERS = [ - platforms: {platMan.getAllPlatforms(userVal, PageControl.PAGE_ALL)}, + platforms: {platMan.getAllPlatforms(userVal, PageControl.PAGE_ALL)}, + groups: {groupMan.findAllGroups(userVal, PageControl.PAGE_ALL)}, ] ResourceHelper(user) { @@ -26,6 +31,7 @@ } private getPlatMan() { PlatformManagerEJBImpl.one } + private getGroupMan() { AppdefGroupManagerEJBImpl.one } /** * Generic method to find resources. The results are constrained by the |
|
From: <jt...@hy...> - 2007-03-24 20:23:34
|
Author: jtravis Date: 2007-03-24 12:23:30 -0800 (Sat, 24 Mar 2007) New Revision: 3862 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3862 Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy Log: Fix problem when gspArgs isn't set Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-24 20:05:34 UTC (rev 3861) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-24 20:23:30 UTC (rev 3862) @@ -7,7 +7,6 @@ import org.apache.commons.logging.Log import org.apache.commons.logging.LogFactory -import org.hyperic.hq.appdef.shared.AppdefEntityID import org.hyperic.hq.authz.server.session.AuthzSubject import org.hyperic.hq.ui.util.ContextUtils import org.hyperic.hq.ui.util.RequestUtils @@ -110,8 +109,8 @@ */ protected void render(args) { args = (args == null) ? [:] : args - def gspArgs = args.remove("args") - def gspFile = args.remove("file") + def gspArgs = args.get("args", [:]) + def gspFile = args.file def useAction if (gspFile == null) |
|
From: <jt...@hy...> - 2007-03-24 20:05:37
|
Author: jtravis Date: 2007-03-24 12:05:34 -0800 (Sat, 24 Mar 2007) New Revision: 3861 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3861 Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/HQHelper.groovy Modified: trunk/ui_plugins/hqu_livedata/showResource.gsp trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy Log: Add the HQHelper, easy ability to link to a resource Modified: trunk/ui_plugins/hqu_livedata/showResource.gsp =================================================================== --- trunk/ui_plugins/hqu_livedata/showResource.gsp 2007-03-24 17:39:11 UTC (rev 3860) +++ trunk/ui_plugins/hqu_livedata/showResource.gsp 2007-03-24 20:05:34 UTC (rev 3861) @@ -1,6 +1,6 @@ <html> <body> - <h1>LiveData commands for <%= resource.name %> + <h1>LiveData commands for <%= link_to resource.name, [resource:resource] %> (<%= resource.appdefResourceTypeValue.name %>)</h1> <p> Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-24 17:39:11 UTC (rev 3860) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-24 20:05:34 UTC (rev 3861) @@ -7,12 +7,14 @@ import org.apache.commons.logging.Log import org.apache.commons.logging.LogFactory +import org.hyperic.hq.appdef.shared.AppdefEntityID import org.hyperic.hq.authz.server.session.AuthzSubject import org.hyperic.hq.ui.util.ContextUtils import org.hyperic.hq.ui.util.RequestUtils import org.hyperic.hq.ui.rendit.helpers.LiveDataHelper import org.hyperic.hq.ui.rendit.helpers.ResourceHelper +import org.hyperic.hq.ui.rendit.helpers.HQHelper import groovy.text.SimpleTemplateEngine import java.io.File @@ -41,6 +43,7 @@ def getResourceHelper() { return new ResourceHelper(getUser()) } def getLiveDataHelper() { return new LiveDataHelper(getUser()) } + def getHQHelper() { return new HQHelper(getUser()) } /** * Retreives the currently logged-in user @@ -58,15 +61,20 @@ public String h(str) { StringEscapeUtils.escapeHtml(str) } - + + // TODO: These need to be moved to a separate class public RENDER_BUILTINS = [ link_to : { text, Object[] args -> def url = "" def opts = (args.length > 0) ? args[0] : [:] def htmlOpts = (args.length > 1) ? args[1] : [:] - if (opts.containsKey('action')) + if (opts.containsKey('action')) { url += h(opts['action']) + } else if (opts.containsKey('resource')) { + def entId = opts['resource'].entityId.appdefKey + url = getHQHelper().serverURL + "Resource.do?eid=$entId" + } url += '?' for (o in htmlOpts) { @@ -74,6 +82,8 @@ URLEncoder.encode("" + o.value, "UTF-8") + "&" } + if (url[-1] == '?' || url[-1] == '&') + url = url[0..-2] return "<a href=\"$url\">$text</a>" }, Added: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/HQHelper.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/HQHelper.groovy (rev 0) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/helpers/HQHelper.groovy 2007-03-24 20:05:34 UTC (rev 3861) @@ -0,0 +1,22 @@ +package org.hyperic.hq.ui.rendit.helpers + +import org.hyperic.hq.common.shared.HQConstants +import org.hyperic.hq.common.server.session.ServerConfigManagerEJBImpl + +class HQHelper + extends BaseHelper +{ + HQHelper(user) { + super(user) + } + + private getServerMan() { ServerConfigManagerEJBImpl.one } + + String getServerURL() { + def res = serverMan.config.getProperty(HQConstants.BaseURL) + if (!res.endsWith('/')) { + res += '/' + } + res + } +} |
|
From: <rm...@hy...> - 2007-03-24 17:39:19
|
Author: rmorgan Date: 2007-03-24 09:39:11 -0800 (Sat, 24 Mar 2007) New Revision: 3860 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3860 Modified: trunk/build.xml Log: Fix build. Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2007-03-24 11:38:55 UTC (rev 3859) +++ trunk/build.xml 2007-03-24 17:39:11 UTC (rev 3860) @@ -73,7 +73,7 @@ <property name="installer.dir" value="${build.dir}/installer"/> <property name="rendit_sys.dir" - value="${basedir}/src/org/hyperic/hq/ui/rendit/rendit_sys"/> + value="${basedir}/ui_plugins/rendit_sys"/> <path id="pdknative"> <fileset dir="${sigar.lib}" includes="*.jar" /> |