From e3221512062f163cd312fd93651680b8031e32bc Mon Sep 17 00:00:00 2001 From: kongjian Date: Fri, 19 Apr 2013 13:35:44 +0800 Subject: [PATCH 1/2] add parameter for nginx port --- README.md | 13 ++++++++++--- mod_nginx.c | 5 ++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2760c63..011398a 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Support read data from nginx by common socket or unix domain socket. Quick start ----------- -1. Install [tsar](http://code.taobao.org/p/tsar/src/). -2. Generate a new module by using [tsardevel](http://code.taobao.org/p/tsar/wiki/mod/). +1. Install [tsar](https://github.com/alibaba/tsar). +2. Generate a new module by using [tsardevel](https://github.com/alibaba/tsar/tree/master/devel). >`tsardevel ngx_mod` 3. Replace ngx_mod.c. @@ -23,7 +23,14 @@ Configuration ------------- 1. Default host is 127.0.0.1 and default port is 80. But we can change both (or one of) the host and port: - ####example: + ####config port: + >modify `/etc/tsar/tsar.conf` + + >add port after `mod_nginx on` such as `mod_nginx on 8080` + + or + + ####modify EV: >`export NGX_TSAR_HOST=192.168.0.1` >`export NGX_TSAR_PORT=8080` diff --git a/mod_nginx.c b/mod_nginx.c index 40d5c91..6879a6e 100644 --- a/mod_nginx.c +++ b/mod_nginx.c @@ -82,7 +82,7 @@ static void init_nginx_host_info(struct hostinfo *p) } -void read_nginx_stats(struct module *mod) +void read_nginx_stats(struct module *mod, char *parameter) { int write_flag = 0, addr_len, domain; int m, sockfd, send, pos; @@ -94,6 +94,9 @@ void read_nginx_stats(struct module *mod) FILE *stream = NULL; struct hostinfo hinfo; init_nginx_host_info(&hinfo); + if(atoi(parameter) != 0){ + hinfo.port = atoi(parameter); + } struct stats_nginx st_nginx; memset(&st_nginx, 0, sizeof(struct stats_nginx)); From 0cf77423490493f2f3dde51364c4dfd7021d2f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=8B?= Date: Fri, 19 Apr 2013 14:43:25 +0800 Subject: [PATCH 2/2] Update README.md for config priority --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 011398a..8c4fafc 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Configuration >`export NGX_TSAR_HOST=192.168.0.1` >`export NGX_TSAR_PORT=8080` + + notice:config's priority is higher than modify EV 2. Stub Status module must be included,and add configuration as below: