Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add internal metrics support: libraries #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ struct tunnel_entry {
};

/* global variables */
#if (!defined __PMACCTD_C) && (!defined __NFACCTD_C) && (!defined __SFACCTD_C) && (!defined __UACCTD_C) && (!defined __PMTELEMETRYD_C) && (!defined __PMBGPD_C) && (!defined __PMBMPD_C)
#if (!defined __PMACCTD_C) && (!defined __NFACCTD_C) && (!defined __SFACCTD_C) && (!defined __UACCTD_C) && (!defined __PMTELEMETRYD_C) && (!defined __PMBGPD_C) && (!defined __PMBMPD_C) && (!defined __INTSTATSD_C)
#define EXT extern
#else
#define EXT
Expand Down
17 changes: 0 additions & 17 deletions src/nfprobe_plugin/nfprobe_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,23 +771,6 @@ process_packet(struct FLOWTRACK *ft, struct primitives_ptrs *prim_ptrs, const st
return (PP_OK);
}

/*
* Subtract two timevals. Returns (t1 - t2) in milliseconds.
*/
u_int32_t
timeval_sub_ms(const struct timeval *t1, const struct timeval *t2)
{
struct timeval res;

res.tv_sec = t1->tv_sec - t2->tv_sec;
res.tv_usec = t1->tv_usec - t2->tv_usec;
if (res.tv_usec < 0) {
res.tv_usec += 1000000L;
res.tv_sec--;
}
return ((u_int32_t)res.tv_sec * 1000 + (u_int32_t)res.tv_usec / 1000);
}

static void
update_statistic(struct STATISTIC *s, double new, double n)
{
Expand Down
2 changes: 1 addition & 1 deletion src/once.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef _ONCE_H_
#define _ONCE_H_

#if defined __PMACCTD_C || defined __NFACCTD_C || defined __SFACCTD_C || defined __UACCTD_C || defined __PMACCT_CLIENT_C || defined __PMTELEMETRYD_C || defined __PMBGPD_C || defined __PMBMPD_C
#if defined __PMACCTD_C || defined __NFACCTD_C || defined __SFACCTD_C || defined __UACCTD_C || defined __PMACCT_CLIENT_C || defined __PMTELEMETRYD_C || defined __PMBGPD_C || defined __PMBMPD_C || defined __INTSTATSD_C
#define EXT
#else
#define EXT extern
Expand Down
2 changes: 1 addition & 1 deletion src/pmacct-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define PLUGIN_ID_UNKNOWN -1

/* vars */
#if (!defined __PMACCTD_C) && (!defined __NFACCTD_C) && (!defined __SFACCTD_C) && (!defined __UACCTD_C) && (!defined __PMTELEMETRYD_C) && (!defined __PMACCT_CLIENT_C) && (!defined __PMBGPD_C) && (!defined __PMBMPD_C)
#if (!defined __PMACCTD_C) && (!defined __NFACCTD_C) && (!defined __SFACCTD_C) && (!defined __UACCTD_C) && (!defined __PMTELEMETRYD_C) && (!defined __PMACCT_CLIENT_C) && (!defined __PMBGPD_C) && (!defined __PMBMPD_C) && (!defined __INTSTATSD_C)
#define EXT extern
#else
#define EXT
Expand Down
2 changes: 1 addition & 1 deletion src/pmacct.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void
initsetproctitle(int, char**, char**);

/* global variables */
#if (!defined __PMACCTD_C) && (!defined __NFACCTD_C) && (!defined __SFACCTD_C) && (!defined __UACCTD_C) && (!defined __PMTELEMETRYD_C) && (!defined __PMBGPD_C) && (!defined __PMBMPD_C)
#if (!defined __PMACCTD_C) && (!defined __NFACCTD_C) && (!defined __SFACCTD_C) && (!defined __UACCTD_C) && (!defined __PMTELEMETRYD_C) && (!defined __PMBGPD_C) && (!defined __PMBMPD_C) && (!defined __INTSTATSD_C)
#define EXT extern
#else
#define EXT
Expand Down
17 changes: 17 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,23 @@ int timeval_cmp(struct timeval *a, struct timeval *b)
}
}

/*
* Subtract two timevals. Returns (t1 - t2) in milliseconds.
*/
u_int32_t
timeval_sub_ms(const struct timeval *t1, const struct timeval *t2)
{
struct timeval res;

res.tv_sec = t1->tv_sec - t2->tv_sec;
res.tv_usec = t1->tv_usec - t2->tv_usec;
if (res.tv_usec < 0) {
res.tv_usec += 1000000L;
res.tv_sec--;
}
return ((u_int32_t)res.tv_sec * 1000 + (u_int32_t)res.tv_usec / 1000);
}

/*
* exit_all(): Core Process exit lane. Not meant to be a nice shutdown method: it is
* an exit() replacement that sends kill signals to the plugins.
Expand Down