* Please see COPYING for details
*
* Copyright (c) 2007 Toni Spets
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
#include "conky.h"
#include "diskio.h"
#include "logging.h"
+#include "net_stat.h"
#include "openbsd.h"
#include "top.h"
info.loadavg[2] = (float) v[2];
}
+#define OBSD_MAX_SENSORS 256
+static struct obsd_sensors_struct {
+ int device;
+ float temp[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+ unsigned int fan[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+ float volt[MAXSENSORDEVICES][OBSD_MAX_SENSORS];
+} obsd_sensors;
+
/* read sensors from sysctl */
void update_obsd_sensors()
{
init_sensors = 1;
}
+void parse_obsd_sensor(struct text_object *obj, const char *arg)
+{
+ if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
+ || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
+ obj->data.l = 0;
+ NORM_ERR("Invalid sensor number!");
+ } else
+ obj->data.l = atoi(&arg[0]);
+}
+
+void print_obsd_sensors_temp(struct text_object *obj, char *p, int p_max_size)
+{
+ obsd_sensors.device = sensor_device;
+ update_obsd_sensors();
+ temp_print(p, p_max_size,
+ obsd_sensors.temp[obsd_sensors.device][obj->data.l],
+ TEMP_CELSIUS);
+}
+
+void print_obsd_sensors_fan(struct text_object *obj, char *p, int p_max_size)
+{
+ obsd_sensors.device = sensor_device;
+ update_obsd_sensors();
+ snprintf(p, p_max_size, "%d",
+ obsd_sensors.fan[obsd_sensors.device][obj->data.l]);
+}
+
+void print_obsd_sensors_volt(struct text_object *obj, char *p, int p_max_size)
+{
+ obsd_sensors.device = sensor_device;
+ update_obsd_sensors();
+ snprintf(p, p_max_size, "%.2f",
+ obsd_sensors.volt[obsd_sensors.device][obj->data.l]);
+}
+
/* chipset vendor */
void get_obsd_vendor(char *buf, size_t client_buffer_size)
{
}
}
-/* rdtsc() and get_freq_dynamic() copied from linux.c */
-
-#if defined(__i386) || defined(__x86_64)
-__inline__ unsigned long long int rdtsc()
-{
- unsigned long long int x;
-
- __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
- return x;
-}
-#endif
-
-/* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
-void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
- const char *p_format, int divisor)
-{
-#if defined(__i386) || defined(__x86_64)
- struct timezone tz;
- struct timeval tvstart, tvstop;
- unsigned long long cycles[2]; /* gotta be 64 bit */
- unsigned int microseconds; /* total time taken */
-
- memset(&tz, 0, sizeof(tz));
-
- /* get this function in cached memory */
- gettimeofday(&tvstart, &tz);
- cycles[0] = rdtsc();
- gettimeofday(&tvstart, &tz);
-
- /* we don't trust that this is any specific length of time */
- usleep(100);
- cycles[1] = rdtsc();
- gettimeofday(&tvstop, &tz);
- microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
- (tvstop.tv_usec - tvstart.tv_usec);
-
- snprintf(p_client_buffer, client_buffer_size, p_format,
- (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
-#else
- get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
-#endif
-}
-
/* void */
char get_freq(char *p_client_buffer, size_t client_buffer_size,
const char *p_format, int divisor, unsigned int cpu)
int comparemem(const void *a, const void *b)
{
- if (((struct process *) a)->totalmem > ((struct process *) b)->totalmem) {
+ if (((struct process *) a)->rss > ((struct process *) b)->rss) {
return -1;
}
- if (((struct process *) a)->totalmem < ((struct process *) b)->totalmem) {
+ if (((struct process *) a)->rss < ((struct process *) b)->rss) {
return 1;
}
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].totalmem = (float) (p[i].p_vm_rssize /
- (float) total_pages) * 100.0;
j++;
}
}
tmp = malloc(sizeof(struct process));
tmp->pid = processes[i].pid;
tmp->amount = processes[i].amount;
- tmp->totalmem = processes[i].totalmem;
tmp->name = strndup(processes[i].name, text_buffer_size);
ttmp = mem[i];
tmp = malloc(sizeof(struct process));
tmp->pid = processes[i].pid;
tmp->amount = processes[i].amount;
- tmp->totalmem = processes[i].totalmem;
tmp->name = strndup(processes[i].name, text_buffer_size);
ttmp = cpu[i];
{
}
-void update_entropy(void)
+int get_entropy_avail(unsigned int *val)
+{
+ return 1;
+}
+
+int get_entropy_poolsize(unsigned int *val)
{
+ return 1;
}
void free_all_processes(void)