Merge pull request #318 from gportay/fix-invalid-cpu-placeholder

print_cpu_usage: fix invalid %cpu placeholder output
This commit is contained in:
Ingo Bürk 2018-10-26 09:24:45 +02:00 committed by GitHub
commit be5f38e0a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -151,7 +151,7 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format, const
}
#if defined(LINUX)
else if (BEGINS_WITH(walk + 1, "cpu")) {
int number = 0;
int number = -1;
sscanf(walk + 1, "cpu%d", &number);
if (number < 0 || number >= cpu_count) {
fprintf(stderr, "provided CPU number '%d' above detected number of CPU %d\n", number, cpu_count);

View File

@ -0,0 +1,7 @@
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
print "CPU: \n";

View File

@ -0,0 +1,9 @@
general {
output_format = "none"
}
order += "cpu_usage"
cpu_usage {
format = "CPU: %cpu"
}