✏ update license

pull/837/head
Fenny 2020-09-28 00:46:18 +02:00
parent 6cac2faa9a
commit 052966e5dc
17 changed files with 48 additions and 86 deletions

6
.github/README.md vendored
View File

@ -580,3 +580,9 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -645,3 +645,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -581,3 +581,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -581,3 +581,6 @@ Copyright (c) 2019-presente [Fenny](https://github.com/fenny) y [contribuyentes]
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -581,3 +581,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -733,4 +733,7 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)
</div>

View File

@ -583,3 +583,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -584,3 +584,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -586,3 +586,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -585,3 +585,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -581,3 +581,6 @@ O logo oficial foi criado por [Vic Shóstak](https://github.com/koddr) e distrib
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -586,3 +586,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -577,3 +577,6 @@ Telif (c) 2019-günümüz [Fenny](https://github.com/fenny) ve [Contributors](ht
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -583,3 +583,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -582,3 +582,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [colorable](https://github.com/mattn/go-colorable/blob/master/LICENSE)
- [fasttemplate](https://github.com/valyala/fasttemplate/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
- [go-ole](https://github.com/go-ole/go-ole)
- [wmi](https://github.com/StackExchange/wmi)

View File

@ -1,13 +0,0 @@
package monitor
var index = []byte(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Monitor</title>
</head>
<body>
<h1>Monitor</h1>
</body>
</html>`)

View File

@ -1,73 +0,0 @@
package monitor
import (
"os"
"sync"
"time"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/internal/gopsutil/process"
)
type stats struct {
CPU float64 `json:"cpu"`
RAM uint64 `json:"ram"`
Load float64 `json:"load"`
Time int64 `json:"time"`
Reqs uint32 `json:"reqs"`
}
var (
monitorCPU float64
monitorRAM uint64
)
var (
mutex sync.RWMutex
once sync.Once
data = &stats{}
)
// New creates a new middleware handler
func New() fiber.Handler {
// Start routine to update statistics
once.Do(func() {
go monitor()
})
// Return new handler
return func(c *fiber.Ctx) error {
// Call chain
if err := c.Next(); err != nil {
return err
}
if c.Get(fiber.HeaderAccept) == fiber.MIMEApplicationJSON {
mutex.Lock()
data = &stats{
CPU: monitorCPU,
RAM: monitorRAM,
Load: 2.32,
Time: (time.Now().UnixNano() - c.Context().Time().UnixNano()) / 100000,
Reqs: c.App().Server().GetCurrentConcurrency(),
}
mutex.Unlock()
return c.JSON(data)
}
c.Response().Header.SetContentType(fiber.MIMETextHTMLCharsetUTF8)
return c.Send(index)
}
}
func monitor() {
p, _ := process.NewProcess(int32(os.Getpid()))
for {
cpu, _ := p.CPUPercent()
monitorCPU = cpu / 10
mem, _ := p.MemoryInfo()
monitorRAM = mem.RSS
time.Sleep(1 * time.Second)
}
}