Commit 4144b89b authored by 's avatar
Browse files

Updating appmon args


git-svn-id: file:///home/svn/mapi/trunk@925 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent bdb437d2
......@@ -70,7 +70,7 @@ int main(int argc, char **argv) {
verbose = 0;
anonymize = 1;
refresh_time = 10;
private = 0;
private = 1;
signal(SIGINT, terminate);
signal(SIGQUIT, terminate);
......@@ -95,7 +95,8 @@ int main(int argc, char **argv) {
refresh_time = atoi(optarg);
break;
case 'n':
MonitorName = optarg;
free(MonitorName);
MonitorName = strdup(optarg);
break;
case 'a':
anonymize = 1;
......@@ -104,6 +105,8 @@ int main(int argc, char **argv) {
anonymize = 1;
private = 1;
break;
case 'f':
case 'v':
verbose = 1;
break;
......@@ -112,27 +115,16 @@ int main(int argc, char **argv) {
}
}
strncpy(local_net, argv[1], MAXLINE);
if(optind + 2 != argc) {
usage();
}
strncpy(local_net, argv[optind], MAXLINE);
printf("local net: %s\n", local_net);
/* concatenate args to build the scope argument for create_flow() */
printf("scope: ");
for(i=2; i<argc; ++i) {
printf("%s\n", argv[i]);
scope_strlen += strlen(argv[i]);
}
scope = (char *)malloc(scope_strlen + argc-2 + 1);
if (scope == NULL) {
printf("Could not allocate memory\n");
exit(EXIT_FAILURE);
}
*scope = '\0';
for(i=2; i<argc; ++i) {
strncat(scope, argv[i], 64);
if (i < argc-1)
strcat(scope, ",");
}
scope = strdup(argv[optind + 1]);
printf("scope: %s\n",scope);
/* start processing */
create_flows(scope);
......@@ -322,7 +314,7 @@ void *process() {
unsigned long long timestamp_in;
unsigned long long timestamp_out;
struct stats_t stats[NUMFILTERS] = {{0,0,0,0}};
struct stats_t stats[NUMFILTERS] = {{0,0,0,0,0,0,0,0}};
mapi_results_t *dres;
char rrd_record[1024], *p;
......@@ -448,42 +440,49 @@ void *process() {
sprintf(top_page_buf, top_page, TOP_FILENAME);
fprintf(fp, "%s", top_page_buf);
if(private) {
fprintf(fp, "<a href=private/%s>Private Section Non-Anonymized</a>", PTOP_FILENAME);
}
fprintf(fp, "<center><table border=1 width=75\%>\n");
fprintf(fp, "\n<tr><th colspan=3>INCOMING TRAFFIC</th></tr>\n");
fprintf(fp, "<tr><th>IP</th><th>Protocol</th><th>Traffic</th></tr>\n");
if(private) {
pfp = fopen(PTOP_FILENAME, "w");
sprintf(ptop_page_buf, top_page, PTOP_FILENAME);
fprintf(pfp, "%s", top_page_buf);
fprintf(pfp, "<center><table border=1 width=75\%>\n");
fprintf(pfp, "\n<tr><th colspan=3>INCOMING TRAFFIC</th></tr>\n");
fprintf(pfp, "<tr><th>IP</th><th>Protocol</th><th>Traffic</th></tr>\n");
}
pfp = fopen(PTOP_FILENAME, "w");
sprintf(ptop_page_buf, top_page, PTOP_FILENAME);
fprintf(pfp, "%s", ptop_page_buf);
fprintf(pfp, "<center><table border=1 width=75\%>\n");
fprintf(pfp, "\n<tr><th colspan=3>INCOMING TRAFFIC</th></tr>\n");
fprintf(pfp, "<tr><th>IP</th><th>Protocol</th><th>Traffic</th></tr>\n");
}
for(i = 0; i < 10 && i < in_top_cnt; i++){
fprintf(fp, "<tr >\n");
struct in_addr ip;
ip.s_addr = (unsigned long int)in_top_clients[i].ip;
if(anonymize) {
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
}
else {
fprintf(fp, "<td align=left>%s</td>\n", inet_ntoa(ip));
}
fprintf(fp, "<td align=center bgcolor=\"%s\"> %s </td>\n",filter[in_top_clients[i].tracker_no].color,in_top_clients[i].tracker_name);
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", in_top_clients[i].speed);
fprintf(fp, "</tr>\n");
if(private) {
fprintf(pfp, "<td align=left>%s</td>\n", inet_ntoa(ip));
fprintf(pfp, "<td align=center bgcolor=\"%s\"> %s </td>\n",filter[in_top_clients[i].tracker_no].color,in_top_clients[i].tracker_name);
fprintf(pfp, "<td align=right>%.2lf Kbps</td>\n", in_top_clients[i].speed);
fprintf(pfp, "</tr>\n");
}
for(i = 0; i < 10 && i < in_top_cnt; i++) {
fprintf(fp, "<tr >\n");
struct in_addr ip;
ip.s_addr = (unsigned long int)in_top_clients[i].ip;
if(anonymize) {
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
}
else {
fprintf(fp, "<td align=left>%s</td>\n", inet_ntoa(ip));
}
fprintf(fp, "<td align=center bgcolor=\"%s\"> %s </td>\n",filter[in_top_clients[i].tracker_no].color,in_top_clients[i].tracker_name);
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", in_top_clients[i].speed);
fprintf(fp, "</tr>\n");
if(private) {
fprintf(pfp, "<tr>\n");
fprintf(pfp, "<td align=left>%s</td>\n", inet_ntoa(ip));
fprintf(pfp, "<td align=center bgcolor=\"%s\"> %s </td>\n",filter[in_top_clients[i].tracker_no].color,in_top_clients[i].tracker_name);
fprintf(pfp, "<td align=right>%.2lf Kbps</td>\n", in_top_clients[i].speed);
fprintf(pfp, "</tr>\n");
}
}
......@@ -494,17 +493,41 @@ void *process() {
fprintf(fp, "<center><table border=1 width=75\%>\n");
fprintf(fp, "\n<tr><th colspan=3>OUTGOING TRAFFIC</th></tr>\n");
fprintf(fp, "<tr><th>IP</th><th>Protocol</th><th>Traffic</th></tr>\n");
for(i = 0; i < 10 && i < out_top_cnt; i++){
fprintf(fp, "<tr >\n");
struct in_addr ip;
ip.s_addr = (unsigned long int)out_top_clients[i].ip;
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
fprintf(fp, "<td align=center bgcolor=\"%s\"> %s </td>\n", filter[out_top_clients[i].tracker_no].color,out_top_clients[i].tracker_name);
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", out_top_clients[i].speed);
fprintf(fp, "</tr>\n");
}
if(private) {
fprintf(pfp, "</table></center>\n");
fprintf(pfp, "<P>\n");
fprintf(pfp, "<center><table border=1 width=75\%>\n");
fprintf(pfp, "\n<tr><th colspan=3>OUTGOING TRAFFIC</th></tr>\n");
fprintf(pfp, "<tr><th>IP</th><th>Protocol</th><th>Traffic</th></tr>\n");
}
for(i = 0; i < 10 && i < out_top_cnt; i++) {
fprintf(fp, "<tr >\n");
struct in_addr ip;
ip.s_addr = (unsigned long int)out_top_clients[i].ip;
if(anonymize) {
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
}
else {
fprintf(fp, "<td align=left>%s</td>\n", inet_ntoa(ip));
}
fprintf(fp, "<td align=center bgcolor=\"%s\"> %s </td>\n", filter[out_top_clients[i].tracker_no].color,out_top_clients[i].tracker_name);
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", out_top_clients[i].speed);
fprintf(fp, "</tr>\n");
if(private) {
fprintf(pfp, "<tr>\n");
fprintf(pfp, "<td align=left>%s</td>\n", inet_ntoa(ip));
fprintf(pfp, "<td align=center bgcolor=\"%s\"> %s </td>\n",filter[out_top_clients[i].tracker_no].color,out_top_clients[i].tracker_name);
fprintf(pfp, "<td align=right>%.2lf Kbps</td>\n", out_top_clients[i].speed);
fprintf(pfp, "</tr>\n");
}
}
fprintf(fp, "</table></center>\n");
......@@ -514,21 +537,55 @@ void *process() {
fprintf(fp, "\n<tr> <th colspan=4>TOTAL TRAFFIC</th></tr>\n");
fprintf(fp, "\n<tr> <th colspan=2>INCOMING TRAFFIC</th> <th colspan=2>OUTGOING TRAFFIC</th></tr>\n");
fprintf(fp, "<tr><th>IP</th><th>Traffic</th><th>IP</th><th>Traffic</th></tr>\n");
if(private) {
fprintf(pfp, "</table></center>\n");
fprintf(pfp, "<P>\n");
fprintf(pfp, "<center><table border=1 width=75\%>\n");
fprintf(pfp, "\n<tr> <th colspan=4>TOTAL TRAFFIC</th></tr>\n");
fprintf(pfp, "\n<tr> <th colspan=2>INCOMING TRAFFIC</th> <th colspan=2>OUTGOING TRAFFIC</th></tr>\n");
fprintf(pfp, "<tr><th>IP</th><th>Traffic</th><th>IP</th><th>Traffic</th></tr>\n");
}
for(i = 0; i < 5;i++) {
fprintf(fp, "<tr >\n");
struct in_addr ip;
// IN
ip.s_addr = (unsigned long int)ip_in_top_clients[i].ip;
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", ip_in_top_clients[i].speed);
// OUT
ip.s_addr = (unsigned long int)ip_out_top_clients[i].ip;
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", ip_out_top_clients[i].speed);
fprintf(fp, "<tr >\n");
struct in_addr ip;
// IN
ip.s_addr = (unsigned long int)ip_in_top_clients[i].ip;
if(anonymize) {
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
}
else {
fprintf(fp, "<td align=left>%s</td>\n", inet_ntoa(ip));
}
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", ip_in_top_clients[i].speed);
fprintf(fp, "</tr>\n");
if(private) {
fprintf(pfp, "<td align=left>%s</td>\n", inet_ntoa(ip));
fprintf(pfp, "<td align=right>%.2lf Kbps</td>\n", ip_in_top_clients[i].speed);
}
// OUT
ip.s_addr = (unsigned long int)ip_out_top_clients[i].ip;
if(anonymize) {
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(ip));
}
else {
fprintf(fp, "<td align=left>%s</td>\n", inet_ntoa(ip));
}
fprintf(fp, "<td align=right>%.2lf Kbps</td>\n", ip_out_top_clients[i].speed);
fprintf(fp, "</tr>\n");
if(private) {
fprintf(pfp, "<td align=left>%s</td>\n", inet_ntoa(ip));
fprintf(pfp, "<td align=right>%.2lf Kbps</td>\n", ip_out_top_clients[i].speed);
fprintf(pfp, "</tr>\n");
}
}
fprintf(fp, "</table></center>\n");
......@@ -536,6 +593,14 @@ void *process() {
fprintf(fp, "</div></body></html>");
fflush(fp);
fclose(fp);
if(private) {
fprintf(pfp, "</table></center>\n");
fprintf(pfp, "</div></body></html>");
fflush(pfp);
fclose(pfp);
}
// }
}
......
......@@ -7,6 +7,7 @@
#define CGI_FILENAME BASENAME".cgi"
#define FORM_FILENAME BASENAME"_form.html"
#define TOP_FILENAME BASENAME"_top.html"
#define PTOP_FILENAME BASENAME"_top_private.html"
static char cgiHour[] = "\
......
......@@ -3,7 +3,7 @@
<title>CGI-C Test Form</title>
</head>
<frameset cols="80%,20%">
<frameset cols="600pi,45%">
<frame src="cgi-bin/appmon.cgi" name="fig">
<frame src="./appmon_top.html" name="text">
</frameset>
......
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