Skip to content

Commit

Permalink
style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunakDas88 committed Oct 5, 2023
1 parent af62646 commit 6c299a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,18 @@ private static void parseFile() {
int sectorSizeBytes = 512;
String line;
while ((line = reader.readLine()) != null) {
String[] fields = line.trim().split("\\s+");
if (fields.length < 14)
String[] parts = line.trim().split("\\s+");
if (parts.length < 14)
continue;
Map<String,Double> innerMap = new HashMap<>();
String device = fields[2];
Double readsCompleted = Double.parseDouble(fields[3]);
Double sectorsRead = Double.parseDouble(fields[5]);
Double writesCompleted = Double.parseDouble(fields[7]);
Double sectorsWritten = Double.parseDouble(fields[9]);

String device = parts[2];
Double readsCompleted = Double.parseDouble(parts[3]);
Double sectorsRead = Double.parseDouble(parts[5]);
Double writesCompleted = Double.parseDouble(parts[7]);
Double sectorsWritten = Double.parseDouble(parts[9]);
Double transactions = readsCompleted + writesCompleted;
Double kbRead = (sectorsRead * sectorSizeBytes) / 1024;
Double kbWritten = (sectorsWritten * sectorSizeBytes) / 1024;

innerMap.put("transactions", transactions);
innerMap.put("kB_read", kbRead);
innerMap.put("kB_written", kbWritten);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ private static void parseFile() {
metricsMap.put(key, value);
}
}
if (metricsMap.get("MemTotal") != null && metricsMap.get("MemFree") != null) {
if (metricsMap.get("MemTotal") != null && metricsMap.get("MemFree") != null)
metricsMap.put("MemUsed", metricsMap.get("MemTotal") - metricsMap.get("MemFree"));
}
if (metricsMap.get("SwapTotal") != null && metricsMap.get("SwapFree") != null) {
if (metricsMap.get("SwapTotal") != null && metricsMap.get("SwapFree") != null)
metricsMap.put("SwapUsed", metricsMap.get("SwapTotal") - metricsMap.get("SwapFree"));
}
} catch (FileNotFoundException e) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ private static void parseFile() {
Double irq = Double.parseDouble(parts[6]);
Double softirq = Double.parseDouble(parts[7]);
Double steal = Double.parseDouble(parts[8]);

Double total = user + nice + system + idle + iowait + irq + softirq + steal;
metricsMap.put("user", user);
metricsMap.put("system", system);
Expand Down

0 comments on commit 6c299a2

Please sign in to comment.