Apply style to all client files.
This commit is contained in:
1 parent
27d1bc1087
commit
46b0c5cf77
14 files changed
+316
-383
No files matched your search
+34
-43
@@ -1,40 +1,31 @@
|
||||
/** \file clients/lcdproc/cpu_smp.c
|
||||
* Display cpu info for multi-processor machines.
|
||||
*
|
||||
* Adapted from cpu.c.
|
||||
*
|
||||
* Really boring for the moment, it only shows a current usage percentage graph
|
||||
* for each CPU.
|
||||
*
|
||||
* It will handle up to 2xlcd_hgt or 8 CPUs, whichever is less. If there are
|
||||
* more CPUs than lines on the LCD, it puts 2 CPUs per line, splitting the line
|
||||
* in half. Otherwise, it uses one line per CPU.
|
||||
*
|
||||
* If the number of lines used to display the bar graphs for the CPUs is smaller
|
||||
* than the LCD's height, a title line is introduced, so that the screen looks
|
||||
* similar to other lcdproc screens.
|
||||
* In all other cases (i.e. \#CPUs == LCD height or \#CPUs >= 2 * LCD height),
|
||||
* the title is left out to display as many CPUs graphs as possible.
|
||||
*/
|
||||
* Display cpu info for multi-processor machines.
|
||||
*
|
||||
* Adapted from cpu.c.
|
||||
*
|
||||
* Really boring for the moment, it only shows a current usage percentage graph
|
||||
* for each CPU.
|
||||
*
|
||||
* It will handle up to 2xlcd_hgt or 8 CPUs, whichever is less. If there are
|
||||
* more CPUs than lines on the LCD, it puts 2 CPUs per line, splitting the line
|
||||
* in half. Otherwise, it uses one line per CPU.
|
||||
*
|
||||
* If the number of lines used to display the bar graphs for the CPUs is smaller
|
||||
* than the LCD's height, a title line is introduced, so that the screen looks
|
||||
* similar to other lcdproc screens.
|
||||
* In all other cases (i.e. \#CPUs == LCD height or \#CPUs >= 2 * LCD height),
|
||||
* the title is left out to display as many CPUs graphs as possible.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (C) 2000 J Robert Ray
|
||||
* Copyright (C) 2006,7 Peter Marschall
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
* Copyright (C) 2000 J Robert Ray
|
||||
* Copyright (C) 2006,2007 Peter Marschall
|
||||
*
|
||||
* This file is part of lcdproc, the lcdproc client.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -65,20 +56,20 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
#undef CPU_BUF_SIZE
|
||||
#define CPU_BUF_SIZE 4
|
||||
int z;
|
||||
static float cpu[MAX_CPUS][CPU_BUF_SIZE + 1]; // last buffer is scratch
|
||||
static float cpu[MAX_CPUS][CPU_BUF_SIZE + 1]; /* last buffer is scratch */
|
||||
load_type load[MAX_CPUS];
|
||||
int num_cpus = MAX_CPUS;
|
||||
int bar_size;
|
||||
int lines_used;
|
||||
|
||||
// get SMP load - inform about max #CPUs allowed
|
||||
/* get SMP load - inform about max #CPUs allowed */
|
||||
machine_get_smpload(load, &num_cpus);
|
||||
|
||||
// restrict num_cpus to max. twice the display height
|
||||
/* restrict num_cpus to max. twice the display height */
|
||||
if (num_cpus > 2 * lcd_hgt)
|
||||
num_cpus = 2 * lcd_hgt;
|
||||
|
||||
// 2 CPUs per line if more CPUs than lines
|
||||
/* 2 CPUs per line if more CPUs than lines */
|
||||
bar_size = (num_cpus > lcd_hgt) ? (lcd_wid / 2 - 6) : (lcd_wid - 6);
|
||||
lines_used = (num_cpus > lcd_hgt) ? (num_cpus + 1) / 2 : num_cpus;
|
||||
|
||||
@@ -87,7 +78,7 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
|
||||
sock_send_string(sock, "screen_add P\n");
|
||||
|
||||
// print title if he have room for it
|
||||
/* print title if he have room for it */
|
||||
if (lines_used < lcd_hgt) {
|
||||
sock_send_string(sock, "widget_add P title title\n");
|
||||
sock_printf(sock, "widget_set P title {SMP CPU %s}\n", get_hostname());
|
||||
@@ -119,16 +110,16 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
float value = 0.0;
|
||||
int i, n;
|
||||
|
||||
// Shift values over by one
|
||||
/* Shift values over by one */
|
||||
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
||||
cpu[z][i] = cpu[z][i + 1];
|
||||
|
||||
// Read new data
|
||||
/* Read new data */
|
||||
cpu[z][CPU_BUF_SIZE-1] = (load[z].total > 0L)
|
||||
? (((float) load[z].user + (float) load[z].system + (float) load[z].nice) / (float) load[z].total) * 100.0
|
||||
: 0.0;
|
||||
|
||||
// Average values for final result
|
||||
/* Average values for final result */
|
||||
for (i = 0; i < CPU_BUF_SIZE; i++) {
|
||||
value += cpu[z][i];
|
||||
}
|
||||
@@ -139,4 +130,4 @@ cpu_smp_screen (int rep, int display, int *flags_ptr)
|
||||
}
|
||||
|
||||
return 0;
|
||||
} // End cpu_screen()
|
||||
}
|
||||
Reference in new issue
Block a user