Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only show 1-minute CPU warning #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ exports.register = function(server, options, next) {
'15-minute': data.osload[2].toFixed(3)
});
}
// warn if any of the CPU load averages exceeds the expected threshold:
for (let i = 0; i < 3; i++) {
const cpuLabel = ['1-minute', '5-minute', '15-minute'][i];
const cpuThreshold = options.cpuThresholds[i];
const cpuAvg = data.osload[i];
if (cpuAvg > cpuThreshold) {
server.log(['ops', 'cpu', 'warning', 'threshold'], `Average ${cpuLabel} CPU load of ${cpuAvg} exceeds threshold of ${cpuThreshold}`);
}
// warn if the 1-minute CPU load averages exceeds the expected threshold:
const cpuThreshold = options.cpuThresholds[0];
const cpuAvg = data.osload[0];
if (cpuAvg > cpuThreshold) {
server.log(['ops', 'cpu', 'warning', 'threshold'], `Average 1-minute CPU load of ${cpuAvg} exceeds threshold of ${cpuThreshold}`);
}
}

Expand Down