run e2e
This commit is contained in:
parent
9990a31bfc
commit
2e7c1308c9
2 changed files with 31 additions and 31 deletions
|
@ -192,6 +192,7 @@ var (
|
||||||
type exeMatcher struct {
|
type exeMatcher struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
|
enableVtsCollector bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (em exeMatcher) MatchAndName(nacl common.NameAndCmdline) (bool, string) {
|
func (em exeMatcher) MatchAndName(nacl common.NameAndCmdline) (bool, string) {
|
||||||
|
@ -202,9 +203,9 @@ func (em exeMatcher) MatchAndName(nacl common.NameAndCmdline) (bool, string) {
|
||||||
return em.name == cmd, ""
|
return em.name == cmd, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NGINXController) setupMonitor(args[] string, vtsCollector *bool) {
|
func (n *NGINXController) setupMonitor(args[] string, vtsCollector bool) {
|
||||||
// TODO fix true
|
glog.Warning("vtsCollector now is ", vtsCollector)
|
||||||
pc, err := newProcessCollector(true, exeMatcher{"nginx", args}, vtsCollector)
|
pc, err := newProcessCollector(true, exeMatcher{"nginx", args, vtsCollector})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error registering nginx collector: %v", err)
|
glog.Warningf("unexpected error registering nginx collector: %v", err)
|
||||||
|
@ -213,8 +214,9 @@ func (n *NGINXController) setupMonitor(args[] string, vtsCollector *bool) {
|
||||||
err = prometheus.Register(pc)
|
err = prometheus.Register(pc)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err, ok := err.(prometheus.AlreadyRegisteredError); ok {
|
if reg, ok := err.(prometheus.AlreadyRegisteredError); ok {
|
||||||
glog.Warningf("unexpected error registering nginx collector: %v", err)
|
*reg.ExistingCollector.(prometheus.Collector).(*namedProcessCollector) = *pc
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
glog.Warningf("unexpected error registering nginx collector: %v", err)
|
glog.Warningf("unexpected error registering nginx collector: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -231,16 +233,15 @@ type (
|
||||||
|
|
||||||
namedProcessCollector struct {
|
namedProcessCollector struct {
|
||||||
scrapeChan chan scrapeRequest
|
scrapeChan chan scrapeRequest
|
||||||
*proc.Grouper
|
grouper *proc.Grouper
|
||||||
fs *proc.FS
|
fs *proc.FS
|
||||||
vtsCollector *bool
|
//enableVtsCollector *bool
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func newProcessCollector(
|
func newProcessCollector(
|
||||||
children bool,
|
children bool,
|
||||||
n common.MatchNamer,
|
n common.MatchNamer) (*namedProcessCollector, error) {
|
||||||
vtsCollector *bool) (*namedProcessCollector, error) {
|
|
||||||
|
|
||||||
//fs, err := proc.NewFS("/proc")
|
//fs, err := proc.NewFS("/proc")
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
|
@ -248,9 +249,9 @@ func newProcessCollector(
|
||||||
//}
|
//}
|
||||||
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,
|
//enableVtsCollector: vtsCollector,
|
||||||
}
|
}
|
||||||
|
|
||||||
// p.Update(p.fs.AllProcs())
|
// p.Update(p.fs.AllProcs())
|
||||||
|
@ -273,14 +274,13 @@ func (p *namedProcessCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||||
ch <- memResidentbytesDesc
|
ch <- memResidentbytesDesc
|
||||||
ch <- memVirtualbytesDesc
|
ch <- memVirtualbytesDesc
|
||||||
ch <- startTimeDesc
|
ch <- startTimeDesc
|
||||||
|
x := p.grouper.(exeMatcher)
|
||||||
if *p.vtsCollector {
|
if true { //x.(execMatcher) == nil { //.(exeMatcher).enableVtsCollector {
|
||||||
glog.Info("registering vts describe")
|
glog.Info("registering vts describe")
|
||||||
|
|
||||||
ch <- vtsBytesDesc
|
ch <- vtsBytesDesc
|
||||||
ch <- vtsCacheDesc
|
ch <- vtsCacheDesc
|
||||||
ch <- vtsConnectionsDesc
|
ch <- vtsConnectionsDesc
|
||||||
ch <- readBytesDesc
|
|
||||||
ch <- vtsRequestDesc
|
ch <- vtsRequestDesc
|
||||||
ch <- vtsResponseDesc
|
ch <- vtsResponseDesc
|
||||||
ch <- vtsUpstreamBackupDesc
|
ch <- vtsUpstreamBackupDesc
|
||||||
|
@ -347,11 +347,12 @@ func (p *namedProcessCollector) scrapeNginxStatus(ch chan<- prometheus.Metric) {
|
||||||
|
|
||||||
func (p *namedProcessCollector) scrapeVts(ch chan<- prometheus.Metric) {
|
func (p *namedProcessCollector) scrapeVts(ch chan<- prometheus.Metric) {
|
||||||
|
|
||||||
if ! *p.vtsCollector {
|
if ! true {
|
||||||
glog.Warningf("vts metrics not enabled")
|
glog.V(3).Info("vts metrics not enabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
glog.Info("starting scrap on vts")
|
|
||||||
|
glog.V(3).Info("starting scrap on vts")
|
||||||
nginxMetrics, err := getNginxVtsMetrics()
|
nginxMetrics, err := getNginxVtsMetrics()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error obtaining nginx status info: %v", err)
|
glog.Warningf("unexpected error obtaining nginx status info: %v", err)
|
||||||
|
@ -435,7 +436,7 @@ func (p *namedProcessCollector) scrapeVts(ch chan<- prometheus.Metric) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *namedProcessCollector) scrapeProcs(ch chan<- prometheus.Metric) {
|
func (p *namedProcessCollector) scrapeProcs(ch chan<- prometheus.Metric) {
|
||||||
|
return
|
||||||
//_, err := p.Update(p.fs.AllProcs())
|
//_, err := p.Update(p.fs.AllProcs())
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// glog.Warningf("unexpected error obtaining nginx process info: %v", err)
|
// glog.Warningf("unexpected error obtaining nginx process info: %v", err)
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -159,8 +158,8 @@ func (n *NGINXController) start(cmd *exec.Cmd, done chan error) {
|
||||||
done <- err
|
done <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
falseVar := false
|
cfg := ngx_template.ReadConfig(n.configmap.Data)
|
||||||
n.setupMonitor(cmd.Args, &falseVar)
|
n.setupMonitor(cmd.Args, cfg.EnableVtsStatus)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
done <- cmd.Wait()
|
done <- cmd.Wait()
|
||||||
|
@ -170,19 +169,15 @@ 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
|
||||||
|
@ -212,6 +207,10 @@ func (n NGINXController) isReloadRequired(data []byte) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(src, data) {
|
if !bytes.Equal(src, data) {
|
||||||
|
|
||||||
|
cfg := ngx_template.ReadConfig(n.configmap.Data)
|
||||||
|
n.setupMonitor([]string{""}, &cfg.EnableVtsStatus)
|
||||||
|
|
||||||
tmpfile, err := ioutil.TempFile("", "nginx-cfg-diff")
|
tmpfile, err := ioutil.TempFile("", "nginx-cfg-diff")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("error creating temporal file: %s", err)
|
glog.Errorf("error creating temporal file: %s", err)
|
||||||
|
|
Loading…
Reference in a new issue