Skip to content

Commit

Permalink
dashboard: add proxy start and close time
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed May 30, 2017
1 parent 44971c7 commit e29a133
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assets/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>frps dashboard</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?189199ae955b61cb7046"></script><script type="text/javascript" src="vendor.js?66dfcf2d1c500e900413"></script><script type="text/javascript" src="index.js?ba5d6545ccb2ffaaf197"></script></body> </html>
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>frps dashboard</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?5217927b66cc446ebfd3"></script><script type="text/javascript" src="vendor.js?66dfcf2d1c500e900413"></script><script type="text/javascript" src="index.js?bf962cded96400bef9a0"></script></body> </html>
4 changes: 2 additions & 2 deletions assets/static/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/static/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/statik/statik.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion server/dashboard_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type ProxyStatsInfo struct {
TodayTrafficIn int64 `json:"today_traffic_in"`
TodayTrafficOut int64 `json:"today_traffic_out"`
CurConns int64 `json:"cur_conns"`
LastStartTime string `json:"last_start_time"`
LastCloseTime string `json:"last_close_time"`
Status string `json:"status"`
}

Expand Down Expand Up @@ -176,10 +178,12 @@ func getProxyStatsByType(proxyType string) (proxyInfos []*ProxyStatsInfo) {
} else {
proxyInfo.Status = consts.Offline
}
proxyInfo.Name = ps.Name
proxyInfo.TodayTrafficIn = ps.TodayTrafficIn
proxyInfo.TodayTrafficOut = ps.TodayTrafficOut
proxyInfo.CurConns = ps.CurConns
proxyInfo.Name = ps.Name
proxyInfo.LastStartTime = ps.LastStartTime
proxyInfo.LastCloseTime = ps.LastCloseTime
proxyInfos = append(proxyInfos, proxyInfo)
}
return
Expand Down
20 changes: 14 additions & 6 deletions server/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func StatsNewProxy(name string, proxyType string) {
proxyStats, ok := globalStats.ProxyStatistics[name]
if !(ok && proxyStats.ProxyType == proxyType) {
proxyStats = &ProxyStatistics{
Name: name,
ProxyType: proxyType,
CurConns: metric.NewCounter(),
TrafficIn: metric.NewDateCounter(ReserveDays),
TrafficOut: metric.NewDateCounter(ReserveDays),
LastStartTime: time.Now(),
Name: name,
ProxyType: proxyType,
CurConns: metric.NewCounter(),
TrafficIn: metric.NewDateCounter(ReserveDays),
TrafficOut: metric.NewDateCounter(ReserveDays),
}
globalStats.ProxyStatistics[name] = proxyStats
}
proxyStats.LastStartTime = time.Now()
}
}

Expand Down Expand Up @@ -230,6 +230,8 @@ type ProxyStats struct {
Type string
TodayTrafficIn int64
TodayTrafficOut int64
LastStartTime string
LastCloseTime string
CurConns int64
}

Expand All @@ -250,6 +252,12 @@ func StatsGetProxiesByType(proxyType string) []*ProxyStats {
TodayTrafficOut: proxyStats.TrafficOut.TodayCount(),
CurConns: proxyStats.CurConns.Count(),
}
if !proxyStats.LastStartTime.IsZero() {
ps.LastStartTime = proxyStats.LastStartTime.Format("01-02 15:04:05")
}
if !proxyStats.LastCloseTime.IsZero() {
ps.LastCloseTime = proxyStats.LastCloseTime.Format("01-02 15:04:05")
}
res = append(res, ps)
}
return res
Expand Down
2 changes: 1 addition & 1 deletion web/frps/src/components/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<el-form-item label="Client Counts">
<span>{{ client_counts }}</span>
</el-form-item>
<el-form-item label="Current Conns">
<el-form-item label="Current Connections">
<span>{{ cur_conns }}</span>
</el-form-item>
<el-form-item label="Proxy Counts">
Expand Down
6 changes: 6 additions & 0 deletions web/frps/src/components/ProxiesHttp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<el-form-item label="Compression">
<span>{{ props.row.compression }}</span>
</el-form-item>
<el-form-item label="Last Start">
<span>{{ props.row.last_start_time }}</span>
</el-form-item>
<el-form-item label="Last Close">
<span>{{ props.row.last_close_time }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
Expand Down
6 changes: 6 additions & 0 deletions web/frps/src/components/ProxiesHttps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<el-form-item label="Compression">
<span>{{ props.row.compression }}</span>
</el-form-item>
<el-form-item label="Last Start">
<span>{{ props.row.last_start_time }}</span>
</el-form-item>
<el-form-item label="Last Close">
<span>{{ props.row.last_close_time }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
Expand Down
6 changes: 6 additions & 0 deletions web/frps/src/components/ProxiesTcp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<el-form-item label="Compression">
<span>{{ props.row.compression }}</span>
</el-form-item>
<el-form-item label="Last Start">
<span>{{ props.row.last_start_time }}</span>
</el-form-item>
<el-form-item label="Last Close">
<span>{{ props.row.last_close_time }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
Expand Down
6 changes: 6 additions & 0 deletions web/frps/src/components/ProxiesUdp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<el-form-item label="Compression">
<span>{{ props.row.compression }}</span>
</el-form-item>
<el-form-item label="Last Start">
<span>{{ props.row.last_start_time }}</span>
</el-form-item>
<el-form-item label="Last Close">
<span>{{ props.row.last_close_time }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
Expand Down
2 changes: 2 additions & 0 deletions web/frps/src/utils/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class BaseProxy {
this.conns = proxyStats.cur_conns
this.traffic_in = proxyStats.today_traffic_in
this.traffic_out = proxyStats.today_traffic_out
this.last_start_time = proxyStats.last_start_time
this.last_close_time = proxyStats.last_close_time
this.status = proxyStats.status
}
}
Expand Down

0 comments on commit e29a133

Please sign in to comment.