strncpy_nt(inface, iface, 32);
}
-#if defined(__linux__)
+#if defined(__linux__) || defined(CHECK_VNSTAT)
/* try getting interface info from /proc */
- if (readproc(inface)!=1) {
+ if (readproc(inface)==1) {
+ ifinfo.timestamp = time(NULL);
+ return 1;
+ } else {
if (debug)
printf("Failed to use %s as source.\n", PROCNETDEV);
+ }
- /* try getting interface info from /sys */
- if (readsysclassnet(inface)!=1) {
- snprintf(errorstring, 1024, "Unable to get interface \"%s\" statistics.", inface);
- printe(PT_Error);
- return 0;
- }
+ /* try getting interface info from /sys */
+ if (readsysclassnet(inface)==1) {
+ ifinfo.timestamp = time(NULL);
+ return 1;
}
+
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
- if (readifaddrs(inface)!=1) {
- snprintf(errorstring, 1024, "Unable to get interface \"%s\" statistics.", inface);
- printe(PT_Error);
- return 0;
+ if (readifaddrs(inface)==1) {
+ ifinfo.timestamp = time(NULL);
+ return 1;
}
-#else
- return 0;
#endif
- ifinfo.timestamp = time(NULL);
- return 1;
+
+ snprintf(errorstring, 1024, "Unable to get interface \"%s\" statistics.", inface);
+ printe(PT_Error);
+ return 0;
}
int getiflist(char **ifacelist, int showspeed)
{
uint32_t speed;
char temp[64];
-#if defined(__linux__)
+#if defined(__linux__) || defined(CHECK_VNSTAT)
char interface[32];
FILE *fp;
DIR *dp;
}
*ifacelist[0] = '\0';
-#if defined(__linux__)
+#if defined(__linux__) || defined(CHECK_VNSTAT)
if ((fp=fopen(PROCNETDEV, "r"))!=NULL) {
/* make list of interfaces */
START_TEST(addinterfaces_does_nothing_with_no_files)
{
DSTATE s;
- linuxonly;
defaultcfg();
initdstate(&s);
{
int ret;
DSTATE s;
- linuxonly;
defaultcfg();
initdstate(&s);
{
int ret;
DSTATE s;
- linuxonly;
defaultcfg();
initdstate(&s);
{
int ret;
DSTATE s;
- linuxonly;
defaultcfg();
initdstate(&s);
{
DSTATE s;
- linuxonly_exit;
-
defaultcfg();
initdstate(&s);
suppress_output();
{
DSTATE s;
- linuxonly_exit;
-
defaultcfg();
initdstate(&s);
suppress_output();
{
DSTATE s;
- linuxonly_exit;
-
defaultcfg();
initdstate(&s);
s.noadd = 1;
int ret;
DSTATE s;
- linuxonly;
-
defaultcfg();
initdstate(&s);
suppress_output();
START_TEST(processdatacache_can_process_things)
{
- /* ifinfo needs to be faked and that's currently
- supported only in Linux */
- linuxonly;
-
int ret;
DSTATE s;
defaultcfg();
{
DSTATE s;
- linuxonly;
-
initdstate(&s);
ck_assert_int_eq(remove_directory(TESTDIR), 1);
interfacechangecheck(&s);
{
DSTATE s;
- linuxonly;
-
initdstate(&s);
ck_assert_int_eq(remove_directory(TESTDIR), 1);
fake_proc_net_dev("w", "ethsomething", 1, 2, 3, 4);
uint32_t ifhash;
char *ifacelist;
- linuxonly;
-
initdstate(&s);
ck_assert_int_eq(remove_directory(TESTDIR), 1);
fake_proc_net_dev("w", "ethsomething", 1, 2, 3, 4);
START_TEST(interfacechangecheck_with_filled_cache)
{
- linuxonly;
-
int ret;
DSTATE s;
datacache *iterator;