Compare commits

...

1 Commits

Author SHA1 Message Date
Taylor McKinnon 9c76001b44 add test changes 2021-08-05 15:29:08 -07:00
4 changed files with 91 additions and 16 deletions

View File

@ -1,19 +1,19 @@
FROM golang:1.14-alpine as builder
# FROM golang:1.14-alpine as builder
ENV WARP10_EXPORTER_VERSION 2.7.5
# ENV WARP10_EXPORTER_VERSION 2.7.5
RUN apk add zip unzip build-base \
&& wget -q -O exporter.zip https://github.com/centreon/warp10-sensision-exporter/archive/refs/heads/master.zip \
&& unzip exporter.zip \
&& cd warp10-sensision-exporter-master \
&& go mod download \
&& cd tools \
&& go run generate_sensision_metrics.go ${WARP10_EXPORTER_VERSION} \
&& cp sensision.go ../collector/ \
&& cd .. \
&& go build -a -o /usr/local/go/warp10_sensision_exporter
# RUN apk add zip unzip build-base \
# && wget -q -O exporter.zip https://github.com/centreon/warp10-sensision-exporter/archive/refs/heads/master.zip \
# && unzip exporter.zip \
# && cd warp10-sensision-exporter-master \
# && go mod download \
# && cd tools \
# && go run generate_sensision_metrics.go ${WARP10_EXPORTER_VERSION} \
# && cp sensision.go ../collector/ \
# && cd .. \
# && go build -a -o /usr/local/go/warp10_sensision_exporter
FROM warp10io/warp10:2.7.5
FROM warp10io/warp10:master
ENV S6_VERSION 2.0.0.1
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS 2
@ -40,11 +40,15 @@ RUN wget https://github.com/just-containers/s6-overlay/releases/download/v${S6_V
ADD ./images/warp10/warp10-ext-protobuf-1.2.2-uberjar.jar /opt/warp10/lib/
# Install Sensision exporter
COPY --from=builder /usr/local/go/warp10_sensision_exporter /usr/local/bin/warp10_sensision_exporter
# COPY --from=builder /usr/local/go/warp10_sensision_exporter /usr/local/bin/warp10_sensision_exporter
ADD https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.16.1/jmx_prometheus_javaagent-0.16.1.jar /opt/jmx_prom_agent.jar
RUN printf '---\nstartDelaySeconds: 0' > /opt/jmx_prom_agent.yaml
ADD ./images/warp10/s6 /etc
ADD ./warpscript /usr/local/share/warpscript
ADD ./images/warp10/static.tokens /
ENV WARP10_VERSION 2.8.1-95-g73e7de80
CMD /init

View File

@ -1,4 +1,5 @@
#!/usr/bin/with-contenv sh
echo 'Starting sensision exporter'
exec warp10_sensision_exporter --warp10.url=http://localhost:${SENSISION_PORT}/metrics
exec tail -f /dev/null
# exec warp10_sensision_exporter --warp10.url=http://localhost:${SENSISION_PORT}/metrics

View File

@ -19,7 +19,7 @@ if [ -z "$WARP10_HEAP_MAX" ]; then
WARP10_HEAP_MAX=4g
fi
JAVA_OPTS="-Djava.awt.headless=true -Xms${WARP10_HEAP} -Xmx${WARP10_HEAP_MAX} -XX:+UseG1GC ${JAVA_OPTS}"
JAVA_OPTS="-javaagent:/opt/jmx_prom_agent.jar=4803:/opt/jmx_prom_agent.yaml -Djava.awt.headless=true -Xms${WARP10_HEAP} -Xmx${WARP10_HEAP_MAX} -XX:+UseG1GC ${JAVA_OPTS}"
SENSISION_OPTS=
if [ -n "$ENABLE_SENSISION" ]; then

70
tools/delete.js Normal file
View File

@ -0,0 +1,70 @@
/* eslint-disable no-console */
const { clients } = require('./libV2/warp10');
const client = clients[0];
const secUSecs = 1000 * 1000;
const twoHourUSecs = secUSecs * 60 * 60 * 2;
async function getOldest() {
const resp = await client.exec({
macro: 'utapi/findOldestRecord',
params: {
class: '~.*',
labels: {},
},
});
if (!resp.result || resp.result.length !== 1) {
console.log('failed to fetch oldest record timestamp. expiration failed');
return null;
}
const oldestTimestamp = resp.result[0];
if (oldestTimestamp === -1) {
console.log('No records found, nothing to delete.');
return null;
}
return oldestTimestamp;
}
async function doDelete(start) {
const end = start + secUSecs - 1;
const params = {
className: '~.*',
labels: {},
start,
end,
};
console.log(`delete ${start} - ${end} at ${(new Date()).toISOString()}`);
try {
const deleted = await client.delete(params);
console.log(`deleted from gts ${JSON.stringify(deleted)}`);
console.log('done, sleeping');
// sleep for 5 secs
setTimeout(() => doDelete(start + secUSecs), 5000);
} catch (err) {
console.log(err);
console.log('Error during deletion retrying in 5 secs');
setTimeout(() => doDelete(start), 5000);
}
}
async function main() {
const start = await getOldest();
if (start === null) {
setTimeout(main, 30000);
return;
}
if (start >= (Date.now() * 1000) - twoHourUSecs) {
console.log('Waiting for records to reach 2 hours old');
setTimeout(main, 30000);
return;
}
setImmediate(() => doDelete(start - 1));
}
main();