Commit a1fc3148 authored by 's avatar

Traffic from interfaces within [scope] is added together


git-svn-id: file:///home/svn/mapi/trunk@1250 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent c9862c84
......@@ -48,7 +48,7 @@ III. INSTALL DiMAPI
[ --enable-reconnect ] \
[ --with-libpcap=/usr/local/src/libpcap ] \
[ --enable-dag --with-libdag=/usr/local/dag ]
[ --enable-anonlib --enable-ipfixflib --enable-extraflib ] \
[ --enable-anonflib --enable-ipfixflib --enable-extraflib ] \
It is recommended that you use all the options in the above example.
......
This diff is collapsed.
......@@ -44,8 +44,6 @@
#include "abw_common.h"
#include "abw_conf.h"
#define PROC_STAT "/proc/stat"
tracked_protocol_t tracked_protocols[] = {
{ "ftp", "TRACK_FTP" },
{ "gnutella", "TRACK_GNUTELLA" },
......@@ -80,10 +78,6 @@ subject_t *new_subject(void) {
memset(p, 0, sizeof(subject_t));
p->port=-1;
p->mpls=0;
p->vlan=0;
p->link_mbps=DEFAULT_LINK_MBPS;
p->out=0;
return p;
} /* new_subject() */
......
......@@ -73,17 +73,13 @@ typedef struct flow_struct {
int pkt_counter_fid; /* fid for PKT_COUNT */
int byte_counter_fid; /* fid for BYTE_COUNT */
/* struct mapi_results_t *pkt_counter_res; */ /* result of PKT_COUNTER */
/* struct mapi_results_t *byte_counter_res; */ /* result of BYTE_COUNTER */
unsigned long long pkt_counter[MAX_SUBJECTS]; /* packets from PKT_COUNTER */
unsigned long long byte_counter[MAX_SUBJECTS]; /* bytes from BYTE_COUNTER */
/* unsigned long long old_pkt_counter; */ /* previous packets dtto */
/* unsigned long long old_byte_counter; */ /* previous bytes dtto */
char *rrd_filename[MAX_SUBJECTS];
unsigned long long pkt_counter[MAX_SUBJECTS]; /* packets from PKT_COUNTER */
unsigned long long byte_counter[MAX_SUBJECTS]; /* bytes from BYTE_COUNTER */
char *rrd_filename;
unsigned long long pkt_ts[MAX_SUBJECTS]; /* time of the previous result */
unsigned long long byte_ts[MAX_SUBJECTS]; /* time of the previous result */
time_t rrd_ts[MAX_SUBJECTS]; /* time of previous RRD update */
time_t rrd_ts; /* time of previous RRD update */
struct flow_run_struct *next;
} flow_t;
......
This diff is collapsed.
......@@ -37,8 +37,6 @@
#define _GNU_SOURCE
#include <getopt.h>
#define ABW_CONST_CFG PREFIX "/etc/abw_const.cfg"
/*
* Leading colon ":" makes getopt() to return colon ":" rather than
* a question mark "?" when option argument is missing (and it returns
......@@ -49,30 +47,15 @@
* as not followed by ":" and an option with an optional argument as
* followed by "::".
*/
#define ARGS ":n:d:m:r:w:f:i:l:D::hqG"
#define ARGS ":f:hdgqsc"
/* Long option codes */
enum {
LO_HOSTNAME, LO_INTERFACE, LO_PORT,
LO_LINK_MBPS, LO_MPLS, LO_VLAN,
LO_SAU_MODE, LO_SAU_THRESHOLD, LO_PAYLOAD_STRING, LO_INTERVAL,
LO_PROTOCOLS,
/* enum {
LO_CONF_FILENAME, LO_NO_MEASURE, LO_NO_STDOUT, LO_STDOUT_SIMPLE,
LO_DEBUG, LO_DAEMON };
LO_DEBUG, LO_DAEMON }; */
/* Long option names and argument types */
static const struct option long_options[] = {
{ "hostname", required_argument, 0, LO_HOSTNAME },
{ "interface", required_argument, 0, LO_INTERFACE },
{ "port", required_argument, 0, LO_PORT },
{ "mpls", no_argument, 0, LO_MPLS },
{ "vlan", no_argument, 0, LO_VLAN },
{ "link_mbps", required_argument, 0, LO_LINK_MBPS },
{ "sau_mode", required_argument, 0, LO_SAU_MODE },
{ "sau_threshold", required_argument, 0, LO_SAU_THRESHOLD },
{ "payload_string", required_argument, 0, LO_PAYLOAD_STRING },
{ "interval", required_argument, 0, LO_INTERVAL },
{ "protocols", required_argument, 0, LO_PROTOCOLS },
/* static const struct option long_options[] = {
{ "conf_filename", required_argument, 0, LO_CONF_FILENAME },
{ "no_measure", no_argument, 0, LO_NO_MEASURE },
{ "no_stdout", no_argument, 0, LO_NO_STDOUT },
......@@ -80,7 +63,7 @@ static const struct option long_options[] = {
{ "debug", optional_argument, 0, LO_DEBUG },
{ "daemon", no_argument, 0, LO_DAEMON },
{ 0, 0, 0, 0 }
};
}; */
#define DEFAULT_HOSTNAME "localhost"
#define DEFAULT_INTERFACE "eth0"
......@@ -108,12 +91,6 @@ typedef struct subject_struct {
char *hostname;
char *interface;
int port;
int mpls;
int vlan;
int link_mbps;
char *label;
char *description;
int out;
struct subject_struct *next;
} subject_t;
......@@ -127,6 +104,12 @@ typedef struct scope_struct {
char *subject_array[MAX_SUBJECTS];
int subject_no;
int mpls;
int vlan;
int out;
char *label;
char *description;
struct scope_struct *next;
} scope_t;
......@@ -138,11 +121,8 @@ typedef struct parameters_struct {
char *payload_strings[MAX_PAYLOAD_STRINGS];
struct timeval interval;
/* Alternative representations, conversion done in check_conf() */
/* Alternative representation, conversion done in check_conf() */
int sau_mode_encoded;
/* int sau_packet_threshold;
int sau_byte_threshold;
float sau_pass_probability; */
struct parameters_struct *next;
} parameters_t;
......@@ -196,8 +176,6 @@ int read_conf_file(configuration_t *configuration);
int read_const_conf_file(configuration_t *configuration);
/* int read_password(configuration_t *configuration); */
int check_conf(configuration_t *configuration);
int print_conf(configuration_t *configuration);
......
This diff is collapsed.
......@@ -40,14 +40,13 @@
#define ABW_INFO_ARGS "f:hv"
/* Long option codes */
enum { LO_ABW_INFO_VERBOSE, LO_ABW_INFO_CONF_FILENAME, LO_SUBJECT_ID, LO_LABEL,
enum { LO_ABW_INFO_VERBOSE, LO_ABW_INFO_CONF_FILENAME, LO_LABEL,
LO_PARAMETERS_ID, LO_DIRECTION };
/* Long option names and argument types */
static const struct option abw_info_long_options[] = {
{ "verbose", no_argument, 0, LO_ABW_INFO_VERBOSE },
{ "conf_filename", required_argument, 0, LO_ABW_INFO_CONF_FILENAME },
{ "subject_id", required_argument, 0, LO_SUBJECT_ID },
{ "label", required_argument, 0, LO_LABEL },
{ "parameters_id", required_argument, 0, LO_PARAMETERS_ID },
{ "direction", required_argument, 0, LO_DIRECTION },
......
......@@ -41,38 +41,65 @@
#include "abw_rrd.h"
#include "abw_common.h"
#include "abw_conf.h"
extern int debug;
/* TODO: check for overflow */
/* /directory/hostname1-interface1-port1,hostname2-interface2-port2, ...
-parameters-protocol.rrd */
char *abw_rrd_create_filename(char *hostname, char *interface,
int port, int parameters_id, char *protocol) {
char *abw_rrd_create_filename(scope_t *scope, int parameters_id,
char *protocol) {
static char rrd_filename[MAX_RRD_FILENAME+1];
char *ch;
int i;
strcpy(rrd_filename, RRD_DIRECTORY);
if (hostname)
sprintf(rrd_filename+strlen(rrd_filename), "%s", hostname);
/* Remove leading '/' and replace other '/' with '_' */
if (interface) {
ch=rrd_filename+strlen(rrd_filename);
if (interface[0]=='/')
sprintf(rrd_filename+strlen(rrd_filename), "-%s", interface+1);
else
sprintf(rrd_filename+strlen(rrd_filename), "-%s", interface);
while (*ch) {
if (*ch=='/')
*ch='_';
ch++;
/* pointer after /directory/ where / must be replaced with _ */
ch=rrd_filename + strlen(RRD_DIRECTORY);
i=0;
while (scope->subject[i] && i<MAX_SUBJECTS) {
/* Append comma "," */
if (i) {
if (strlen(rrd_filename)+1>=MAX_RRD_FILENAME) {
fprintf(stderr, "%s: RRD filename is longer than %d characters\n",
__func__, MAX_RRD_FILENAME);
return NULL;
}
strcat(rrd_filename, ",");
}
}
if (port>=0)
sprintf(rrd_filename+strlen(rrd_filename), "-%d", port);
/* Append next hostname-interface-port */
if (strlen(rrd_filename) +
strlen(scope->subject[i]->hostname) +
strlen(scope->subject[i]->interface) +
5 + 2 /* 5 for port, 1 for - and 1 for - */
>= MAX_RRD_FILENAME) {
fprintf(stderr, "%s: RRD filename is longer than %d characters\n",
__func__, MAX_RRD_FILENAME);
return NULL;
}
sprintf(rrd_filename + strlen(rrd_filename), "%s-%s-%d",
scope->subject[i]->hostname,
scope->subject[i]->interface,
(scope->subject[i]->port)>=0?scope->subject[i]->port:0);
i++;
} /* while (scope->subject[i] && i<MAX_SUBJECTS) */
/* Replace '/' with '_' */
while (*ch) {
if (*ch=='/')
*ch='_';
ch++;
}
/* If we do not use parameters, still append default "1" for
compatibility with scripts */
......@@ -85,9 +112,6 @@ char *abw_rrd_create_filename(char *hostname, char *interface,
if (protocol)
sprintf(rrd_filename+strlen(rrd_filename), "-%s", protocol);
/* if (rrd_filename[strlen(rrd_filename)-1]=='-')
rrd_filename[strlen(rrd_filename)-1]='\0'; */
/*
* If protocol is specified, this is a full RRD filename. If protocol is not
* specified, this is a prefix for rrd_graph... scripts.
......@@ -130,7 +154,7 @@ int abw_rrd_create_file(char *filename) {
}
else {
if (debug)
printf("%s: RRD file %s already exists\n", __func__, filename);
printf("%s: Ok, RRD file %s already exists\n", __func__, filename);
}
return 0;
......
......@@ -35,13 +35,14 @@
#define __ABW_RRD_H
#include "abw_common.h"
#include "abw_conf.h"
#define MAX_RRD_FILENAME 256
#define RRD_CREATE_LINK_SCRIPT PREFIX "/bin/rrd_create_link.sh"
#define RRD_DIRECTORY ABW_VAR_DIR "/rrd/" /* include trailing / */
char *abw_rrd_create_filename(char *hostname, char *interface,
int port, int parameters_id, char *protocol);
char *abw_rrd_create_filename(scope_t *scope, int parameters_id,
char *protocol);
int abw_rrd_create_file(char *filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment