diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-07-25 12:48:03 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-07-25 12:48:03 +0530 |
| commit | a2a52d53ee2e0dd32b993c112200cfd1c927aafa (patch) | |
| tree | 35b78b0672fec644c822b1fdaf4f20f95fa80d4c /src/com.gluster.storage.management.server | |
| parent | 1e8135f9e270e7c6557e66532160fbea40ea8bba (diff) | |
Story #38 - CPU Usage graph
Diffstat (limited to 'src/com.gluster.storage.management.server')
| -rw-r--r-- | src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java index 609b4f65..e4d37ad8 100644 --- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java +++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/ServerUtil.java @@ -224,49 +224,6 @@ public class ServerUtil { return (Status) executeOnServer(true, serverName, REMOTE_SCRIPT_GET_DISK_FOR_DIR + " " + brickDir, Status.class); } - public ServerStats fetchCPUUsageData(String serverName) { - Object output = executeOnServer(true, serverName, "get_rrd_cpu_details.py 1d", ServerStats.class); - //String cpuUsageData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <xport> <meta> <start>1310468100</start> <step>300</step> <end>1310471700</end> <rows>13</rows> <columns>3</columns> <legend> <entry>user</entry> <entry>system</entry> <entry>total</entry> </legend> </meta> <data> <row><t>1310468100</t><v>2.23802952e-1</v><v>4.3747778209e-01</v><v>6.6128073384e-01</v></row> <row><t>1310468400</t><v>2.3387347338e-01</v><v>4.4642717442e-01</v><v>6.8030064780e-01</v></row> <row><t>1310468700</t><v>5.5043873220e+00</v><v>6.2462376636e+00</v><v>1.1750624986e+01</v></row> <row><t>1310469000</t><v>2.4350593653e+01</v><v>2.6214585217e+01</v><v>5.0565178869e+01</v></row> <row><t>1310469300</t><v>4.0786489953e+01</v><v>4.6784713828e+01</v><v>8.7571203781e+01</v></row> <row><t>1310469600</t><v>4.1459955508e+01</v><v>5.2546309044e+01</v><v>9.4006264551e+01</v></row> <row><t>1310469900</t><v>4.2312286165e+01</v><v>5.2390588332e+01</v><v>9.4702874497e+01</v></row> <row><t>1310470200</t><v>4.2603794982e+01</v><v>5.1598861493e+01</v><v>9.4202656475e+01</v></row> <row><t>1310470500</t><v>3.8238751290e+01</v><v>4.5312089966e+01</v><v>8.3550841256e+01</v></row> <row><t>1310470800</t><v>1.7949961224e+01</v><v>2.1282058418e+01</v><v>3.9232019642e+01</v></row> <row><t>1310471100</t><v>1.2330371421e-01</v><v>4.6347832868e-01</v><v>5.8678204289e-01</v></row> <row><t>1310471400</t><v>1.6313260492e-01</v><v>5.4088119561e-01</v><v>7.0401380052e-01</v></row> <row><t>1310471700</t><v>NaN</v><v>NaN</v><v>NaN</v></row> </data> </xport>"; - //Object output = unmarshal(ServerStats.class, cpuUsageData, false); - if(output instanceof Status) { - throw new GlusterRuntimeException(((Status)output).toString()); - } - return (ServerStats) output; - } - - private ServerStats getFirstOnlineServerCPUStats(List<String> serverNames, boolean removeServerOnError, boolean removeOnlineServer) { - for(int i = serverNames.size() - 1; i >= 0; i--) { - String serverName = serverNames.get(i); - try { - ServerStats stats = fetchCPUUsageData(serverName); - if(removeOnlineServer) { - serverNames.remove(serverName); - } - return stats; - } catch(Exception e) { - // server might be offline - continue with next one - logger.warn("Couldn't fetch CPU stats from server [" + serverName + "]!", e); - if(removeServerOnError) { - serverNames.remove(serverName); - } - continue; - } - } - throw new GlusterRuntimeException("All servers offline!"); - } - - public ServerStats fetchAggregatedCPUStats(List<String> serverNames) { - if(serverNames == null || serverNames.size() == 0) { - throw new GlusterRuntimeException("No server names passed to fetchAggregaredCPUUsageData!"); - } - - ServerStats firstServerStats = getFirstOnlineServerCPUStats(serverNames, true, true); - - ServerStats aggregatedStats = new ServerStats(firstServerStats); - aggregateCPUStats(serverNames, aggregatedStats); - return aggregatedStats; - } - public static void main(String[] args) { // ServerStats stats = new ServerUtil().fetchCPUUsageData("s1", "1d"); // for(ServerStatsRow row : stats.getRows()) { |
