Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arne Øslebø
mapi
Commits
4144b89b
Commit
4144b89b
authored
Oct 06, 2006
by
Browse files
Updating appmon args
git-svn-id:
file:///home/svn/mapi/trunk@925
8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent
bdb437d2
Changes
3
Show whitespace changes
Inline
Side-by-side
applications/appmon/appmon.c
View file @
4144b89b
...
...
@@ -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,26 +115,15 @@ 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 */
...
...
@@ -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
;
...
...
@@ -449,40 +441,47 @@ void *process() {
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
,
"%s"
,
p
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
++
){
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
"
);
}
}
...
...
@@ -495,15 +494,39 @@ 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
++
){
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
"
);
...
...
@@ -515,20 +538,54 @@ void *process() {
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
;
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
);
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
);
}
// }
}
...
...
applications/appmon/cgi_headers.h
View file @
4144b89b
...
...
@@ -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
[]
=
"\
...
...
applications/appmon/index.html
View file @
4144b89b
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment