mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Started fixing ${top} and ${top_mem} stuff on
FreeBSD: - fixed ${top_mem} sorting - fixed crash if using ${top_mem name 1} git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@600 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
838674bbb3
commit
c2fb9f583a
@ -34,6 +34,10 @@
|
||||
#define KELVTOC(x) ((x - 2732) / 10.0)
|
||||
#define MAXSHOWDEVS 16
|
||||
|
||||
#if 0
|
||||
#define FREEBSD_DEBUG
|
||||
#endif
|
||||
|
||||
inline void proc_find_top(struct process **cpu, struct process **mem);
|
||||
|
||||
u_int64_t diskio_prev = 0;
|
||||
@ -273,7 +277,7 @@ long cpu_used, oldtotal, oldused;
|
||||
|
||||
void get_cpu_count()
|
||||
{
|
||||
int cpu_count = 0;
|
||||
/* int cpu_count = 0; */
|
||||
|
||||
/* XXX
|
||||
* FreeBSD doesn't allow to get per CPU load stats
|
||||
@ -625,11 +629,43 @@ inline void proc_find_top(struct process **cpu, struct process **mem)
|
||||
}
|
||||
}
|
||||
|
||||
qsort(processes, j, sizeof(struct process), comparemem);
|
||||
for (i = 0; i < 10; mem[i] = &processes[i], i++);
|
||||
qsort(processes, j - 1, sizeof(struct process), comparemem);
|
||||
for (i = 0; i < 10; i++) {
|
||||
struct process *tmp;
|
||||
|
||||
qsort(processes, j, sizeof(struct process), comparecpu);
|
||||
for (i = 0; i < 10; cpu[i] = &processes[i], i++);
|
||||
tmp = malloc(sizeof(struct process));
|
||||
tmp->pid = processes[i].pid;
|
||||
tmp->amount = processes[i].amount;
|
||||
tmp->totalmem = processes[i].totalmem;
|
||||
tmp->name = strdup(processes[i].name);
|
||||
|
||||
mem[i] = tmp;
|
||||
}
|
||||
|
||||
qsort(processes, j - 1, sizeof(struct process), comparecpu);
|
||||
for (i = 0; i < 10; i++) {
|
||||
struct process *tmp;
|
||||
|
||||
tmp = malloc(sizeof(struct process));
|
||||
tmp->pid = processes[i].pid;
|
||||
tmp->amount = processes[i].amount;
|
||||
tmp->totalmem = processes[i].totalmem;
|
||||
tmp->name = strdup(processes[i].name);
|
||||
|
||||
cpu[i] = tmp;
|
||||
}
|
||||
|
||||
#if defined(FREEBSD_DEBUG)
|
||||
printf("=====\nmem\n");
|
||||
for (i = 0; i < 10; i++) {
|
||||
printf("%d: %s(%d) %.2f\n", i, mem[i]->name, mem[i]->pid, mem[i]->totalmem);
|
||||
}
|
||||
|
||||
/* printf("=====\ncpu\n");
|
||||
for (i = 0; i <= 10; i++) {
|
||||
printf("%d: %s\n", i, cpu[i]->name);
|
||||
}*/
|
||||
#endif
|
||||
|
||||
free(processes);
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user