Skip to content

Commit

Permalink
Feature: added hostname section for issues/37
Browse files Browse the repository at this point in the history
  • Loading branch information
vozlt committed Feb 8, 2017
1 parent 468f6e4 commit 5f18695
Show file tree
Hide file tree
Showing 7 changed files with 491 additions and 481 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ v0.1.12 [Tue Feb 07 2017 YoungJoo.Kim <vozltx@gmail.com>]
* Feature: added request_time, request_times sections for
issues/(43|57) and pull/67

* Feature: added hostname section for issues/37

* Refactor: divided the source code because of too big

v0.1.11 [Wed Nov 09 2016 YoungJoo.Kim <vozltx@gmail.com>]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ JSON document contains as follows:

```Json
{
"hostName": ...,
"nginxVersion": ...,
"loadMsec": ...,
"nowMsec": ...,
Expand Down Expand Up @@ -479,6 +480,8 @@ The following status information is provided in the JSON format:

/*`{status_uri}`*/control?cmd=status&...

* hostName
* Host name.
* nginxVersion
* Version of the provided.
* loadMsec
Expand Down
2 changes: 1 addition & 1 deletion share/status.compress.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions share/status.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h1>
</div>

<div id="footer" class="footer">
<a href="/format/json" id="jsonUri"><strong>JSON</strong></a>
<a href="{{uri}}/format/json" id="jsonUri"><strong>JSON</strong></a>
| <a href="https://github.com/vozlt/nginx-module-vts"><strong>GITHUB</strong></a>
</div>

Expand Down Expand Up @@ -540,8 +540,8 @@ <h1>
/* main */
aPs.refresh(it.nowMsec);
var cache = 0;
var out = '<div id="serverInfos"><h2>Server main</h2><table><thead><tr><th rowspan="2">Version</th><th rowspan="2">Uptime</th><th colspan="4">Connections</th><th colspan="5">Requests</th></tr><tr><th>active</th><th>reading</th><th>writing</th><th>waiting</th><th>accepted</th><th>handled</th><th>Total</th><th>Req/s</th></tr></thead><tbody>';
out += '<tr><td>' + it.nginxVersion + '</td><td>' + mTh(it.nowMsec - it.loadMsec) + '</td><td>'
var out = '<div id="serverInfos"><h2>Server main</h2><table><thead><tr><th rowspan="2">Host</th><th rowspan="2">Version</th><th rowspan="2">Uptime</th><th colspan="4">Connections</th><th colspan="5">Requests</th></tr><tr><th>active</th><th>reading</th><th>writing</th><th>waiting</th><th>accepted</th><th>handled</th><th>Total</th><th>Req/s</th></tr></thead><tbody>';
out += '<tr><td>' + it.hostName + '</td><td>' + it.nginxVersion + '</td><td>' + mTh(it.nowMsec - it.loadMsec) + '</td><td>'
+ it.connections.active + '</td><td>'
+ it.connections.reading + '</td><td>'
+ it.connections.writing + '</td><td>'
Expand Down
7 changes: 4 additions & 3 deletions src/ngx_http_vhost_traffic_status_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ ngx_http_vhost_traffic_status_display_handler_default(ngx_http_request_t *r)

}
else {
b->last = ngx_sprintf(b->last, NGX_HTTP_VHOST_TRAFFIC_STATUS_HTML_DATA, &uri);
b->last = ngx_sprintf(b->last, NGX_HTTP_VHOST_TRAFFIC_STATUS_HTML_DATA, &uri, &uri);
}

r->headers_out.status = NGX_HTTP_OK;
Expand Down Expand Up @@ -482,8 +482,9 @@ ngx_http_vhost_traffic_status_display_set_main(ngx_http_request_t *r,
wr = *ngx_stat_writing;
wa = *ngx_stat_waiting;

buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_MAIN, NGINX_VERSION,
vtscf->start_msec, ngx_current_msec, ac, rd, wr, wa, ap, hn, rq);
buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_MAIN, &ngx_cycle->hostname,
NGINX_VERSION, vtscf->start_msec, ngx_current_msec,
ac, rd, wr, wa, ap, hn, rq);

return buf;
}
Expand Down
3 changes: 2 additions & 1 deletion src/ngx_http_vhost_traffic_status_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
#define NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_E "}"
#define NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_NEXT ","

#define NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_MAIN "\"nginxVersion\":\"%s\"," \
#define NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_MAIN "\"hostName\":\"%V\"," \
"\"nginxVersion\":\"%s\"," \
"\"loadMsec\":%M," \
"\"nowMsec\":%M," \
"\"connections\":{" \
Expand Down
Loading

0 comments on commit 5f18695

Please sign in to comment.