Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noddos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
noddos
Commits
71c9fe77
Commit
71c9fe77
authored
15 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add a tiny historical graph of qps
parent
89fe6829
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
master/status_httpd.cc
+60
-6
60 additions, 6 deletions
master/status_httpd.cc
with
60 additions
and
6 deletions
master/status_httpd.cc
+
60
−
6
View file @
71c9fe77
// $Id$
// $Id$
#include
<numeric>
#include
<iostream>
#include
<iostream>
#include
<sstream>
#include
<sstream>
#include
<string>
#include
<string>
#include
"status_httpd.h"
#include
"status_httpd.h"
using
namespace
std
;
namespace
dos
{
namespace
dos
{
static
void
normalize
(
vector
<
double
>&
values
)
{
ostringstream
ds
;
double
min
=
min_element
(
values
.
begin
(),
values
.
end
());
double
max
=
max_element
(
values
.
begin
(),
values
.
end
());
vector
<
double
>::
iterator
i
;
for
(
i
=
values
.
begin
();
i
!=
values
.
end
();
++
i
)
*
i
=
(
*
i
-
min
)
/
(
max
-
min
);
}
static
string
to_dataset
(
vector
<
double
>&
values
)
{
static
const
char
vchar
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
;
normalize
(
values
);
ostringstream
ds
;
vector
<
double
>::
const_iterator
i
;
for
(
i
=
values
.
begin
();
i
!=
values
.
end
();
++
i
)
ds
<<
vchar
[
static_cast
<
int
>
(
100
*
(
*
i
))];
return
ds
.
str
();
}
static
string
qps_graph
(
const
vector
<
QpsTuple
>&
qps_values
,
int
width
=
500
,
int
height
=
200
)
{
ostringstream
url
;
url
<<
"http://chart.apis.google.com/chart"
<<
"?chs="
<<
width
<<
"x"
<<
height
<<
"&cht=lc"
;
vector
<
double
>
stdup
,
avg
,
stddown
;
vector
<
QpsTuple
>::
const_iterator
i
;
for
(
i
=
qps_values
.
begin
();
i
!=
qps_values
.
end
();
++
i
)
{
stdup
.
push_back
((
*
i
).
value
+
(
*
i
).
std_dev
);
avg
.
push_back
((
*
i
).
value
);
stddown
.
push_back
((
*
i
).
value
-
(
*
i
).
std_dev
);
}
url
<<
"&chd=s:"
<<
to_dataset
(
stdup
)
<<
","
<<
to_dataset
(
avg
)
<<
","
<<
to_dataset
(
stddown
);
}
void
StatusHttpd
::
handle_status
(
evhttp_request
*
req
)
void
StatusHttpd
::
handle_status
(
evhttp_request
*
req
)
{
{
std
::
ostringstream
resp
;
ostringstream
resp
;
resp
<<
"<?xml version=
\"
1.0
\"
?>
\n
"
resp
<<
"<?xml version=
\"
1.0
\"
?>
\n
"
<<
"<html lang=
\"
en
\"
>
\n
"
<<
"<html lang=
\"
en
\"
>
\n
"
...
@@ -19,13 +66,20 @@ void StatusHttpd::handle_status(evhttp_request *req)
...
@@ -19,13 +66,20 @@ void StatusHttpd::handle_status(evhttp_request *req)
resp
<<
"<h1>NoDDoS Master</h1>"
;
resp
<<
"<h1>NoDDoS Master</h1>"
;
resp
<<
"<p>Global QPS: <b>"
<<
logic
->
get_qps
()
<<
"</b></p>"
vector
<
QpsTuple
>
qps_values
;
logic
->
get_store
()
->
read_stats
(
qps_values
,
24
);
string
graph_url
=
qps_graph
(
qps_values
);
resp
<<
"<table><tr><td valign=
\"
top
\"
>"
<<
"<p>Global QPS: <b>"
<<
logic
->
get_qps
()
<<
"</b></p>"
<<
"<p>Global status: <b>"
<<
logic
->
get_status
().
str
()
<<
"<p>Global status: <b>"
<<
logic
->
get_status
().
str
()
<<
"</b></p>
\n
"
;
<<
"</b></p>
\n
"
<<
"</td><td>"
<<
"<img src=
\"
"
<<
graph_url
<<
"
\"
border=
\"
0
\"
/>"
<<
"</td></tr></table>
\n
"
;
resp
<<
"<h3>Nodes</h3><ul>"
;
resp
<<
"<h3>Nodes</h3><ul>"
;
std
::
vector
<
std
::
string
>
nodes
=
logic
->
nodes
();
vector
<
string
>
nodes
=
logic
->
nodes
();
std
::
vector
<
std
::
string
>::
const_iterator
i
;
vector
<
string
>::
const_iterator
i
;
for
(
i
=
nodes
.
begin
();
i
!=
nodes
.
end
();
i
++
)
for
(
i
=
nodes
.
begin
();
i
!=
nodes
.
end
();
i
++
)
resp
<<
"<li><a href=
\"
http://"
<<
(
*
i
)
resp
<<
"<li><a href=
\"
http://"
<<
(
*
i
)
<<
"/
\"
>"
<<
(
*
i
)
<<
"</a></li>"
;
<<
"/
\"
>"
<<
(
*
i
)
<<
"</a></li>"
;
...
@@ -33,7 +87,7 @@ void StatusHttpd::handle_status(evhttp_request *req)
...
@@ -33,7 +87,7 @@ void StatusHttpd::handle_status(evhttp_request *req)
resp
<<
"<h3>Blacklisted hosts</h3><table class=
\"
d
\"
>"
resp
<<
"<h3>Blacklisted hosts</h3><table class=
\"
d
\"
>"
<<
"<thead><tr><th>IP</th></tr></thead><tbody>"
;
<<
"<thead><tr><th>IP</th></tr></thead><tbody>"
;
std
::
vector
<
std
::
string
>
blacklist
=
logic
->
get_blacklist
();
vector
<
string
>
blacklist
=
logic
->
get_blacklist
();
for
(
i
=
blacklist
.
begin
();
i
!=
blacklist
.
end
();
i
++
)
for
(
i
=
blacklist
.
begin
();
i
!=
blacklist
.
end
();
i
++
)
resp
<<
"<tr><td>"
<<
(
*
i
)
<<
"</td></tr>"
;
resp
<<
"<tr><td>"
<<
(
*
i
)
<<
"</td></tr>"
;
resp
<<
"</tbody></table>
\n
"
;
resp
<<
"</tbody></table>
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment