openbsd-ports/sysutils/conky/patches/patch-src_openbsd_c
dcoppa 237c8f2f08 - Reenable $addr and $if_up
- Enable the new SMP code (allowing the user to actually see multiple
  cores)
- Enable RES and VSIZE display in $top

From Pascal Stumpf: thanks!

ok benoit@, jasper@
2011-09-11 18:53:28 +00:00

246 lines
5.5 KiB
Plaintext

$OpenBSD: patch-src_openbsd_c,v 1.13 2011/09/11 18:53:28 dcoppa Exp $
declarations in common.h got changed, but upstream forgot to do the
corresponding changes into openbsd.c
Adapt to new OpenBSD kinfo_proc API.
--- src/openbsd.c.orig Tue Oct 5 23:29:36 2010
+++ src/openbsd.c Mon Jul 18 14:04:55 2011
@@ -140,7 +140,7 @@ int check_mount(char *s)
return 0;
}
-void update_uptime()
+int update_uptime()
{
int mib[2] = { CTL_KERN, KERN_BOOTTIME };
struct timeval boottime;
@@ -155,9 +155,10 @@ void update_uptime()
NORM_ERR("Could not get uptime");
info.uptime = 0;
}
+ return 0;
}
-void update_meminfo()
+int update_meminfo()
{
static int mib[2] = { CTL_VM, VM_METER };
struct vmtotal vmtotal;
@@ -194,9 +195,10 @@ void update_meminfo()
info.swap = 0;
info.swapfree = 0;
}
+ return 0;
}
-void update_net_stats()
+int update_net_stats()
{
struct net_stat *ns;
double delta;
@@ -207,11 +209,11 @@ void update_net_stats()
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001) {
- return;
+ return 0;
}
if (getifaddrs(&ifap) < 0) {
- return;
+ return 0;
}
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
@@ -266,28 +268,32 @@ void update_net_stats()
}
freeifaddrs(ifap);
+ return 0;
}
-void update_total_processes()
+int update_total_processes()
{
int n_processes;
+ int max_size = sizeof(struct kinfo_proc);
+
kvm_init();
- kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
+ kvm_getprocs(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
info.procs = n_processes;
+ return 0;
}
-void update_running_processes()
+int update_running_processes()
{
- struct kinfo_proc2 *p;
+ struct kinfo_proc *p;
int n_processes;
int i, cnt = 0;
kvm_init();
- int max_size = sizeof(struct kinfo_proc2);
+ int max_size = sizeof(struct kinfo_proc);
- p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
+ p = kvm_getprocs(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
for (i = 0; i < n_processes; i++) {
if (p[i].p_stat == SRUN) {
cnt++;
@@ -295,10 +301,11 @@ void update_running_processes()
}
info.run_procs = cnt;
+ return 0;
}
/* new SMP code can be enabled by commenting the following line */
-#define OLDCPU
+/* #define OLDCPU */
#ifdef OLDCPU
struct cpu_load_struct {
@@ -343,7 +350,7 @@ void get_cpu_count()
#endif
}
-void update_cpu_usage()
+int update_cpu_usage()
{
#ifdef OLDCPU
int mib[2] = { CTL_KERN, KERN_CPTIME };
@@ -427,9 +434,10 @@ void update_cpu_usage()
oldtotal[i] = total;
}
#endif
+ return 0;
}
-void update_load_average()
+int update_load_average()
{
double v[3];
@@ -438,6 +446,7 @@ void update_load_average()
info.loadavg[0] = (float) v[0];
info.loadavg[1] = (float) v[1];
info.loadavg[2] = (float) v[2];
+ return 0;
}
#define OBSD_MAX_SENSORS 256
@@ -606,10 +615,11 @@ char get_freq(char *p_client_buffer, size_t client_buf
return 1;
}
-void update_top()
+int update_top()
{
kvm_init();
proc_find_top(info.cpu, info.memu);
+ return 0;
}
#if 0
@@ -665,19 +675,11 @@ cleanup:
}
#endif
-void clear_diskio_stats()
+int update_diskio()
{
+ return 0; /* XXX: implement? hifi: not sure how */
}
-struct diskio_stat *prepare_diskio_stat(const char *s)
-{
-}
-
-void update_diskio()
-{
- return; /* XXX: implement? hifi: not sure how */
-}
-
/* While topless is obviously better, top is also not bad. */
int comparecpu(const void *a, const void *b)
@@ -708,7 +710,7 @@ int comparemem(const void *a, const void *b)
inline void proc_find_top(struct process **cpu, struct process **mem)
{
- struct kinfo_proc2 *p;
+ struct kinfo_proc *p;
int n_processes;
int i, j = 0;
struct process *processes;
@@ -730,9 +732,9 @@ inline void proc_find_top(struct process **cpu, struct
/* translate bytes into page count */
total_pages = usermem / pagesize;
- int max_size = sizeof(struct kinfo_proc2);
+ int max_size = sizeof(struct kinfo_proc);
- p = kvm_getproc2(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
+ p = kvm_getprocs(kd, KERN_PROC_ALL, 0, max_size, &n_processes);
processes = malloc(n_processes * sizeof(struct process));
for (i = 0; i < n_processes; i++) {
@@ -740,6 +742,8 @@ inline void proc_find_top(struct process **cpu, struct
processes[j].pid = p[i].p_pid;
processes[j].name = strndup(p[i].p_comm, text_buffer_size);
processes[j].amount = 100.0 * p[i].p_pctcpu / FSCALE;
+ processes[j].vsize = p[i].p_vm_map_size;
+ processes[j].rss = p[i].p_vm_rssize * PAGE_SIZE;
j++;
}
}
@@ -752,6 +756,8 @@ inline void proc_find_top(struct process **cpu, struct
tmp->pid = processes[i].pid;
tmp->amount = processes[i].amount;
tmp->name = strndup(processes[i].name, text_buffer_size);
+ tmp->vsize = processes[i].vsize;
+ tmp->rss = processes[i].rss;
ttmp = mem[i];
mem[i] = tmp;
@@ -769,6 +775,8 @@ inline void proc_find_top(struct process **cpu, struct
tmp->pid = processes[i].pid;
tmp->amount = processes[i].amount;
tmp->name = strndup(processes[i].name, text_buffer_size);
+ tmp->vsize = processes[i].vsize;
+ tmp->rss = processes[i].rss;
ttmp = cpu[i];
cpu[i] = tmp;
@@ -784,7 +792,6 @@ inline void proc_find_top(struct process **cpu, struct
free(processes);
}
-#if defined(i386) || defined(__i386__)
#define APMDEV "/dev/apm"
#define APM_UNKNOWN 255
@@ -908,7 +915,6 @@ char *get_apm_battery_time()
return out;
}
-#endif
/* empty stubs so conky links */
void prepare_update()
@@ -923,8 +929,4 @@ int get_entropy_avail(unsigned int *val)
int get_entropy_poolsize(unsigned int *val)
{
return 1;
-}
-
-void free_all_processes(void)
-{
}