| // |
| 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 |
| 15 | package mem |
| 16 |
| 17 | import ( |
| 18 | "time" |
| 19 |
| 20 | "github.com/fatedier/frp/pkg/util/metric" |
| 21 | ) |
| 22 |
| 23 | const ( |
| 24 | ReserveDays = 7 |
| 25 | ) |
| 26 |
| 27 | type ServerStats struct { |
| 28 | TotalTrafficIn int64 |
| 29 | TotalTrafficOut int64 |
| 30 | CurConns int64 |
| 31 | ClientCounts int64 |
| 32 | ProxyTypeCounts map[string]int64 |
| 33 | } |
| 34 |
| 35 | type ProxyStats struct { |
| 36 | Name string |
| 37 | Type string |
| 38 | User string |
| 39 | ClientID string |
| 40 | TodayTrafficIn int64 |
| 41 | TodayTrafficOut int64 |
| 42 | LastStartTime string |
| 43 | LastCloseTime string |
| 44 | LastStartAt int64 |
| 45 | LastCloseAt int64 |
| 46 | CurConns int64 |
| 47 | } |
| 48 |
| 49 | type ProxyTrafficInfo struct { |
| 50 | Name string |
| 51 | TrafficIn []int64 |
| 52 | TrafficOut []int64 |
| 53 | } |
| 54 |
| 55 | type ProxyStatistics struct { |
| 56 | Name string |
| 57 | ProxyType string |
| 58 | User string |
| 59 | ClientID string |
| 60 | TrafficIn metric.DateCounter |
| 61 | TrafficOut metric.DateCounter |
| 62 | CurConns metric.Counter |
| 63 | LastStartTime time.Time |
| 64 | LastCloseTime time.Time |
| 65 | } |
| 66 |
| 67 | type ServerStatistics struct { |
| 68 | TotalTrafficIn metric.DateCounter |
| 69 | TotalTrafficOut metric.DateCounter |
| 70 | CurConns metric.Counter |
| 71 |
| 72 | // counter for clients |
| 73 | ClientCounts metric.Counter |
| 74 |
| 75 | // counter for proxy types |
| 76 | ProxyTypeCounts map[string]metric.Counter |
| 77 |
| 78 | // statistics for different proxies |
| 79 | // key is proxy name |
| 80 | ProxyStatistics map[string]*ProxyStatistics |
| 81 | } |
| 82 |
| 83 | type Collector interface { |
| 84 | GetServer() *ServerStats |
| 85 | GetProxiesByType(proxyType string) []*ProxyStats |
| 86 | GetProxiesByTypeAndName(proxyType string, proxyName string) *ProxyStats |
| 87 | GetProxyByName(proxyName string) *ProxyStats |
| 88 | GetProxyTraffic(name string) *ProxyTrafficInfo |
| 89 | ClearOfflineProxies() (int, int) |
| 90 | PruneOfflineProxies() (int, int) |
| 91 | } |