mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
更换LOGO、优化获取IP策略
This commit is contained in:
parent
3aba6a4131
commit
8acf99253c
13
README.md
13
README.md
@ -1,16 +1,15 @@
|
||||
# 哪吒监控
|
||||
<div align="center" style="background-color: white">
|
||||
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
|
||||
</div>
|
||||
|
||||
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=管理面板%20v0.4.14&logo=github&style=for-the-badge) ![Agent release](https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge) ![shell](https://img.shields.io/badge/安装脚本-v0.4.9-brightgreen?style=for-the-badge&logo=linux)
|
||||
|
||||
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=管理面板%20v0.4.13&logo=github&style=for-the-badge) ![Agent release](https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge) ![shell](https://img.shields.io/badge/安装脚本-v0.4.9-brightgreen?style=for-the-badge&logo=linux)
|
||||
|
||||
:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。
|
||||
|
||||
<div align="center">
|
||||
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png">
|
||||
</div>
|
||||
|
||||
\>> QQ 交流群:955957790
|
||||
|
||||
\>> [我们的用户](https://www.google.com/search?q="powered+by+哪吒"+"监控%7C面板"&filter=0) (Google)
|
||||
\>> [我们的用户](https://www.google.com/search?q="powered+by+哪吒监控%7C哪吒面板"&filter=0) (Google)
|
||||
|
||||
| 默认主题 | DayNight [@JackieSung](https://github.com/JackieSung4ev) | hotaru |
|
||||
| ------------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------- |
|
||||
|
@ -105,6 +105,8 @@ func run() {
|
||||
|
||||
// 上报服务器信息
|
||||
go reportState()
|
||||
// 更新IP信息
|
||||
go monitor.UpdateIP()
|
||||
|
||||
if version != "" {
|
||||
go func() {
|
||||
|
@ -25,8 +25,41 @@ type ipDotSbGeoIP struct {
|
||||
}
|
||||
|
||||
var netInSpeed, netOutSpeed, netInTransfer, netOutTransfer, lastUpdate uint64
|
||||
var cachedIP, country string
|
||||
var latestFetchIP time.Time
|
||||
var cachedIP, cachedCountry string
|
||||
|
||||
func UpdateIP() {
|
||||
var ip ipDotSbGeoIP
|
||||
for {
|
||||
var tempIP string
|
||||
var tempCountry string
|
||||
resp, err := http.Get("https://api-ipv4.ip.sb/geoip")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
json.Unmarshal(body, &ip)
|
||||
tempIP = ip.IP
|
||||
tempCountry = ip.CountryCode
|
||||
} else {
|
||||
cachedIP = ""
|
||||
}
|
||||
time.Sleep(time.Second * 10)
|
||||
resp, err = http.Get("https://api-ipv6.ip.sb/geoip")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
json.Unmarshal(body, &ip)
|
||||
if tempIP == "" {
|
||||
tempIP = ip.IP
|
||||
} else {
|
||||
tempIP = fmt.Sprintf("ip(v4: %s, v6: %s)", tempIP, ip.IP)
|
||||
}
|
||||
tempCountry = ip.CountryCode
|
||||
}
|
||||
cachedIP = tempIP
|
||||
cachedCountry = tempCountry
|
||||
time.Sleep(time.Minute * 10)
|
||||
}
|
||||
}
|
||||
|
||||
func GetHost() *model.Host {
|
||||
hi, _ := host.Info()
|
||||
@ -49,33 +82,6 @@ func GetHost() *model.Host {
|
||||
ms, _ := mem.SwapMemory()
|
||||
u, _ := disk.Usage("/")
|
||||
|
||||
if latestFetchIP.Before(time.Now().Add(time.Minute * -15)) {
|
||||
var ip ipDotSbGeoIP
|
||||
latestFetchIP = time.Now()
|
||||
resp, err := http.Get("https://api-ipv4.ip.sb/geoip")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
json.Unmarshal(body, &ip)
|
||||
cachedIP = ip.IP
|
||||
country = ip.CountryCode
|
||||
} else {
|
||||
cachedIP = ""
|
||||
}
|
||||
resp, err = http.Get("https://api-ipv6.ip.sb/geoip")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
json.Unmarshal(body, &ip)
|
||||
if cachedIP == "" {
|
||||
cachedIP = ip.IP
|
||||
} else {
|
||||
cachedIP = fmt.Sprintf("ip(v4: %s, v6: %s)", cachedIP, ip.IP)
|
||||
}
|
||||
country = ip.CountryCode
|
||||
}
|
||||
}
|
||||
|
||||
return &model.Host{
|
||||
Platform: hi.OS,
|
||||
PlatformVersion: hi.PlatformVersion,
|
||||
@ -87,7 +93,7 @@ func GetHost() *model.Host {
|
||||
Virtualization: hi.VirtualizationSystem,
|
||||
BootTime: hi.BootTime,
|
||||
IP: cachedIP,
|
||||
CountryCode: strings.ToLower(country),
|
||||
CountryCode: strings.ToLower(cachedCountry),
|
||||
Version: dao.Version,
|
||||
}
|
||||
}
|
||||
|
2
resource/template/common/header.html
vendored
2
resource/template/common/header.html
vendored
@ -10,7 +10,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/semantic-ui-alerts.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/main.css?v202102051040">
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png" />
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png?v20210320" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
2
resource/template/common/menu.html
vendored
2
resource/template/common/menu.html
vendored
@ -2,7 +2,7 @@
|
||||
<div class="ui large top fixed menu nb-menu">
|
||||
<div class="ui container">
|
||||
<div class="item">
|
||||
<img src="/static/logo.png">
|
||||
<img src="/static/logo.png?v20210320">
|
||||
</div>
|
||||
{{if .IsAdminPage}}
|
||||
<a class='item{{if eq .MatchedPath "/server"}} active{{end}}' href="/server"><i class="server icon"></i>资产</a>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="ui center aligned grid">
|
||||
<div class="column">
|
||||
<h2 class="ui teal image header">
|
||||
<img src="/static/logo.png" class="image">
|
||||
<img src="/static/logo.png?v20210320" class="image">
|
||||
<div class="content">
|
||||
访问受限
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="ui center aligned grid">
|
||||
<div class="column">
|
||||
<h2 class="ui teal image header">
|
||||
<img src="static/logo.png" class="image">
|
||||
<img src="static/logo.png?v20210320" class="image">
|
||||
<div class="content">
|
||||
使用 GitHub 账号登录
|
||||
</div>
|
||||
|
2
resource/template/theme-daynight/home.html
vendored
2
resource/template/theme-daynight/home.html
vendored
@ -7,7 +7,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png" />
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png?v20210320" />
|
||||
|
||||
<link rel="stylesheet" href="/static/theme-daynight/css/main.css?v202103202286">
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet">
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png" />
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png?v20210320" />
|
||||
<link rel="stylesheet" href="/static/theme-daynight/css/service.css?v202103202286" />
|
||||
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet" />
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png" />
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png?v20210320" />
|
||||
<link rel="stylesheet" href="/static/theme-daynight/css/passwd.css?v202103202286" />
|
||||
|
||||
{{if ts .CustomCode}}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="ui center aligned grid">
|
||||
<div class="column">
|
||||
<h2 class="ui teal image header">
|
||||
<img src="static/logo.png" class="image">
|
||||
<img src="static/logo.png?v20210320" class="image">
|
||||
<div class="content">
|
||||
验证查看密码
|
||||
</div>
|
||||
|
2
resource/template/theme-hotaru/home.html
vendored
2
resource/template/theme-hotaru/home.html
vendored
@ -7,7 +7,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png" />
|
||||
<link rel="shortcut icon" type="image/png" href="/static/logo.png?v20210320" />
|
||||
|
||||
<!-- Fix chrome language detection -->
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="ui center aligned grid">
|
||||
<div class="column">
|
||||
<h2 class="ui teal image header">
|
||||
<img src="static/logo.png" class="image">
|
||||
<img src="static/logo.png?v20210320" class="image">
|
||||
<div class="content">
|
||||
验证查看密码
|
||||
</div>
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
pb "github.com/naiba/nezha/proto"
|
||||
)
|
||||
|
||||
var Version = "v0.4.13" // !!记得修改 README 重的 badge 版本!!
|
||||
var Version = "v0.4.14" // !!记得修改 README 重的 badge 版本!!
|
||||
|
||||
const (
|
||||
SnapshotDelay = 3
|
||||
|
Loading…
Reference in New Issue
Block a user