Skip to content

Commit

Permalink
添加功能:根据目录获取磁盘使用情况
Browse files Browse the repository at this point in the history
  • Loading branch information
iceopen committed Apr 11, 2017
1 parent 2052044 commit 3277a1f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
mohoo-sys-getinfo.iml
40 changes: 39 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
### 地址:
> ip:port/swap/info
### 请求方法:
GET

### 返回参数:
```javascript
{
Expand All @@ -19,6 +22,9 @@
### 地址:
> ip:port/vmem/info
### 请求方法:
GET

### 返回参数:
```javascript
{
Expand All @@ -45,6 +51,9 @@
### 地址:
> ip:port/cpu/time
### 请求方法:
GET

### 返回参数:
```javascript
[
Expand Down Expand Up @@ -97,6 +106,9 @@
### 地址:
> ip:port/cpu/info
### 请求方法:
GET

### 返回参数:
```javascript
[
Expand Down Expand Up @@ -198,6 +210,9 @@
### 地址:
> ip:port/disk/usage
### 请求方法:
GET

### 返回参数:
```javascript
{
Expand All @@ -212,4 +227,27 @@
"inodesFree": 4292650478,
"inodesUsedPercent": 0.053942227018302744
}
```
```

## 根据传参目录磁盘使用情况
### 地址:
> ip:port/disk/path
### 请求方法:
POST

### 返回参数:
```javascript
{
"path": "/data/file",
"fstype": "nfs",
"total": 536870912000,
"free": 420079468544,
"used": 116791443456,
"usedPercent": 21.7541015625,
"inodesTotal": 827138037,
"inodesUsed": 969507,
"inodesFree": 826168530,
"inodesUsedPercent": 0.11721223745390395
}
```
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/martini-contrib/render"
"net/http"
)

func init() {
Expand Down Expand Up @@ -45,6 +46,12 @@ func main() {
diskInfo, _ := disk.Usage("/")
r.JSON(200, diskInfo)
})
//制定目录使用 信息详细
m.Post("/disk/path", func(r render.Render, req *http.Request){
path := req.FormValue("path")
diskInfo, _ := disk.Usage(path)
r.JSON(200, diskInfo)
})
//m.Run()
m.RunOnAddr(":8848")
}

0 comments on commit 3277a1f

Please sign in to comment.