Cleanup and initial test of build pipeline.

This commit is contained in:
Mark Nellemann 2021-05-21 17:00:47 +02:00
parent 1b60d58df3
commit 0124b21692
12 changed files with 110 additions and 126 deletions

22
bitbucket-pipelines.yml Normal file
View 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

View File

@ -1,4 +1,4 @@
version=0.0.1-SNAPSHOT
version=0.0.2
pf4jVersion=3.6.0
slf4jVersion=1.7.30
camelVersion=3.7.4

View File

@ -1,8 +1,5 @@
package sysmon.plugins.os_aix;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -11,25 +8,21 @@ import java.util.regex.Pattern;
public class AixDiskStat {
private static final Logger log = LoggerFactory.getLogger(AixDiskStat.class);
// Disks: % tm_act Kbps tps Kb_read Kb_wrtn
// 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 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 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 Long kbRead = 0L; // The total number of KB read.
private Long kbWritten = 0L; // The total number of KB written.
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 long kbRead = 0L; // The total number of KB read.
private long kbWritten = 0L; // The total number of KB written.
AixDiskStat(List<String> lines) {
for (String line : lines) {
if (line.startsWith("hdisk")) {
Matcher matcher = pattern.matcher(line);
if (matcher.find() && matcher.groupCount() == 6) {
@ -40,24 +33,21 @@ public class AixDiskStat {
kbRead += Long.parseLong(matcher.group(5));
kbWritten += Long.parseLong(matcher.group(6));
}
}
}
}
public Map<String, String> getTags() {
Map<String, String> tags = new HashMap<>();
return tags;
return new HashMap<>();
}
public Map<String, Object> getFields() {
Map<String, Object> fields = new HashMap<>();
fields.put("reads", kbRead * 1024); // from Kb to bytes
fields.put("writes", kbWritten * 1024); // from Kb to bytes
fields.put("kbps", kbps);
fields.put("tps", tps);
fields.put("kbps", (int) kbps);
fields.put("tps", (int) tps);
return fields;
}
}

View File

@ -1,10 +1,5 @@
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.List;
import java.util.Map;
@ -13,17 +8,15 @@ import java.util.regex.Pattern;
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 Long total;
private Long used;
private Long free;
private Long pin;
private Long virtual;
private Long available;
private Long paged;
private long total;
private long used;
private long free;
private long pin;
private long virtual;
private long available;
private long paged;
AixMemoryStat(List<String> lines) {
for (String line : lines) {
@ -43,15 +36,14 @@ public class AixMemoryStat {
public Map<String, String> getTags() {
Map<String, String> tags = new HashMap<>();
return tags;
return new HashMap<>();
}
public Map<String, Object> getFields() {
double tmp = ((double) (total - available) / total ) * 100;
BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
float usage = ((float) (total - available) / total ) * 100;
//BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
Map<String, Object> fields = new HashMap<>();
fields.put("total", total);
@ -61,7 +53,7 @@ public class AixMemoryStat {
fields.put("virtual", virtual);
fields.put("available", available);
fields.put("paged", paged);
fields.put("usage", usage.doubleValue());
fields.put("usage", usage);
return fields;
}

View File

@ -1,8 +1,5 @@
package sysmon.plugins.os_aix;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -11,8 +8,6 @@ import java.util.regex.Pattern;
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
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 mode;
private Integer smt;
private Integer lcpu;
private Integer psize;
private Float ent;
private int smt;
private int lcpu;
private int psize;
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 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 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 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 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 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 physc; // Indicates the number of physical processors 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.
AixProcessorStat(List<String> lines) {
@ -54,7 +49,6 @@ public class AixProcessorStat {
if (line.startsWith("type=")) {
//type=Shared mode=Uncapped smt=8 lcpu=4 mem=4101120 kB cpus=24 ent=4.00
Matcher matcher = patternLinux.matcher(line);
if (matcher.find() && matcher.groupCount() == 7) {
type = matcher.group(1);
@ -84,31 +78,31 @@ public class AixProcessorStat {
}
public Float getUser() {
public float getUser() {
return user;
}
public Float getSys() {
public float getSys() {
return sys;
}
public Float getIdle() {
public float getIdle() {
return idle;
}
public Float getWait() {
public float getWait() {
return wait;
}
public Float getPhysc() {
public float getPhysc() {
return physc;
}
public Float getEntc() {
public float getEntc() {
return entc;
}
public Float getLbusy() {
public float getLbusy() {
return lbusy;
}
@ -117,8 +111,7 @@ public class AixProcessorStat {
}
public Map<String, String> getTags() {
Map<String, String> tags = new HashMap<>();
return tags;
return new HashMap<>();
}
public Map<String, Object> getFields() {

View File

@ -18,8 +18,8 @@ class AixDiskTest extends Specification {
//stats.getTags().get("device") == "hdisk0"
stats.getFields().get("reads") == 757760L
stats.getFields().get("writes") == 12288L
stats.getFields().get("kbps") == 752.0F
stats.getFields().get("tps") == 81.0F
stats.getFields().get("kbps") == 752L
stats.getFields().get("tps") == 81L
}

View File

@ -15,14 +15,14 @@ class AixMemoryTest extends Specification {
AixMemoryStat stats = extension.processCommandOutput(lines)
then:
stats.getFields().get("total") == 4194304l
stats.getFields().get("used") == 4065060l
stats.getFields().get("free") == 129244l
stats.getFields().get("pin") == 1878240l
stats.getFields().get("virtual") == 2784988l
stats.getFields().get("available") == 1058012l
stats.getFields().get("paged") == 524288l
stats.getFields().get("usage") == 74.78d
stats.getFields().get("total") == 4194304L
stats.getFields().get("used") == 4065060L
stats.getFields().get("free") == 129244L
stats.getFields().get("pin") == 1878240L
stats.getFields().get("virtual") == 2784988L
stats.getFields().get("available") == 1058012L
stats.getFields().get("paged") == 524288L
stats.getFields().get("usage") == 74.775024f
}

View File

@ -8,26 +8,23 @@ import java.util.Map;
public class LinuxDiskStat {
private static final Logger log = LoggerFactory.getLogger(LinuxDiskStat.class);
private String device;
private final long iotime;
private final long reads;
private final long writes;
private final double kbps;
private final double tps;
private final long kbps;
private final long tps;
LinuxDiskStat(LinuxDiskProcLine proc1, LinuxDiskProcLine proc2) {
iotime = proc2.getTimeSpentOnIo() - proc1.getTimeSpentOnIo();
writes = proc2.getBytesWritten() - proc1.getBytesWritten();
reads = proc2.getBytesRead() - proc1.getBytesRead();
kbps = ((double) writes + reads) / 1024;
kbps = (writes + reads) / 1024;
tps = proc2.getTransactions() - proc1.getTransactions();
}
public Map<String, String> getTags() {
Map<String, String> tags = new HashMap<>();
return tags;
return new HashMap<>();
}
public Map<String, Object> getFields() {

View File

@ -1,10 +1,5 @@
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.List;
import java.util.Map;
@ -13,8 +8,6 @@ import java.util.regex.Pattern;
public class LinuxMemoryStat {
private static final Logger log = LoggerFactory.getLogger(LinuxMemoryStat.class);
/*
total used free shared buff/cache available
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 Long total;
private Long used;
private Long free;
private Long shared;
private Long buffers;
private Long available;
private String mode;
private long total;
private long used;
private long free;
private long shared;
private long buffers;
private long available;
//private String mode;
LinuxMemoryStat(List<String> lines) {
for (String line : lines) {
@ -40,7 +33,6 @@ public class LinuxMemoryStat {
shared = Long.parseLong(matcher.group(4));
buffers = Long.parseLong(matcher.group(5));
available = Long.parseLong(matcher.group(6));
break;
}
}
@ -48,15 +40,14 @@ public class LinuxMemoryStat {
public Map<String, String> getTags() {
Map<String, String> tags = new HashMap<>();
return tags;
return new HashMap<>();
}
public Map<String, Object> getFields() {
double tmp = ((double) (total - available) / total ) * 100;
BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
float usage = ((float) (total - available) / total ) * 100;
//BigDecimal usage = new BigDecimal(tmp).setScale(2, RoundingMode.HALF_UP);
Map<String, Object> fields = new HashMap<>();
fields.put("total", total);
@ -65,7 +56,7 @@ public class LinuxMemoryStat {
fields.put("shared", shared);
fields.put("buffers", buffers);
fields.put("available", available);
fields.put("usage", usage.doubleValue());
fields.put("usage", usage);
return fields;
}

View File

@ -3,16 +3,16 @@ package sysmon.plugins.os_linux;
public class LinuxProcessorProcLine {
private final String cpuName;
private final Long userTime;
private final Long niceTime;
private final Long systemTime;
private final Long idleTime;
private final Long ioWaitTime;
private final Long irqTime;
private final Long softIrqTime;
private final Long stealTime;
private final Long guestTime;
private final Long guestNiceTime;
private final long userTime;
private final long niceTime;
private final long systemTime;
private final long idleTime;
private final long ioWaitTime;
private final long irqTime;
private final long softIrqTime;
private final long stealTime;
private final long guestTime;
private final long guestNiceTime;
public LinuxProcessorProcLine(String procString) {
@ -40,55 +40,55 @@ public class LinuxProcessorProcLine {
return cpuName;
}
public Long getUserTime() {
public long getUserTime() {
return userTime;
}
public Long getNiceTime() {
public long getNiceTime() {
return niceTime;
}
public Long getSystemTime() {
public long getSystemTime() {
return systemTime;
}
public Long getIdleTime() {
public long getIdleTime() {
return idleTime;
}
public Long getIoWaitTime() {
public long getIoWaitTime() {
return ioWaitTime;
}
public Long getIrqTime() {
public long getIrqTime() {
return irqTime;
}
public Long getSoftIrqTime() {
public long getSoftIrqTime() {
return softIrqTime;
}
public Long getStealTime() {
public long getStealTime() {
return stealTime;
}
public Long getGuestTime() {
public long getGuestTime() {
return guestTime;
}
public Long getGuestNiceTime() {
public long getGuestNiceTime() {
return guestNiceTime;
}
public Long getCombinedIdleTime() {
public long getCombinedIdleTime() {
return idleTime + ioWaitTime;
}
public Long getCombinedWorkTime() {
public long getCombinedWorkTime() {
return userTime + niceTime + systemTime + irqTime + softIrqTime + stealTime + guestTime + guestNiceTime;
}
public Long getCombinedTime() {
public long getCombinedTime() {
return getCombinedIdleTime() + getCombinedWorkTime();
}

View File

@ -21,7 +21,7 @@ class LinuxMemoryTest extends Specification {
stats.getFields().get("shared") == 639780l
stats.getFields().get("buffers") == 5574480l
stats.getFields().get("available") == 9192992l
stats.getFields().get("usage") == 42.79d
stats.getFields().get("usage") == 42.79113f
}

View File

@ -2,13 +2,12 @@ package sysmon.server.bean;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import sysmon.shared.MetricResult;
public class IncomingMetricProcessor implements Processor {
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(payload.toString());