modify the getListener function && add TPS in dashboard

This commit is contained in:
XueBing 2016-12-18 23:35:14 +08:00
parent edf4bc431d
commit d93dd82ed9
2 changed files with 14 additions and 8 deletions

View File

@ -25,6 +25,7 @@
<th class="tab_info" ng-click="col='current_conns';desc=!desc">CurCon<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='daily[daily.length-1].flow_out';desc=!desc">FlowOut<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='daily[daily.length-1].flow_in';desc=!desc">FlowIn<i class="iconfont pull-right">&#xe66d;</i></th>
<th class="tab_info" ng-click="col='daily[daily.length-1].total_accept_conns';desc=!desc">TotalAcceptConns<i class="iconfont pull-right">&#xe66d;</i></th>
</tr>
</thead>
<tbody id="tab_body">
@ -34,10 +35,11 @@
</td>
<td><span ng-bind="x.type"></span></td>
<td><span ng-bind="x.listen_port"></span></td>
<td><span ng-bind="x.status"></span></td>
<td><span ng-bind="x.status_desc"></span></td>
<td><span ng-bind="x.current_conns"></span></td>
<td><span ng-bind="x.daily[x.daily.length-1].flow_out"></span></td>
<td><span ng-bind="x.daily[x.daily.length-1].flow_in"></span></td>
<td><span ng-bind="x.daily[x.daily.length-1].total_accept_conns"></span></td>
</tr>
</tbody>
</table>

View File

@ -76,10 +76,19 @@ func (v *VhostMuxer) Listen(p *config.ProxyServerConf) (ls []*Listener) {
return ls
}
func (v *VhostMuxer) getListener(name string) (l *Listener, exist bool) {
func (v *VhostMuxer) getListener(reqInfoMap map[string]string) (l *Listener, exist bool) {
v.mutex.RLock()
defer v.mutex.RUnlock()
//host
name := strings.ToLower(reqInfoMap["Host"])
// http
scheme := strings.ToLower(reqInfoMap["Scheme"])
if scheme == "http" || scheme == "" {
name = name + ":" + reqInfoMap["Path"]
}
// // first we check the full hostname
vr, found := v.registryRouter.get(name)
if found {
@ -126,12 +135,7 @@ func (v *VhostMuxer) handle(c *conn.Conn) {
return
}
name := strings.ToLower(reqInfoMap["Host"])
// get listener by hostname
if reqInfoMap["Scheme"] == "http" {
name = name + ":" + reqInfoMap["Path"]
}
l, ok := v.getListener(name)
l, ok := v.getListener(reqInfoMap)
if !ok {
c.Close()
return