types.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2017 fatedier, fatedier@gmail.com
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package mem
  15. import (
  16. "time"
  17. "github.com/fatedier/frp/pkg/util/metric"
  18. )
  19. const (
  20. ReserveDays = 7
  21. )
  22. type ServerStats struct {
  23. TotalTrafficIn int64
  24. TotalTrafficOut int64
  25. CurConns int64
  26. ClientCounts int64
  27. ProxyTypeCounts map[string]int64
  28. }
  29. type ProxyStats struct {
  30. Name string
  31. Type string
  32. TodayTrafficIn int64
  33. TodayTrafficOut int64
  34. LastStartTime string
  35. LastCloseTime string
  36. CurConns int64
  37. }
  38. type ProxyTrafficInfo struct {
  39. Name string
  40. TrafficIn []int64
  41. TrafficOut []int64
  42. }
  43. type ProxyStatistics struct {
  44. Name string
  45. ProxyType string
  46. TrafficIn metric.DateCounter
  47. TrafficOut metric.DateCounter
  48. CurConns metric.Counter
  49. LastStartTime time.Time
  50. LastCloseTime time.Time
  51. }
  52. type ServerStatistics struct {
  53. TotalTrafficIn metric.DateCounter
  54. TotalTrafficOut metric.DateCounter
  55. CurConns metric.Counter
  56. // counter for clients
  57. ClientCounts metric.Counter
  58. // counter for proxy types
  59. ProxyTypeCounts map[string]metric.Counter
  60. // statistics for different proxies
  61. // key is proxy name
  62. ProxyStatistics map[string]*ProxyStatistics
  63. }
  64. type Collector interface {
  65. GetServer() *ServerStats
  66. GetProxiesByType(proxyType string) []*ProxyStats
  67. GetProxiesByTypeAndName(proxyType string, proxyName string) *ProxyStats
  68. GetProxyTraffic(name string) *ProxyTrafficInfo
  69. ClearOfflineProxies() (int, int)
  70. }