Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
61bbdbb9
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
61bbdbb9
编写于
7月 06, 2014
作者:
R
Roman Bogorodskiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement interface stats for BSD
上级
5559a8b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
1 deletion
+63
-1
configure.ac
configure.ac
+12
-1
src/util/virstats.c
src/util/virstats.c
+51
-0
未找到文件。
configure.ac
浏览文件 @
61bbdbb9
...
@@ -275,7 +275,7 @@ dnl and various less common threadsafe functions
...
@@ -275,7 +275,7 @@ dnl and various less common threadsafe functions
AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
getmntent_r getpwuid_r getuid kill mmap newlocale posix_fallocate \
getmntent_r getpwuid_r getuid kill mmap newlocale posix_fallocate \
posix_memalign prlimit regexec sched_getaffinity setgroups setns \
posix_memalign prlimit regexec sched_getaffinity setgroups setns \
setrlimit symlink sysctlbyname])
setrlimit symlink sysctlbyname
getifaddrs
])
dnl Availability of pthread functions. Because of $LIB_PTHREAD, we
dnl Availability of pthread functions. Because of $LIB_PTHREAD, we
dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD
dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD
...
@@ -2691,6 +2691,17 @@ if test $with_freebsd = yes; then
...
@@ -2691,6 +2691,17 @@ if test $with_freebsd = yes; then
)
)
fi
fi
# FreeBSD 10-STABLE requires _IFI_OQDROPS to be defined for if_data.ifi_oqdrops
# field be available
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -D_IFI_OQDROPS"
AC_CHECK_MEMBERS([struct if_data.ifi_oqdrops],
[],
[CFLAGS="$old_CFLAGS"],
[#include <net/if.h>
])
# Check if we need to look for ifconfig
# Check if we need to look for ifconfig
if test "$want_ifconfig" = "yes"; then
if test "$want_ifconfig" = "yes"; then
AC_PATH_PROG([IFCONFIG_PATH], [ifconfig])
AC_PATH_PROG([IFCONFIG_PATH], [ifconfig])
...
...
src/util/virstats.c
浏览文件 @
61bbdbb9
...
@@ -29,6 +29,11 @@
...
@@ -29,6 +29,11 @@
#include <unistd.h>
#include <unistd.h>
#include <regex.h>
#include <regex.h>
#ifdef HAVE_GETIFADDRS
# include <net/if.h>
# include <ifaddrs.h>
#endif
#include "virerror.h"
#include "virerror.h"
#include "datatypes.h"
#include "datatypes.h"
#include "virstats.h"
#include "virstats.h"
...
@@ -114,6 +119,52 @@ virNetInterfaceStats(const char *path,
...
@@ -114,6 +119,52 @@ virNetInterfaceStats(const char *path,
_
(
"/proc/net/dev: Interface not found"
));
_
(
"/proc/net/dev: Interface not found"
));
return
-
1
;
return
-
1
;
}
}
#elif defined(HAVE_GETIFADDRS)
int
virNetInterfaceStats
(
const
char
*
path
,
struct
_virDomainInterfaceStats
*
stats
)
{
struct
ifaddrs
*
ifap
,
*
ifa
;
struct
if_data
*
ifd
;
int
ret
=
-
1
;
if
(
getifaddrs
(
&
ifap
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"Could not get interface list"
));
return
-
1
;
}
for
(
ifa
=
ifap
;
ifa
;
ifa
=
ifa
->
ifa_next
)
{
if
(
ifa
->
ifa_addr
->
sa_family
!=
AF_LINK
)
continue
;
if
(
STREQ
(
ifa
->
ifa_name
,
path
))
{
ifd
=
(
struct
if_data
*
)
ifa
->
ifa_data
;
stats
->
tx_bytes
=
ifd
->
ifi_ibytes
;
stats
->
tx_packets
=
ifd
->
ifi_ipackets
;
stats
->
tx_errs
=
ifd
->
ifi_ierrors
;
stats
->
tx_drop
=
ifd
->
ifi_iqdrops
;
stats
->
rx_bytes
=
ifd
->
ifi_obytes
;
stats
->
rx_packets
=
ifd
->
ifi_opackets
;
stats
->
rx_errs
=
ifd
->
ifi_oerrors
;
# ifdef HAVE_STRUCT_IF_DATA_IFI_OQDROPS
stats
->
rx_drop
=
ifd
->
ifi_oqdrops
;
# else
stats
->
rx_drop
=
0
;
# endif
ret
=
0
;
break
;
}
}
if
(
ret
<
0
)
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Interface not found"
));
freeifaddrs
(
ifap
);
return
ret
;
}
#else
#else
int
int
virNetInterfaceStats
(
const
char
*
path
ATTRIBUTE_UNUSED
,
virNetInterfaceStats
(
const
char
*
path
ATTRIBUTE_UNUSED
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录