Skip to content

Commit fcb7127

Browse files
lambda-zhangYour Name
authored andcommitted
start
0 parents  commit fcb7127

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+15826
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
systemmonitor.db
2+
main.arm64

1_run.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
pushd webpage
4+
npm install
5+
npm run build
6+
popd
7+
8+
go run main.go

2_build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-linux-gnueabi-gcc go build -o main.arm -v -ldflags "-w -s -linkmode external -extldflags -static" main.go
3+
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -ldflags "-w" -o main.arm64 main.go
4+
CGO_ENABLED=1 go build -ldflags "-w" -o main main.go
5+
pushd webpage
6+
npm run build
7+
popd
8+
9+
rm -rf release.arm64.tgz
10+
tar -czvmf release.arm64.tgz main.arm64 main.arm main webpage/dist/

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
目前只支持Linux
2+
3+
## 安装依赖
4+
```
5+
$ go get -u -v github.com/gin-gonic/gin
6+
$ go get -u -v github.com/jinzhu/gorm
7+
$ go get -u -v github.com/jinzhu/gorm/dialects/sqlite
8+
$ go get -u -v github.com/gin-contrib/cors
9+
$ go get -u -v github.com/gin-contrib/gzip
10+
$ go get -u -v github.com/lambda-zhang/systemmonitor
11+
$ go get -u -v github.com/gorilla/websocket
12+
13+
$ npm install -g vue-cli
14+
$ cd webpage/
15+
$ npm install
16+
```
17+
18+
## 运行源码
19+
```
20+
$ cd webpage/
21+
$ npm run build
22+
$ cd ..
23+
$ go run main.go
24+
```
25+
26+
27+
## 编译二进制
28+
```
29+
for armd64:
30+
$ CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o main.amd64 main.go
31+
32+
for arm64(debug):
33+
$ CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o main.arm64 -v -ldflags "-linkmode external -extldflags -static" main.go
34+
35+
for arm64(release):
36+
$ CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o main.arm64 -v -ldflags "-w -s -linkmode external -extldflags -static" main.go
37+
38+
for arm(debug):
39+
$ CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-linux-gnueabi-gcc go build -o main.arm -v -ldflags "-linkmode external -extldflags -static" main.go
40+
41+
for arm(release):
42+
$ CGO_ENABLED=1 GOOS=linux GOARCH=arm CC=arm-linux-gnueabi-gcc go build -o main.arm -v -ldflags "-w -s -linkmode external -extldflags -static" main.go
43+
```
44+
45+
46+
## 运行起来之后在浏览器打开http://127.0.0.1:9000
47+
![截图1](https://github.com/lambda-zhang/systemmonitor-web/blob/master/webpage/static/images/screenshot1.png)
48+
![截图2](https://github.com/lambda-zhang/systemmonitor-web/blob/master/webpage/static/images/screenshot2.png)
49+
50+
51+
## 调试时候检查数据
52+
```
53+
$ sqlite3 systemmonitor.db
54+
sqlite> .database
55+
seq name file
56+
--- --------------- ----------------------------------------------------------
57+
0 main /data/lambda/systemmonitor-web/systemmonitor.db
58+
59+
sqlite> .tables
60+
os products
61+
62+
sqlite> .mode column
63+
sqlite> .header on
64+
sqlite> select * from os;
65+
id up_time start_time use_permillage arch os kernel_version kernel_hostname num_cpu
66+
---------- ---------- ---------- -------------- ---------- ---------- -------------- --------------- ----------
67+
1 1 1 1 1 1 1 1 1
68+
69+
sqlite> .quit
70+
```

controllers/pong.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package controllers
2+
3+
import (
4+
"github.com/gin-gonic/gin"
5+
)
6+
7+
func Pong(c *gin.Context) {
8+
c.JSON(200, gin.H{"status": 200, "ping": "pong"})
9+
}

0 commit comments

Comments
 (0)