-
Notifications
You must be signed in to change notification settings - Fork 22
/
main.go
37 lines (31 loc) · 878 Bytes
/
main.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
package main
// pull in the package andrew mentioned that deals with memory
// read command line for destination cnf
// call object.generate with mem library and destination string
import (
sigar "github.com/cloudfoundry/gosigar"
"fmt"
"flag"
"os"
)
var (
targetPercentage float64
outputFile string
)
func main() {
flag.Float64Var(&targetPercentage, "P", 50.0,
"Set this to an integer which represents the percentage of system RAM to reserve for InnoDB's buffer pool")
flag.StringVar(&outputFile, "f", "",
"Target file for rendering MySQL option file")
flag.Parse()
mem := sigar.Mem{}
mem.Get()
totalMem := mem.Total
fmt.Printf("Total memory in bytes: %d", mem.Total)
file, err := os.OpenFile(outputFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
panic(err)
}
defer file.Close()
Generate(totalMem, targetPercentage, file)
}