1 /* Conky, a system monitor, based on torsmo
3 * Any original torsmo code is licensed under the BSD license
5 * All code written since the fork of torsmo is licensed under the GPL
7 * Please see COPYING for details
9 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
11 * All rights reserved.
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <sys/ioctl.h>
28 #include <sys/dkstat.h>
29 #include <sys/param.h>
30 #include <sys/resource.h>
31 #include <sys/socket.h>
33 #include <sys/sysctl.h>
35 #include <sys/types.h>
39 #include <net/if_mib.h>
40 #include <net/if_media.h>
41 #include <net/if_var.h>
48 #include <dev/wi/if_wavelan_ieee.h>
49 #include <dev/acpica/acpiio.h>
57 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
58 #define KELVTOC(x) ((x - 2732) / 10.0)
59 #define MAXSHOWDEVS 16
65 __attribute__((gnu_inline)) inline void
66 proc_find_top(struct process **cpu, struct process **mem);
68 static short cpu_setup = 0;
70 static int getsysctl(const char *name, void *ptr, size_t len)
74 if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
78 if (nlen != len && errno == ENOMEM) {
85 struct ifmibdata *data = NULL;
88 static int swapmode(unsigned long *retavail, unsigned long *retfree)
91 unsigned long pagesize = getpagesize();
92 struct kvm_swap swapary[1];
97 #define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
99 n = kvm_getswapinfo(kd, swapary, 1, 0);
100 if (n < 0 || swapary[0].ksw_total == 0) {
104 *retavail = CONVERT(swapary[0].ksw_total);
105 *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
107 n = (int) ((double) swapary[0].ksw_used * 100.0 /
108 (double) swapary[0].ksw_total);
113 void prepare_update(void)
117 void update_uptime(void)
119 int mib[2] = { CTL_KERN, KERN_BOOTTIME };
120 struct timeval boottime;
122 size_t size = sizeof(boottime);
124 if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
125 && (boottime.tv_sec != 0)) {
127 info.uptime = now - boottime.tv_sec;
129 fprintf(stderr, "Could not get uptime\n");
134 int check_mount(char *s)
136 struct statfs *mntbuf;
139 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
140 for (i = mntsize - 1; i >= 0; i--) {
141 if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
149 void update_meminfo(void)
151 u_int total_pages, inactive_pages, free_pages;
152 unsigned long swap_avail, swap_free;
154 int pagesize = getpagesize();
156 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
157 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
160 if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
161 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
164 if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
165 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
168 info.memmax = total_pages * (pagesize >> 10);
169 info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
170 info.memeasyfree = info.memfree = info.memmax - info.mem;
172 if ((swapmode(&swap_avail, &swap_free)) >= 0) {
173 info.swapmax = swap_avail;
174 info.swap = (swap_avail - swap_free);
175 info.swapfree = swap_free;
183 void update_net_stats(void)
187 long long r, t, last_recv, last_trans;
188 struct ifaddrs *ifap, *ifa;
192 delta = current_update_time - last_update_time;
193 if (delta <= 0.0001) {
197 if (getifaddrs(&ifap) < 0) {
201 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
202 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
204 if (ifa->ifa_flags & IFF_UP) {
205 struct ifaddrs *iftmp;
208 last_recv = ns->recv;
209 last_trans = ns->trans;
211 if (ifa->ifa_addr->sa_family != AF_LINK) {
215 for (iftmp = ifa->ifa_next;
216 iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
217 iftmp = iftmp->ifa_next) {
218 if (iftmp->ifa_addr->sa_family == AF_INET) {
219 memcpy(&(ns->addr), iftmp->ifa_addr,
220 iftmp->ifa_addr->sa_len);
224 ifd = (struct if_data *) ifa->ifa_data;
228 if (r < ns->last_read_recv) {
229 ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
231 ns->recv += (r - ns->last_read_recv);
234 ns->last_read_recv = r;
236 if (t < ns->last_read_trans) {
237 ns->trans += ((long long) 4294967295U -
238 ns->last_read_trans) + t;
240 ns->trans += (t - ns->last_read_trans);
243 ns->last_read_trans = t;
245 /* calculate speeds */
246 ns->recv_speed = (ns->recv - last_recv) / delta;
247 ns->trans_speed = (ns->trans - last_trans) / delta;
256 void update_total_processes(void)
260 kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
262 info.procs = n_processes;
265 void update_running_processes(void)
267 struct kinfo_proc *p;
271 p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
272 for (i = 0; i < n_processes; i++) {
273 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
274 if (p[i].kp_proc.p_stat == SRUN) {
276 if (p[i].ki_stat == SRUN) {
282 info.run_procs = cnt;
285 struct cpu_load_struct {
286 unsigned long load[5];
289 struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
290 long cpu_used, oldtotal, oldused;
292 void get_cpu_count(void)
294 /* int cpu_count = 0; */
296 /* XXX: FreeBSD doesn't allow to get per CPU load stats on SMP machines.
297 * It's possible to get a CPU count, but as we fulfill only
298 * info.cpu_usage[0], it's better to report there's only one CPU.
299 * It should fix some bugs (e.g. cpugraph) */
301 if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
302 info.cpu_count = cpu_count;
307 info.cpu_usage = malloc(info.cpu_count * sizeof(float));
308 if (info.cpu_usage == NULL) {
309 CRIT_ERR(NULL, NULL, "malloc");
313 /* XXX: SMP support */
314 void update_cpu_usage(void)
317 long cp_time[CPUSTATES];
318 size_t cp_len = sizeof(cp_time);
320 /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
321 if ((cpu_setup == 0) || (!info.cpu_usage)) {
326 if (sysctlbyname("kern.cp_time", &cp_time, &cp_len, NULL, 0) < 0) {
327 fprintf(stderr, "Cannot get kern.cp_time");
330 fresh.load[0] = cp_time[CP_USER];
331 fresh.load[1] = cp_time[CP_NICE];
332 fresh.load[2] = cp_time[CP_SYS];
333 fresh.load[3] = cp_time[CP_IDLE];
334 fresh.load[4] = cp_time[CP_IDLE];
336 used = fresh.load[0] + fresh.load[1] + fresh.load[2];
337 total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
339 if ((total - oldtotal) != 0) {
340 info.cpu_usage[0] = ((double) (used - oldused)) /
341 (double) (total - oldtotal);
343 info.cpu_usage[0] = 0;
350 void update_load_average(void)
356 info.loadavg[0] = (double) v[0];
357 info.loadavg[1] = (double) v[1];
358 info.loadavg[2] = (double) v[2];
361 double get_acpi_temperature(int fd)
366 if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
368 "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
372 return KELVTOC(temp);
375 static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
376 if (battime && GETSYSCTL("hw.acpi.battery.time", *battime)) {
377 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
379 if (batcapacity && GETSYSCTL("hw.acpi.battery.life", *batcapacity)) {
380 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
382 if (batstate && GETSYSCTL("hw.acpi.battery.state", *batstate)) {
383 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
385 if (ac && GETSYSCTL("hw.acpi.acline", *ac)) {
386 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
390 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
392 int battime, batcapacity, batstate, ac;
395 get_battery_stats(&battime, &batcapacity, &batstate, &ac);
397 if (batstate != 1 && batstate != 2 && batstate != 0 && batstate != 7)
398 fprintf(stderr, "Unknown battery state %d!\n", batstate);
399 else if (batstate != 1 && ac == 0)
400 fprintf(stderr, "Battery charging while not on AC!\n");
401 else if (batstate == 1 && ac == 1)
402 fprintf(stderr, "Battery discharing while on AC!\n");
406 if (batstate == 1 && battime != -1)
407 snprintf(buf, n, "%d:%2.2d", battime / 60, battime % 60);
410 if (batstate == 1) // Discharging
411 snprintf(buf, n, "remaining %d%%", batcapacity);
413 snprintf(buf, n, batstate == 2 ? "charging (%d%%)" :
414 (batstate == 7 ? "absent/on AC" : "charged (%d%%)"),
418 fprintf(stderr, "Unknown requested battery stat %d\n", item);
422 static int check_bat(const char *bat)
424 int batnum, numbatts;
426 if (GETSYSCTL("hw.acpi.battery.units", numbatts)) {
427 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n");
431 fprintf(stderr, "No battery unit detected\n");
434 if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 ||
435 bat == endptr || batnum > numbatts) {
436 fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : "");
442 int get_battery_perct(const char *bat)
444 union acpi_battery_ioctl_arg battio;
446 int designcap, lastfulcap, batperct;
448 if ((battio.unit = batnum = check_bat(bat)) < 0)
450 if ((acpifd = open("/dev/acpi", O_RDONLY)) < 0) {
451 fprintf(stderr, "Can't open ACPI device\n");
454 if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) {
455 fprintf(stderr, "Unable to get info for battery unit %d\n", batnum);
459 designcap = battio.bif.dcap;
460 lastfulcap = battio.bif.lfcap;
461 batperct = (designcap > 0 && lastfulcap > 0) ?
462 (int) (((float) lastfulcap / designcap) * 100) : 0;
463 return batperct > 100 ? 100 : batperct;
466 int get_battery_perct_bar(const char *bar)
468 int batperct = get_battery_perct(bar);
469 return (int)(batperct * 2.56 - 1);
472 int open_acpi_temperature(const char *name)
475 /* Not applicable for FreeBSD. */
479 void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
483 if (!p_client_buffer || client_buffer_size <= 0) {
487 if (GETSYSCTL("hw.acpi.acline", state)) {
488 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
493 strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
495 strncpy(p_client_buffer, "Running on battery", client_buffer_size);
499 void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
501 /* not implemented */
502 if (p_client_buffer && client_buffer_size > 0) {
503 memset(p_client_buffer, 0, client_buffer_size);
507 void get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
509 /* not implemented */
510 if (p_client_buffer && client_buffer_size > 0) {
511 memset(p_client_buffer, 0, client_buffer_size);
515 void get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
517 /* not implemented */
518 if (p_client_buffer && client_buffer_size > 0) {
519 memset(p_client_buffer, 0, client_buffer_size);
523 /* rdtsc() and get_freq_dynamic() copied from linux.c */
525 #if defined(__i386) || defined(__x86_64)
526 __attribute__((gnu_inline)) inline unsigned long long int rdtsc(void)
528 unsigned long long int x;
530 __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
535 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
536 void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
537 const char *p_format, int divisor)
539 #if defined(__i386) || defined(__x86_64)
541 struct timeval tvstart, tvstop;
542 unsigned long long cycles[2]; /* gotta be 64 bit */
543 unsigned int microseconds; /* total time taken */
545 memset(&tz, 0, sizeof(tz));
547 /* get this function in cached memory */
548 gettimeofday(&tvstart, &tz);
550 gettimeofday(&tvstart, &tz);
552 /* we don't trust that this is any specific length of time */
555 gettimeofday(&tvstop, &tz);
556 microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
557 (tvstop.tv_usec - tvstart.tv_usec);
559 snprintf(p_client_buffer, client_buffer_size, p_format,
560 (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
562 get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
567 char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format,
568 int divisor, unsigned int cpu)
573 freq_sysctl = (char *) calloc(16, sizeof(char));
574 if (freq_sysctl == NULL) {
578 snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
580 if (!p_client_buffer || client_buffer_size <= 0 || !p_format
585 if (GETSYSCTL(freq_sysctl, freq) == 0) {
586 snprintf(p_client_buffer, client_buffer_size, p_format,
587 (float) freq / divisor);
589 snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
596 void update_top(void)
598 proc_find_top(info.cpu, info.memu);
602 void update_wifi_stats(void)
604 struct ifreq ifr; /* interface stats */
607 struct ifaddrs *ifap, *ifa;
608 struct ifmediareq ifmr;
611 /* Get iface table */
612 if (getifaddrs(&ifap) < 0) {
616 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
617 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
619 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
622 bzero(&ifmr, sizeof(ifmr));
623 strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
624 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
629 /* We can monitor only wireless interfaces
630 * which are not in hostap mode */
631 if ((ifmr.ifm_active & IFM_IEEE80211)
632 && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
634 bzero(&ifr, sizeof(ifr));
635 strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
636 wireq.wi_type = WI_RID_COMMS_QUALITY;
637 wireq.wi_len = WI_MAX_DATALEN;
638 ifr.ifr_data = (void *) &wireq;
640 if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
641 perror("ioctl (getting wi status)");
645 /* wi_val[0] = quality
647 * wi_val[2] = noise */
648 ns->linkstatus = (int) wireq.wi_val[1];
656 void update_diskio(void)
658 int devs_count, num_selected, num_selections, dn;
659 struct device_selection *dev_select = NULL;
660 long select_generation;
661 static struct statinfo statinfo_cur;
662 char device_name[text_buffer_size];
663 struct diskio_stat *cur;
664 unsigned int reads, writes;
665 unsigned int total_reads = 0, total_writes = 0;
668 memset(&statinfo_cur, 0, sizeof(statinfo_cur));
669 statinfo_cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
670 stats.current = stats.current_read = stats.current_write = 0;
672 if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
673 free(statinfo_cur.dinfo);
677 devs_count = statinfo_cur.dinfo->numdevs;
678 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
679 &select_generation, statinfo_cur.dinfo->generation,
680 statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
681 DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
682 for (dn = 0; dn < devs_count; dn++) {
686 di = dev_select[dn].position;
687 dev = &statinfo_cur.dinfo->devices[di];
688 snprintf(device_name, text_buffer_size, "%s%d",
689 dev_select[dn].device_name, dev_select[dn].unit_number);
691 total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512);
692 total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512);
693 for (cur = stats.next; cur; cur = cur->next) {
694 if (cur->dev && !strcmp(device_name, cur->dev)) {
695 update_diskio_values(cur, reads, writes);
700 update_diskio_values(&stats, total_reads, total_writes);
705 free(statinfo_cur.dinfo);
708 /* While topless is obviously better, top is also not bad. */
710 int comparecpu(const void *a, const void *b)
712 if (((const struct process *)a)->amount > ((const struct process *)b)->amount) {
714 } else if (((const struct process *)a)->amount < ((const struct process *)b)->amount) {
721 int comparemem(const void *a, const void *b)
723 if (((const struct process *)a)->totalmem > ((const struct process *)b)->totalmem) {
725 } else if (((const struct process *)a)->totalmem < ((const struct process *)b)->totalmem) {
732 __attribute__((gnu_inline)) inline void
733 proc_find_top(struct process **cpu, struct process **mem)
735 struct kinfo_proc *p;
738 struct process *processes;
742 /* we get total pages count again to be sure it is up to date */
743 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
744 CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
747 p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
748 processes = malloc(n_processes * sizeof(struct process));
750 for (i = 0; i < n_processes; i++) {
751 if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
752 processes[j].pid = p[i].ki_pid;
753 processes[j].name = strndup(p[i].ki_comm, text_buffer_size);
754 processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
755 processes[j].totalmem = (float) (p[i].ki_rssize /
756 (float) total_pages) * 100.0;
757 processes[j].vsize = p[i].ki_size;
758 processes[j].rss = (p[i].ki_rssize * getpagesize());
763 qsort(processes, j - 1, sizeof(struct process), comparemem);
764 for (i = 0; i < 10 && i < n_processes; i++) {
765 struct process *tmp, *ttmp;
767 tmp = malloc(sizeof(struct process));
768 tmp->pid = processes[i].pid;
769 tmp->amount = processes[i].amount;
770 tmp->totalmem = processes[i].totalmem;
771 tmp->name = strndup(processes[i].name, text_buffer_size);
772 tmp->rss = processes[i].rss;
773 tmp->vsize = processes[i].vsize;
783 qsort(processes, j - 1, sizeof(struct process), comparecpu);
784 for (i = 0; i < 10 && i < n_processes; i++) {
785 struct process *tmp, *ttmp;
787 tmp = malloc(sizeof(struct process));
788 tmp->pid = processes[i].pid;
789 tmp->amount = processes[i].amount;
790 tmp->totalmem = processes[i].totalmem;
791 tmp->name = strndup(processes[i].name, text_buffer_size);
792 tmp->rss = processes[i].rss;
793 tmp->vsize = processes[i].vsize;
803 #if defined(FREEBSD_DEBUG)
804 printf("=====\nmem\n");
805 for (i = 0; i < 10; i++) {
806 printf("%d: %s(%d) %.2f %ld %ld\n", i, mem[i]->name,
807 mem[i]->pid, mem[i]->totalmem, mem[i]->vsize, mem[i]->rss);
811 for (i = 0; i < j; i++) {
812 free(processes[i].name);
817 #if defined(i386) || defined(__i386__)
818 #define APMDEV "/dev/apm"
819 #define APM_UNKNOWN 255
821 int apm_getinfo(int fd, apm_info_t aip)
823 if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
830 char *get_apm_adapter(void)
833 struct apm_info a_info;
836 out = (char *) calloc(16, sizeof(char));
838 fd = open(APMDEV, O_RDONLY);
840 strncpy(out, "ERR", 16);
844 if (apm_getinfo(fd, &a_info) != 0) {
846 strncpy(out, "ERR", 16);
851 switch (a_info.ai_acline) {
853 strncpy(out, "off-line", 16);
857 if (a_info.ai_batt_stat == 3) {
858 strncpy(out, "charging", 16);
861 strncpy(out, "on-line", 16);
866 strncpy(out, "unknown", 16);
872 char *get_apm_battery_life(void)
876 struct apm_info a_info;
879 out = (char *) calloc(16, sizeof(char));
881 fd = open(APMDEV, O_RDONLY);
883 strncpy(out, "ERR", 16);
887 if (apm_getinfo(fd, &a_info) != 0) {
889 strncpy(out, "ERR", 16);
894 batt_life = a_info.ai_batt_life;
895 if (batt_life == APM_UNKNOWN) {
896 strncpy(out, "unknown", 16);
897 } else if (batt_life <= 100) {
898 snprintf(out, 16, "%d%%", batt_life);
901 strncpy(out, "ERR", 16);
907 char *get_apm_battery_time(void)
912 struct apm_info a_info;
915 out = (char *) calloc(16, sizeof(char));
917 fd = open(APMDEV, O_RDONLY);
919 strncpy(out, "ERR", 16);
923 if (apm_getinfo(fd, &a_info) != 0) {
925 strncpy(out, "ERR", 16);
930 batt_time = a_info.ai_batt_time;
932 if (batt_time == -1) {
933 strncpy(out, "unknown", 16);
940 snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
948 void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
950 get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
951 if (0 == strncmp("charging", buffer, 8)) {
953 memmove(buffer + 1, buffer + 8, n - 8);
954 } else if (0 == strncmp("discharging", buffer, 11)) {
956 memmove(buffer + 1, buffer + 11, n - 11);
957 } else if (0 == strncmp("absent/on AC", buffer, 12)) {
959 memmove(buffer + 1, buffer + 12, n - 12);
963 void update_entropy(void)
965 /* Not applicable for FreeBSD as it uses the yarrow prng. */
968 /* empty stub so conky links */
969 void free_all_processes(void)