Commit 880852a2 authored by 's avatar
Browse files

adding private and anonymize options


git-svn-id: file:///home/svn/mapi/trunk@921 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent b5d98614
......@@ -54,8 +54,9 @@ static char *progname;
int verbose;
int refresh_time;
int anonymize;
int private;
char *MonitorName = "Monitor";
char *MonitorName = "University of Crete Monitor";
int main(int argc, char **argv) {
......@@ -69,10 +70,11 @@ int main(int argc, char **argv) {
verbose = 0;
anonymize = 1;
refresh_time = 10;
private = 0;
signal(SIGINT, terminate);
signal(SIGQUIT, terminate);
signal(SIGTERM, terminate);
signal(SIGQUIT, terminate);
signal(SIGTERM, terminate);
progname = strdup(argv[0]);
......@@ -82,7 +84,7 @@ int main(int argc, char **argv) {
}
while((opt = getopt(argc, argv, "hval:i:n:")) != EOF)
while((opt = getopt(argc, argv, "hvpal:i:n:")) != EOF)
{
switch(opt)
{
......@@ -98,6 +100,10 @@ int main(int argc, char **argv) {
case 'a':
anonymize = 1;
break;
case 'p':
anonymize = 1;
private = 1;
break;
case 'v':
verbose = 1;
break;
......@@ -323,12 +329,13 @@ void *process() {
int i;
double speed;
char top_page_buf[1024];
char ptop_page_buf[1024];
// TOP vars
unsigned int times = 0;
unsigned int j = 0, *cnt = NULL;
struct topx_result *tmp;
FILE *fp;
FILE *fp, *pfp;
struct top_clients_t in_top_clients[NUMFILTERS*10];
struct top_clients_t out_top_clients[NUMFILTERS*10];
struct top_clients_t ip_in_top_clients[10], ip_out_top_clients[10];
......@@ -435,7 +442,7 @@ void *process() {
sort_top(in_top_clients, in_top_cnt);
sort_top(out_top_clients, out_top_cnt);
fp = fopen(TOP_FILENAME, "w");
sprintf(top_page_buf, top_page, TOP_FILENAME);
......@@ -445,15 +452,39 @@ void *process() {
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");
}
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;
fprintf(fp, "<td align=left>%s</td>\n", anonimize_ip(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");
}
}
fprintf(fp, "</table></center>\n");
......@@ -464,15 +495,15 @@ void *process() {
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");
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");
}
fprintf(fp, "</table></center>\n");
......
......@@ -3,7 +3,7 @@
<title>CGI-C Test Form</title>
</head>
<frameset cols="50%,50%">
<frameset cols="80%,20%">
<frame src="cgi-bin/appmon.cgi" name="fig">
<frame src="./appmon_top.html" name="text">
</frameset>
......
......@@ -6,6 +6,7 @@ fi
mkdir $1/appmon
mkdir $1/appmon/cgi-bin
mkdir $1/appmon/private
# awful
chmod 777 $1/appmon
......@@ -20,6 +21,7 @@ ln -fs `pwd`/appmon24.cgi $1/appmon/cgi-bin/appmon24.cgi
ln -fs `pwd`/appmonWeek.cgi $1/appmon/cgi-bin/appmonWeek.cgi
ln -fs `pwd`/appmonMonth.cgi $1/appmon/cgi-bin/appmonMonth.cgi
ln -fs `pwd`/appmonYear.cgi $1/appmon/cgi-bin/appmonYear.cgi
ln -fs `pwd`/appmon_top_private.html $1/appmon/private/appmon_top_private.html
echo -e "\nDONE - created the following files in $1/appmon\n"
......
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