Cleanup and initial test of build pipeline.
This commit is contained in:
parent
1b60d58df3
commit
0124b21692
22
bitbucket-pipelines.yml
Normal file
22
bitbucket-pipelines.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
image: openjdk:8
|
||||||
|
|
||||||
|
pipelines:
|
||||||
|
branches:
|
||||||
|
master:
|
||||||
|
- step:
|
||||||
|
caches:
|
||||||
|
- gradle
|
||||||
|
name: Build and Test
|
||||||
|
script:
|
||||||
|
- ./gradlew clean build
|
||||||
|
tags: # add the 'tags' section
|
||||||
|
v*: # specify the tag
|
||||||
|
- step: # define the build pipeline for the tag
|
||||||
|
caches:
|
||||||
|
- gradle
|
||||||
|
name: Build and Release
|
||||||
|
script:
|
||||||
|
- ./gradlew clean packages
|
||||||
|
- shopt -s nullglob ; for file in ${BITBUCKET_CLONE_DIR}/server/build/distributions/*.{deb,rpm} ; do curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${file}" ; done
|
||||||
|
- shopt -s nullglob ; for file in ${BITBUCKET_CLONE_DIR}/plugins/build/distributions/*.{deb,rpm} ; do curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${file}" ; done
|
||||||
|
- shopt -s nullglob ; for file in ${BITBUCKET_CLONE_DIR}/client/build/distributions/*.{deb,rpm} ; do curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"${file}" ; done
|
|
@ -1,4 +1,4 @@
|
||||||
version=0.0.1-SNAPSHOT
|
version=0.0.2
|
||||||
pf4jVersion=3.6.0
|
pf4jVersion=3.6.0
|
||||||
slf4jVersion=1.7.30
|
slf4jVersion=1.7.30
|
||||||
camelVersion=3.7.4
|
camelVersion=3.7.4
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package sysmon.plugins.os_aix;
|
package sysmon.plugins.os_aix;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -11,25 +8,21 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class AixDiskStat {
|
public class AixDiskStat {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AixDiskStat.class);
|
|
||||||
|
|
||||||
// Disks: % tm_act Kbps tps Kb_read Kb_wrtn
|
// Disks: % tm_act Kbps tps Kb_read Kb_wrtn
|
||||||
// hdisk0 1.0 752.0 81.0 740 12
|
// hdisk0 1.0 752.0 81.0 740 12
|
||||||
private final Pattern pattern = Pattern.compile("^(hdisk\\d+)\\s+(\\d+\\.?\\d*)\\s+\\s+(\\d+\\.?\\d*)\\s+\\s+(\\d+\\.?\\d*)\\s+(\\d+)\\s+(\\d+)");
|
private final Pattern pattern = Pattern.compile("^(hdisk\\d+)\\s+(\\d+\\.?\\d*)\\s+\\s+(\\d+\\.?\\d*)\\s+\\s+(\\d+\\.?\\d*)\\s+(\\d+)\\s+(\\d+)");
|
||||||
|
|
||||||
|
|
||||||
//private String device;
|
//private String device;
|
||||||
//private Float tmAct = 0.0f; // Indicates the percentage of time the physical disk/tape was active (bandwidth utilization for the drive).
|
//private Float tmAct = 0.0f; // Indicates the percentage of time the physical disk/tape was active (bandwidth utilization for the drive).
|
||||||
private Float kbps = 0.0f; // Indicates the amount of data transferred (read or written) to the drive in KB per second.
|
private float kbps = 0.0f; // Indicates the amount of data transferred (read or written) to the drive in KB per second.
|
||||||
private Float tps = 0.0f; // Indicates the number of transfers per second that were issued to the physical disk/tape. A transfer is an I/O request to the physical disk/tape. Multiple logical requests can be combined into a single I/O request to the disk. A transfer is of indeterminate size.
|
private float tps = 0.0f; // Indicates the number of transfers per second that were issued to the physical disk/tape. A transfer is an I/O request to the physical disk/tape. Multiple logical requests can be combined into a single I/O request to the disk. A transfer is of indeterminate size.
|
||||||
private Long kbRead = 0L; // The total number of KB read.
|
private long kbRead = 0L; // The total number of KB read.
|
||||||
private Long kbWritten = 0L; // The total number of KB written.
|
private long kbWritten = 0L; // The total number of KB written.
|
||||||
|
|
||||||
|
|
||||||
AixDiskStat(List<String> lines) {
|
AixDiskStat(List<String> lines) {
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
|
||||||
if (line.startsWith("hdisk")) {
|
if (line.startsWith("hdisk")) {
|
||||||
Matcher matcher = pattern.matcher(line);
|
Matcher matcher = pattern.matcher(line);
|
||||||
if (matcher.find() && matcher.groupCount() == 6) {
|
if (matcher.find() && matcher.groupCount() == 6) {
|
||||||
|
@ -40,24 +33,21 @@ public class AixDiskStat {
|
||||||
kbRead += Long.parseLong(matcher.group(5));
|
kbRead += Long.parseLong(matcher.group(5));
|
||||||
kbWritten += Long.parseLong(matcher.group(6));
|
kbWritten += Long.parseLong(matcher.group(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getTags() {
|
public Map<String, String> getTags() {
|
||||||
Map<String, String> tags = new HashMap<>();
|
return new HashMap<>();
|
||||||
return tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getFields() {
|
public Map<String, Object> getFields() {
|
||||||
Map<String, Object> fields = new HashMap<>();
|
Map<String, Object> fields = new HashMap<>();
|
||||||
fields.put("reads", kbRead * 1024); // from Kb to bytes
|
fields.put("reads", kbRead * 1024); // from Kb to bytes
|
||||||
fields.put("writes", kbWritten * 1024); // from Kb to bytes
|
fields.put("writes", kbWritten * 1024); // from Kb to bytes
|
||||||
fields.put("kbps", kbps);
|
fields.put("kbps", (int) kbps);
|
||||||
fields.put("tps", tps);
|
fields.put("tps", (int) tps);
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package sysmon.plugins.os_aix;
|
package sysmon.plugins.os_aix;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -13,17 +8,15 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class AixMemoryStat {
|
public class AixMemoryStat {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AixMemoryStat.class);
|
|
||||||
|
|
||||||
private final Pattern pattern = Pattern.compile("^\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
|
private final Pattern pattern = Pattern.compile("^\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
|
||||||
|
|
||||||
private Long total;
|
private long total;
|
||||||
private Long used;
|
private long used;
|
||||||
private Long free;
|
private long free;
|
||||||
private Long pin;
|
private long pin;
|
||||||
private Long virtual;
|
private long virtual;
|
||||||
private Long available;
|
private long available;
|
||||||
private Long paged;
|
private long paged;
|
||||||
|
|
||||||
AixMemoryStat(List<String> lines) {
|
AixMemoryStat(List<String> lines) {
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
@ -43,15 +36,14 @@ public class AixMemoryStat {
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> getTags() {
|
public Map<String, String> getTags() {
|
||||||
Map<String, String> tags = new HashMap<>();
|
return new HashMap<>();
|
||||||
return tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, Object> getFields() {
|
public Map<String, Object> getFields() {
|
||||||
|
|
||||||
double tmp = ((double) (total - available) / total ) * 100;
|
float usage = ((float) (total - available) / total ) * 100;
|
||||||
BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
|
//BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
Map<String, Object> fields = new HashMap<>();
|
Map<String, Object> fields = new HashMap<>();
|
||||||
fields.put("total", total);
|
fields.put("total", total);
|
||||||
|
@ -61,7 +53,7 @@ public class AixMemoryStat {
|
||||||
fields.put("virtual", virtual);
|
fields.put("virtual", virtual);
|
||||||
fields.put("available", available);
|
fields.put("available", available);
|
||||||
fields.put("paged", paged);
|
fields.put("paged", paged);
|
||||||
fields.put("usage", usage.doubleValue());
|
fields.put("usage", usage);
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package sysmon.plugins.os_aix;
|
package sysmon.plugins.os_aix;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -11,8 +8,6 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class AixProcessorStat {
|
public class AixProcessorStat {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AixProcessorStat.class);
|
|
||||||
|
|
||||||
// System configuration: type=Shared mode=Uncapped smt=8 lcpu=8 mem=4096MB psize=19 ent=0.50
|
// System configuration: type=Shared mode=Uncapped smt=8 lcpu=8 mem=4096MB psize=19 ent=0.50
|
||||||
private final Pattern patternAix = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB psize=(\\d+) ent=(\\d+\\.?\\d*)");
|
private final Pattern patternAix = Pattern.compile("^System configuration: type=(\\S+) mode=(\\S+) smt=(\\d+) lcpu=(\\d+) mem=(\\d+)MB psize=(\\d+) ent=(\\d+\\.?\\d*)");
|
||||||
|
|
||||||
|
@ -22,18 +17,18 @@ public class AixProcessorStat {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
private String mode;
|
private String mode;
|
||||||
private Integer smt;
|
private int smt;
|
||||||
private Integer lcpu;
|
private int lcpu;
|
||||||
private Integer psize;
|
private int psize;
|
||||||
private Float ent;
|
private float ent;
|
||||||
|
|
||||||
private final Float user; // Indicates the percentage of the entitled processing capacity used while executing at the user level (application).
|
private final float user; // Indicates the percentage of the entitled processing capacity used while executing at the user level (application).
|
||||||
private final Float sys; // Indicates the percentage of the entitled processing capacity used while executing at the system level (kernel).
|
private final float sys; // Indicates the percentage of the entitled processing capacity used while executing at the system level (kernel).
|
||||||
private final Float wait; // Indicates the percentage of the entitled processing capacity unused while the partition was idle and had outstanding disk I/O request(s).
|
private final float wait; // Indicates the percentage of the entitled processing capacity unused while the partition was idle and had outstanding disk I/O request(s).
|
||||||
private final Float idle; // Indicates the percentage of the entitled processing capacity unused while the partition was idle and did not have any outstanding disk I/O request.
|
private final float idle; // Indicates the percentage of the entitled processing capacity unused while the partition was idle and did not have any outstanding disk I/O request.
|
||||||
private final Float physc; // Indicates the number of physical processors consumed.
|
private final float physc; // Indicates the number of physical processors consumed.
|
||||||
private final Float entc; // Indicates the percentage of the entitled capacity consumed.
|
private final float entc; // Indicates the percentage of the entitled capacity consumed.
|
||||||
private final Float lbusy; // Indicates the percentage of logical processor(s) utilization that occurred while executing at the user and system level.
|
private final float lbusy; // Indicates the percentage of logical processor(s) utilization that occurred while executing at the user and system level.
|
||||||
|
|
||||||
|
|
||||||
AixProcessorStat(List<String> lines) {
|
AixProcessorStat(List<String> lines) {
|
||||||
|
@ -54,7 +49,6 @@ public class AixProcessorStat {
|
||||||
|
|
||||||
if (line.startsWith("type=")) {
|
if (line.startsWith("type=")) {
|
||||||
//type=Shared mode=Uncapped smt=8 lcpu=4 mem=4101120 kB cpus=24 ent=4.00
|
//type=Shared mode=Uncapped smt=8 lcpu=4 mem=4101120 kB cpus=24 ent=4.00
|
||||||
|
|
||||||
Matcher matcher = patternLinux.matcher(line);
|
Matcher matcher = patternLinux.matcher(line);
|
||||||
if (matcher.find() && matcher.groupCount() == 7) {
|
if (matcher.find() && matcher.groupCount() == 7) {
|
||||||
type = matcher.group(1);
|
type = matcher.group(1);
|
||||||
|
@ -84,31 +78,31 @@ public class AixProcessorStat {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getUser() {
|
public float getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getSys() {
|
public float getSys() {
|
||||||
return sys;
|
return sys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getIdle() {
|
public float getIdle() {
|
||||||
return idle;
|
return idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getWait() {
|
public float getWait() {
|
||||||
return wait;
|
return wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getPhysc() {
|
public float getPhysc() {
|
||||||
return physc;
|
return physc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getEntc() {
|
public float getEntc() {
|
||||||
return entc;
|
return entc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getLbusy() {
|
public float getLbusy() {
|
||||||
return lbusy;
|
return lbusy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +111,7 @@ public class AixProcessorStat {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getTags() {
|
public Map<String, String> getTags() {
|
||||||
Map<String, String> tags = new HashMap<>();
|
return new HashMap<>();
|
||||||
return tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getFields() {
|
public Map<String, Object> getFields() {
|
||||||
|
|
|
@ -18,8 +18,8 @@ class AixDiskTest extends Specification {
|
||||||
//stats.getTags().get("device") == "hdisk0"
|
//stats.getTags().get("device") == "hdisk0"
|
||||||
stats.getFields().get("reads") == 757760L
|
stats.getFields().get("reads") == 757760L
|
||||||
stats.getFields().get("writes") == 12288L
|
stats.getFields().get("writes") == 12288L
|
||||||
stats.getFields().get("kbps") == 752.0F
|
stats.getFields().get("kbps") == 752L
|
||||||
stats.getFields().get("tps") == 81.0F
|
stats.getFields().get("tps") == 81L
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,14 @@ class AixMemoryTest extends Specification {
|
||||||
AixMemoryStat stats = extension.processCommandOutput(lines)
|
AixMemoryStat stats = extension.processCommandOutput(lines)
|
||||||
|
|
||||||
then:
|
then:
|
||||||
stats.getFields().get("total") == 4194304l
|
stats.getFields().get("total") == 4194304L
|
||||||
stats.getFields().get("used") == 4065060l
|
stats.getFields().get("used") == 4065060L
|
||||||
stats.getFields().get("free") == 129244l
|
stats.getFields().get("free") == 129244L
|
||||||
stats.getFields().get("pin") == 1878240l
|
stats.getFields().get("pin") == 1878240L
|
||||||
stats.getFields().get("virtual") == 2784988l
|
stats.getFields().get("virtual") == 2784988L
|
||||||
stats.getFields().get("available") == 1058012l
|
stats.getFields().get("available") == 1058012L
|
||||||
stats.getFields().get("paged") == 524288l
|
stats.getFields().get("paged") == 524288L
|
||||||
stats.getFields().get("usage") == 74.78d
|
stats.getFields().get("usage") == 74.775024f
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,26 +8,23 @@ import java.util.Map;
|
||||||
|
|
||||||
public class LinuxDiskStat {
|
public class LinuxDiskStat {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(LinuxDiskStat.class);
|
|
||||||
|
|
||||||
private String device;
|
private String device;
|
||||||
private final long iotime;
|
private final long iotime;
|
||||||
private final long reads;
|
private final long reads;
|
||||||
private final long writes;
|
private final long writes;
|
||||||
private final double kbps;
|
private final long kbps;
|
||||||
private final double tps;
|
private final long tps;
|
||||||
|
|
||||||
LinuxDiskStat(LinuxDiskProcLine proc1, LinuxDiskProcLine proc2) {
|
LinuxDiskStat(LinuxDiskProcLine proc1, LinuxDiskProcLine proc2) {
|
||||||
iotime = proc2.getTimeSpentOnIo() - proc1.getTimeSpentOnIo();
|
iotime = proc2.getTimeSpentOnIo() - proc1.getTimeSpentOnIo();
|
||||||
writes = proc2.getBytesWritten() - proc1.getBytesWritten();
|
writes = proc2.getBytesWritten() - proc1.getBytesWritten();
|
||||||
reads = proc2.getBytesRead() - proc1.getBytesRead();
|
reads = proc2.getBytesRead() - proc1.getBytesRead();
|
||||||
kbps = ((double) writes + reads) / 1024;
|
kbps = (writes + reads) / 1024;
|
||||||
tps = proc2.getTransactions() - proc1.getTransactions();
|
tps = proc2.getTransactions() - proc1.getTransactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getTags() {
|
public Map<String, String> getTags() {
|
||||||
Map<String, String> tags = new HashMap<>();
|
return new HashMap<>();
|
||||||
return tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getFields() {
|
public Map<String, Object> getFields() {
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package sysmon.plugins.os_linux;
|
package sysmon.plugins.os_linux;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -13,8 +8,6 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class LinuxMemoryStat {
|
public class LinuxMemoryStat {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(LinuxMemoryStat.class);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
total used free shared buff/cache available
|
total used free shared buff/cache available
|
||||||
Mem: 16069172 5896832 4597860 639780 5574480 9192992
|
Mem: 16069172 5896832 4597860 639780 5574480 9192992
|
||||||
|
@ -22,13 +15,13 @@ public class LinuxMemoryStat {
|
||||||
*/
|
*/
|
||||||
private final Pattern pattern = Pattern.compile("^Mem:\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
|
private final Pattern pattern = Pattern.compile("^Mem:\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)");
|
||||||
|
|
||||||
private Long total;
|
private long total;
|
||||||
private Long used;
|
private long used;
|
||||||
private Long free;
|
private long free;
|
||||||
private Long shared;
|
private long shared;
|
||||||
private Long buffers;
|
private long buffers;
|
||||||
private Long available;
|
private long available;
|
||||||
private String mode;
|
//private String mode;
|
||||||
|
|
||||||
LinuxMemoryStat(List<String> lines) {
|
LinuxMemoryStat(List<String> lines) {
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
@ -40,7 +33,6 @@ public class LinuxMemoryStat {
|
||||||
shared = Long.parseLong(matcher.group(4));
|
shared = Long.parseLong(matcher.group(4));
|
||||||
buffers = Long.parseLong(matcher.group(5));
|
buffers = Long.parseLong(matcher.group(5));
|
||||||
available = Long.parseLong(matcher.group(6));
|
available = Long.parseLong(matcher.group(6));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,15 +40,14 @@ public class LinuxMemoryStat {
|
||||||
|
|
||||||
|
|
||||||
public Map<String, String> getTags() {
|
public Map<String, String> getTags() {
|
||||||
Map<String, String> tags = new HashMap<>();
|
return new HashMap<>();
|
||||||
return tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, Object> getFields() {
|
public Map<String, Object> getFields() {
|
||||||
|
|
||||||
double tmp = ((double) (total - available) / total ) * 100;
|
float usage = ((float) (total - available) / total ) * 100;
|
||||||
BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
|
//BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
Map<String, Object> fields = new HashMap<>();
|
Map<String, Object> fields = new HashMap<>();
|
||||||
fields.put("total", total);
|
fields.put("total", total);
|
||||||
|
@ -65,7 +56,7 @@ public class LinuxMemoryStat {
|
||||||
fields.put("shared", shared);
|
fields.put("shared", shared);
|
||||||
fields.put("buffers", buffers);
|
fields.put("buffers", buffers);
|
||||||
fields.put("available", available);
|
fields.put("available", available);
|
||||||
fields.put("usage", usage.doubleValue());
|
fields.put("usage", usage);
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ package sysmon.plugins.os_linux;
|
||||||
public class LinuxProcessorProcLine {
|
public class LinuxProcessorProcLine {
|
||||||
|
|
||||||
private final String cpuName;
|
private final String cpuName;
|
||||||
private final Long userTime;
|
private final long userTime;
|
||||||
private final Long niceTime;
|
private final long niceTime;
|
||||||
private final Long systemTime;
|
private final long systemTime;
|
||||||
private final Long idleTime;
|
private final long idleTime;
|
||||||
private final Long ioWaitTime;
|
private final long ioWaitTime;
|
||||||
private final Long irqTime;
|
private final long irqTime;
|
||||||
private final Long softIrqTime;
|
private final long softIrqTime;
|
||||||
private final Long stealTime;
|
private final long stealTime;
|
||||||
private final Long guestTime;
|
private final long guestTime;
|
||||||
private final Long guestNiceTime;
|
private final long guestNiceTime;
|
||||||
|
|
||||||
|
|
||||||
public LinuxProcessorProcLine(String procString) {
|
public LinuxProcessorProcLine(String procString) {
|
||||||
|
@ -40,55 +40,55 @@ public class LinuxProcessorProcLine {
|
||||||
return cpuName;
|
return cpuName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUserTime() {
|
public long getUserTime() {
|
||||||
return userTime;
|
return userTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getNiceTime() {
|
public long getNiceTime() {
|
||||||
return niceTime;
|
return niceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getSystemTime() {
|
public long getSystemTime() {
|
||||||
return systemTime;
|
return systemTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getIdleTime() {
|
public long getIdleTime() {
|
||||||
return idleTime;
|
return idleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getIoWaitTime() {
|
public long getIoWaitTime() {
|
||||||
return ioWaitTime;
|
return ioWaitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getIrqTime() {
|
public long getIrqTime() {
|
||||||
return irqTime;
|
return irqTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getSoftIrqTime() {
|
public long getSoftIrqTime() {
|
||||||
return softIrqTime;
|
return softIrqTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getStealTime() {
|
public long getStealTime() {
|
||||||
return stealTime;
|
return stealTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getGuestTime() {
|
public long getGuestTime() {
|
||||||
return guestTime;
|
return guestTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getGuestNiceTime() {
|
public long getGuestNiceTime() {
|
||||||
return guestNiceTime;
|
return guestNiceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCombinedIdleTime() {
|
public long getCombinedIdleTime() {
|
||||||
return idleTime + ioWaitTime;
|
return idleTime + ioWaitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCombinedWorkTime() {
|
public long getCombinedWorkTime() {
|
||||||
return userTime + niceTime + systemTime + irqTime + softIrqTime + stealTime + guestTime + guestNiceTime;
|
return userTime + niceTime + systemTime + irqTime + softIrqTime + stealTime + guestTime + guestNiceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCombinedTime() {
|
public long getCombinedTime() {
|
||||||
return getCombinedIdleTime() + getCombinedWorkTime();
|
return getCombinedIdleTime() + getCombinedWorkTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class LinuxMemoryTest extends Specification {
|
||||||
stats.getFields().get("shared") == 639780l
|
stats.getFields().get("shared") == 639780l
|
||||||
stats.getFields().get("buffers") == 5574480l
|
stats.getFields().get("buffers") == 5574480l
|
||||||
stats.getFields().get("available") == 9192992l
|
stats.getFields().get("available") == 9192992l
|
||||||
stats.getFields().get("usage") == 42.79d
|
stats.getFields().get("usage") == 42.79113f
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,12 @@ package sysmon.server.bean;
|
||||||
|
|
||||||
import org.apache.camel.Exchange;
|
import org.apache.camel.Exchange;
|
||||||
import org.apache.camel.Processor;
|
import org.apache.camel.Processor;
|
||||||
import sysmon.shared.MetricResult;
|
|
||||||
|
|
||||||
public class IncomingMetricProcessor implements Processor {
|
public class IncomingMetricProcessor implements Processor {
|
||||||
|
|
||||||
public void process(Exchange exchange) throws Exception {
|
public void process(Exchange exchange) throws Exception {
|
||||||
|
|
||||||
MetricResult payload = exchange.getIn().getBody(MetricResult.class);
|
//MetricResult payload = exchange.getIn().getBody(MetricResult.class);
|
||||||
//log.info("I am going to send this data to InfluxDB.");
|
//log.info("I am going to send this data to InfluxDB.");
|
||||||
//log.info(payload.toString());
|
//log.info(payload.toString());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue