-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.go
42 lines (29 loc) · 1 KB
/
resources.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
39
40
41
42
package main
import "os/exec"
const (
cmdSerialNumber string = "ioreg -l | grep IOPlatformSerialNumber | awk -F '=' '{print $2}' | tr -d ' \n'"
cmdCPU string = "/usr/sbin/sysctl -n machdep.cpu.brand_string"
cmdDisk string = "system_profiler SPStorageDataType -detailLevel mini | grep Capacity | awk -F '(' '{print $1}' | awk -F ':' '{print $2}' | tr -d ' '"
cmdMemory = "sysctl hw.memsize | awk -F ':' '{print $2}' | tr -d ' \n'"
cmdGetAccount = "id -un"
)
func getAccount () string {
data, _ := exec.Command ( "bash", "-c", cmdGetAccount ).Output()
return string(data)
}
func getMemory () string {
data, _ := exec.Command("bash", "-c", cmdMemory).Output()
return string(data)
}
func getCPU () string {
data, _ := exec.Command("bash", "-c", cmdCPU).Output()
return string(data)
}
func getSerialNumber () string {
sn, _ := exec.Command("bash", "-c", cmdSerialNumber).Output()
return string(sn)
}
func getDisk () string {
data, _ := exec.Command("bash", "-c", cmdDisk).Output()
return string(data)
}