Merge pull request #1104 from influxdata/hotfix/windows-hosts

Hotfix/windows hosts
pull/1101/head^2
Chris Goller 2017-03-28 16:47:39 -05:00 committed by GitHub
commit 52e70c77ff
3 changed files with 32 additions and 25 deletions

View File

@ -1,6 +1,8 @@
## v1.2.0 [unreleased]
### Bug Fixes
1. [#1104](https://github.com/influxdata/chronograf/pull/1104): Fix windows hosts on host list
### Features
### UI Improvements

View File

@ -5,7 +5,7 @@ import _ from 'lodash';
export function getCpuAndLoadForHosts(proxyLink, telegrafDB) {
return proxy({
source: proxyLink,
query: `select mean(usage_user) from cpu where cpu = 'cpu-total' and time > now() - 10m group by host; select mean("load1") from "system" where time > now() - 10m group by host; select mean("Percent_Processor_Time") from win_cpu where time > now() - 10m group by host; select mean("Processor_Queue_Length") from win_system where time > now() - 10s group by host; select non_negative_derivative(mean(uptime)) as deltaUptime from "system" where time > now() - 10m group by host, time(1m) fill(0); show tag values from system with key = "host"`,
query: `select mean(usage_user) from cpu where cpu = 'cpu-total' and time > now() - 10m group by host; select mean("load1") from "system" where time > now() - 10m group by host; select mean("Percent_Processor_Time") from win_cpu where time > now() - 10m group by host; select mean("Processor_Queue_Length") from win_system where time > now() - 10s group by host; select non_negative_derivative(mean(uptime)) as deltaUptime from "system" where time > now() - 10m group by host, time(1m) fill(0); show tag values from /win_system|system/ with key = "host"`,
db: telegrafDB,
}).then((resp) => {
const hosts = {};
@ -15,18 +15,20 @@ export function getCpuAndLoadForHosts(proxyLink, telegrafDB) {
const winCPUSeries = _.get(resp, ['data', 'results', '2', 'series'], []);
const winLoadSeries = _.get(resp, ['data', 'results', '3', 'series'], []);
const uptimeSeries = _.get(resp, ['data', 'results', '4', 'series'], []);
const allHostsSeries = _.get(resp, ['data', 'results', '5', 'series', '0'], []);
const allHostsSeries = _.get(resp, ['data', 'results', '5', 'series'], []);
const hostnameIndex = allHostsSeries.columns.findIndex((col) => col === 'value');
allHostsSeries.values.forEach((v) => {
const hostname = v[hostnameIndex];
hosts[hostname] = {
name: hostname,
deltaUptime: -1,
cpu: 0.0,
load: 0.0,
};
});
allHostsSeries.forEach((s) => {
const hostnameIndex = s.columns.findIndex((col) => col === 'value')
s.values.forEach((v) => {
const hostname = v[hostnameIndex]
hosts[hostname] = {
name: hostname,
deltaUptime: -1,
cpu: 0.0,
load: 0.0,
}
})
})
cpuSeries.forEach((s) => {
const meanIndex = s.columns.findIndex((col) => col === 'mean');
@ -67,20 +69,25 @@ export async function getAllHosts(proxyLink, telegrafDB) {
try {
const resp = await proxy({
source: proxyLink,
query: 'show tag values from system with key = "host"',
query: 'show tag values from /win_system|system/ with key = "host"',
db: telegrafDB,
});
const allHostsSeries = _.get(resp, ['data', 'results', '0', 'series', '0'], []);
const hostnameIndex = allHostsSeries.columns.findIndex((col) => col === 'value');
return allHostsSeries.values.reduce((hosts, v) => {
const hostname = v[hostnameIndex];
hosts[hostname] = {
name: hostname,
};
return hosts;
}, {});
const hosts = {}
const allHostsSeries = _.get(resp, ['data', 'results', '0', 'series'], [])
allHostsSeries.forEach((s) => {
const hostnameIndex = s.columns.findIndex((col) => col === 'value')
s.values.forEach((v) => {
const hostname = v[hostnameIndex]
hosts[hostname] = {
name: hostname,
}
})
})
return hosts
} catch (error) {
console.error(error); // eslint-disable-line no-console
console.error(error) // eslint-disable-line no-console
}
}

View File

@ -169,8 +169,6 @@ const HostRow = React.createClass({
stateStr = "table-dot dot-critical";
} else if (host.deltaUptime > 0) {
stateStr = "table-dot dot-success";
} else {
stateStr = "table-dot dot-danger";
}
return (