upgrade vts to the latest version

This commit is contained in:
Giancarlo Rubio 2017-02-27 10:24:32 +01:00
parent f79257db36
commit 8f2b701361
5 changed files with 2758 additions and 25 deletions

View file

@ -42,17 +42,23 @@ func (em exeMatcher) MatchAndName(nacl common.NameAndCmdline) (bool, string) {
} }
func (n *NGINXController) setupMonitor(args []string) { func (n *NGINXController) setupMonitor(args []string) {
var enableVts = true
// TODO fix true // TODO fix true
pc, err := newProcessCollector(true, exeMatcher{"nginx", args}, enableVts) pc, err := newProcessCollector(true, exeMatcher{"nginx", args}, false)
if err != nil { if err != nil {
glog.Fatalf("unexpected error registering nginx collector: %v", err) glog.Warningf("unexpected error registering nginx collector: %v", err)
} }
n.namedProcessCollector = pc
err = prometheus.Register(pc) err = prometheus.Register(pc)
if err != nil { if err != nil {
glog.Warningf("unexpected error registering nginx collector: %v", err) glog.Warningf("unexpected error registering nginx collector: %v", err)
} }
}
func (n *NGINXController) reloadMonitor(enableVts *bool) {
n.namedProcessCollector.vtsCollector = enableVts
} }
var ( var (
@ -225,7 +231,7 @@ type (
scrapeChan chan scrapeRequest scrapeChan chan scrapeRequest
*proc.Grouper *proc.Grouper
fs *proc.FS fs *proc.FS
vtsCollector bool vtsCollector *bool
} }
) )
@ -234,21 +240,21 @@ func newProcessCollector(
n common.MatchNamer, n common.MatchNamer,
vtsCollector bool) (*namedProcessCollector, error) { vtsCollector bool) (*namedProcessCollector, error) {
fs, err := proc.NewFS("/proc") //fs, err := proc.NewFS("/proc")
if err != nil { //if err != nil {
return nil, err // return nil, err
} //}
p := &namedProcessCollector{ p := &namedProcessCollector{
scrapeChan: make(chan scrapeRequest), scrapeChan: make(chan scrapeRequest),
Grouper: proc.NewGrouper(children, n), Grouper: proc.NewGrouper(children, n),
fs: fs, //fs: fs,
vtsCollector: vtsCollector, vtsCollector: &vtsCollector,
} }
_, err = p.Update(p.fs.AllProcs()) //_, err = p.Update(p.fs.AllProcs())
if err != nil { //if err != nil {
return nil, err // return nil, err
} //}
go p.start() go p.start()
@ -266,7 +272,7 @@ func (p *namedProcessCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- memVirtualbytesDesc ch <- memVirtualbytesDesc
ch <- startTimeDesc ch <- startTimeDesc
if p.vtsCollector { if p.vtsCollector == true {
ch <- vtsBytesDesc ch <- vtsBytesDesc
ch <- vtsCacheDesc ch <- vtsCacheDesc
@ -306,7 +312,7 @@ func (p *namedProcessCollector) start() {
ch := req.results ch := req.results
p.scrapeNginxStatus(ch) p.scrapeNginxStatus(ch)
if p.vtsCollector { if &p.vtsCollector {
p.scrapeVts(ch) p.scrapeVts(ch)
} }

View file

@ -108,6 +108,8 @@ type NGINXController struct {
storeLister ingress.StoreLister storeLister ingress.StoreLister
binary string binary string
namedProcessCollector *namedProcessCollector
} }
// Start start a new NGINX master process running in foreground. // Start start a new NGINX master process running in foreground.
@ -168,16 +170,21 @@ func (n *NGINXController) start(cmd *exec.Cmd, done chan error) {
// Reload checks if the running configuration file is different // Reload checks if the running configuration file is different
// to the specified and reload nginx if required // to the specified and reload nginx if required
func (n NGINXController) Reload(data []byte) ([]byte, bool, error) { func (n NGINXController) Reload(data []byte) ([]byte, bool, error) {
if !n.isReloadRequired(data) { //if !n.isReloadRequired(data) {
return []byte("Reload not required"), false, nil // return []byte("Reload not required"), false, nil
} //}
cfg := ngx_template.ReadConfig(n.configmap.Data)
err := ioutil.WriteFile(cfgPath, data, 0644) err := ioutil.WriteFile(cfgPath, data, 0644)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
} }
n.reloadMonitor(&cfg.EnableVtsStatus)
o, e := exec.Command(n.binary, "-s", "reload").CombinedOutput() o, e := exec.Command(n.binary, "-s", "reload").CombinedOutput()
return o, true, e return o, true, e
} }

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@ set -e
export NGINX_VERSION=1.11.10 export NGINX_VERSION=1.11.10
export NDK_VERSION=0.3.0 export NDK_VERSION=0.3.0
export VTS_VERSION=0.1.11 export VTS_VERSION=0.1.12
export SETMISC_VERSION=0.31 export SETMISC_VERSION=0.31
export LUA_VERSION=0.10.7 export LUA_VERSION=0.10.7
export STICKY_SESSIONS_VERSION=08a395c66e42 export STICKY_SESSIONS_VERSION=08a395c66e42