Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add port config for tsar #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好文档说一下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`
Expand Down
5 changes: 4 additions & 1 deletion mod_nginx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));

Expand Down