-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdisk_usage.go
38 lines (32 loc) · 1.08 KB
/
disk_usage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package disk
import (
"fmt"
"github.com/shirou/gopsutil/disk"
"github.com/vela-ssoc/vela-kit/lua"
)
type UsageStat disk.UsageStat
func (us UsageStat) String() string { return fmt.Sprintf("%p", &us) }
func (us UsageStat) Type() lua.LValueType { return lua.LTObject }
func (us UsageStat) AssertFloat64() (float64, bool) { return 0, false }
func (us UsageStat) AssertString() (string, bool) { return "", false }
func (us UsageStat) AssertFunction() (*lua.LFunction, bool) { return nil, false }
func (us UsageStat) Peek() lua.LValue { return us }
func (us UsageStat) Index(L *lua.LState, key string) lua.LValue {
switch key {
case "total":
return lua.LNumber(us.Total)
case "free":
return lua.LNumber(us.Free)
case "used":
return lua.LNumber(us.Used)
case "used_pct":
return lua.LNumber(us.UsedPercent)
case "inode_total":
return lua.LNumber(us.InodesTotal)
case "inode_used":
return lua.LNumber(us.InodesUsed)
case "inode_used_pct":
return lua.LNumber(us.InodesUsedPercent)
}
return lua.LNil
}