mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
- Fix networking stuff on FreeBSD (Petr Holub)
- Minor style fixes git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@611 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
6b857758eb
commit
704b590071
@ -97,8 +97,8 @@ update_uptime()
|
|||||||
time_t now;
|
time_t now;
|
||||||
size_t size = sizeof (boottime);
|
size_t size = sizeof (boottime);
|
||||||
|
|
||||||
if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
|
if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) &&
|
||||||
&& (boottime.tv_sec != 0)) {
|
(boottime.tv_sec != 0)) {
|
||||||
time(&now);
|
time(&now);
|
||||||
info.uptime = now - boottime.tv_sec;
|
info.uptime = now - boottime.tv_sec;
|
||||||
} else {
|
} else {
|
||||||
@ -163,12 +163,23 @@ update_net_stats()
|
|||||||
ns = get_net_stat((const char *) ifa->ifa_name);
|
ns = get_net_stat((const char *) ifa->ifa_name);
|
||||||
|
|
||||||
if (ifa->ifa_flags & IFF_UP) {
|
if (ifa->ifa_flags & IFF_UP) {
|
||||||
|
struct ifaddrs *iftmp;
|
||||||
|
|
||||||
|
ns->up = 1;
|
||||||
|
ns->linkstatus = 1;
|
||||||
last_recv = ns->recv;
|
last_recv = ns->recv;
|
||||||
last_trans = ns->trans;
|
last_trans = ns->trans;
|
||||||
|
|
||||||
if (ifa->ifa_addr->sa_family != AF_LINK)
|
if (ifa->ifa_addr->sa_family != AF_LINK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
for (iftmp = ifa->ifa_next; iftmp != NULL &&
|
||||||
|
strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
|
||||||
|
iftmp = iftmp->ifa_next)
|
||||||
|
if (iftmp->ifa_addr->sa_family == AF_INET)
|
||||||
|
memcpy(&(ns->addr), iftmp->ifa_addr,
|
||||||
|
iftmp->ifa_addr->sa_len);
|
||||||
|
|
||||||
ifd = (struct if_data *) ifa->ifa_data;
|
ifd = (struct if_data *) ifa->ifa_data;
|
||||||
r = ifd->ifi_ibytes;
|
r = ifd->ifi_ibytes;
|
||||||
t = ifd->ifi_obytes;
|
t = ifd->ifi_obytes;
|
||||||
@ -191,10 +202,12 @@ update_net_stats()
|
|||||||
|
|
||||||
ns->last_read_trans = t;
|
ns->last_read_trans = t;
|
||||||
|
|
||||||
|
|
||||||
/* calculate speeds */
|
/* calculate speeds */
|
||||||
ns->recv_speed = (ns->recv - last_recv) / delta;
|
ns->recv_speed = (ns->recv - last_recv) / delta;
|
||||||
ns->trans_speed = (ns->trans - last_trans) / delta;
|
ns->trans_speed = (ns->trans - last_trans) / delta;
|
||||||
|
} else {
|
||||||
|
ns->up = 0;
|
||||||
|
ns->linkstatus = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,8 +478,8 @@ get_freq(char *p_client_buffer, size_t client_buffer_size,
|
|||||||
{
|
{
|
||||||
int freq;
|
int freq;
|
||||||
|
|
||||||
if (!p_client_buffer || client_buffer_size <= 0
|
if (!p_client_buffer || client_buffer_size <= 0 ||
|
||||||
|| !p_format || divisor <= 0)
|
!p_format || divisor <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (GETSYSCTL("dev.cpu.0.freq", freq) == 0)
|
if (GETSYSCTL("dev.cpu.0.freq", freq) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user