Пример #1
0
func (herd *Herd) showSubs(writer io.Writer, subType string,
	selectFunc func(*Sub) bool) {
	fmt.Fprintf(writer, "<title>Dominator %s subs</title>", subType)
	fmt.Fprintln(writer, `<style>
                          table, th, td {
                          border-collapse: collapse;
                          }
                          </style>`)
	if srpc.CheckTlsRequired() {
		fmt.Fprintln(writer, "<body>")
	} else {
		fmt.Fprintln(writer, "<body bgcolor=\"#ffb0b0\">")
		fmt.Fprintln(writer,
			`<h1><center><font color="red">Running in insecure mode. You can get pwned!!!</center></font></h1>`)
	}
	if herd.updatesDisabledReason != "" {
		fmt.Fprintf(writer, "<center>")
		herd.writeDisableStatus(writer)
		fmt.Fprintln(writer, "</center>")
	}
	fmt.Fprintln(writer, `<table border="1" style="width:100%">`)
	fmt.Fprintln(writer, "  <tr>")
	fmt.Fprintln(writer, "    <th>Name</th>")
	fmt.Fprintln(writer, "    <th>Required Image</th>")
	fmt.Fprintln(writer, "    <th>Planned Image</th>")
	fmt.Fprintln(writer, "    <th>Busy</th>")
	fmt.Fprintln(writer, "    <th>Status</th>")
	fmt.Fprintln(writer, "    <th>Uptime</th>")
	fmt.Fprintln(writer, "    <th>Last Scan Duration</th>")
	fmt.Fprintln(writer, "    <th>Staleness</th>")
	fmt.Fprintln(writer, "    <th>Last Update</th>")
	fmt.Fprintln(writer, "    <th>Last Sync</th>")
	fmt.Fprintln(writer, "    <th>Connect</th>")
	fmt.Fprintln(writer, "    <th>Short Poll</th>")
	fmt.Fprintln(writer, "    <th>Full Poll</th>")
	fmt.Fprintln(writer, "    <th>Update Compute</th>")
	fmt.Fprintln(writer, "  </tr>")
	subs := herd.getSelectedSubs(selectFunc)
	for _, sub := range subs {
		showSub(writer, sub)
	}
	fmt.Fprintln(writer, "</table>")
}
Пример #2
0
func statusHandler(w http.ResponseWriter, req *http.Request) {
	writer := bufio.NewWriter(w)
	defer writer.Flush()
	fmt.Fprintln(writer, "<title>imageserver status page</title>")
	fmt.Fprintln(writer, "<body>")
	fmt.Fprintln(writer, "<center>")
	fmt.Fprintln(writer, "<h1>imageserver status page</h1>")
	if !srpc.CheckTlsRequired() {
		fmt.Fprintln(writer,
			`<h1><font color="red">Running in insecure mode. Your images can be pwned!!!</font></h1>`)
	}
	fmt.Fprintln(writer, "</center>")
	html.WriteHeaderWithRequest(writer, req)
	fmt.Fprintln(writer, "<h3>")
	for _, htmlWriter := range htmlWriters {
		htmlWriter.WriteHtml(writer)
	}
	fmt.Fprintln(writer, "</h3>")
	fmt.Fprintln(writer, "<hr>")
	html.WriteFooter(writer)
	fmt.Fprintln(writer, "</body>")
}
Пример #3
0
func (herd *Herd) statusHandler(w http.ResponseWriter, req *http.Request) {
	writer := bufio.NewWriter(w)
	defer writer.Flush()
	fmt.Fprintln(writer, "<title>Dominator status page</title>")
	fmt.Fprintln(writer, "<body>")
	fmt.Fprintln(writer, "<center>")
	fmt.Fprintln(writer, "<h1><b>Dominator</b> status page</h1>")
	if !srpc.CheckTlsRequired() {
		fmt.Fprintln(writer,
			`<h1><font color="red">Running in insecure mode. You can get pwned!!!</font></h1>`)
	}
	fmt.Fprintln(writer, "</center>")
	html.WriteHeaderWithRequestNoGC(writer, req)
	fmt.Fprintln(writer, "<h3>")
	herd.writeHtml(writer)
	for _, htmlWriter := range herd.htmlWriters {
		htmlWriter.WriteHtml(writer)
	}
	fmt.Fprintln(writer, "</h3>")
	fmt.Fprintln(writer, "<hr>")
	html.WriteFooter(writer)
	fmt.Fprintln(writer, "</body>")
}
Пример #4
0
func (herd *Herd) showSubHandler(w io.Writer, req *http.Request) {
	subName := req.URL.RawQuery
	fmt.Fprintf(w, "<title>sub %s</title>", subName)
	if srpc.CheckTlsRequired() {
		fmt.Fprintln(w, "<body>")
	} else {
		fmt.Fprintln(w, "<body bgcolor=\"#ffb0b0\">")
		fmt.Fprintln(w,
			`<h1><center><font color="red">Running in insecure mode. You can get pwned!!!</center></font></h1>`)
	}
	if herd.updatesDisabledReason != "" {
		fmt.Fprintf(w, "<center>")
		herd.writeDisableStatus(w)
		fmt.Fprintln(w, "</center>")
	}
	fmt.Fprintln(w, "<h3>")
	sub := herd.getSub(subName)
	if sub == nil {
		fmt.Fprintf(w, "Sub: %s UNKNOWN!\n", subName)
		return
	}
	timeNow := time.Now()
	subURL := fmt.Sprintf("http://%s:%d/",
		strings.SplitN(sub.String(), "*", 2)[0], constants.SubPortNumber)
	fmt.Fprintf(w, "Information for sub: <a href=\"%s\">%s</a><br>\n",
		subURL, subName)
	fmt.Fprintln(w, "</h3>")
	fmt.Fprint(w, "<table border=\"0\">\n")
	newRow(w, "Required Image", true)
	sub.herd.showImage(w, sub.mdb.RequiredImage, true)
	newRow(w, "Planned Image", false)
	sub.herd.showImage(w, sub.mdb.PlannedImage, false)
	newRow(w, "Busy time", false)
	sub.showBusy(w)
	newRow(w, "Status", false)
	fmt.Fprintf(w, "    <td>%s</td>\n", sub.publishedStatus.html())
	newRow(w, "Uptime", false)
	showSince(w, sub.pollTime, sub.startTime)
	newRow(w, "Last scan duration", false)
	showDuration(w, sub.lastScanDuration, false)
	newRow(w, "Time since last successful poll", false)
	showSince(w, timeNow, sub.lastPollSucceededTime)
	newRow(w, "Time since last update", false)
	showSince(w, timeNow, sub.lastUpdateTime)
	newRow(w, "Time since last sync", false)
	showSince(w, timeNow, sub.lastSyncTime)
	newRow(w, "Last connection duration", false)
	showDuration(w, sub.lastConnectDuration, false)
	newRow(w, "Last short poll duration", false)
	showDuration(w, sub.lastShortPollDuration, !sub.lastPollWasFull)
	newRow(w, "Last full poll duration", false)
	showDuration(w, sub.lastFullPollDuration, sub.lastPollWasFull)
	newRow(w, "Last compute duration", false)
	showDuration(w, sub.lastComputeUpdateCpuDuration, false)
	fmt.Fprint(w, "  </tr>\n")
	fmt.Fprint(w, "</table>\n")
	fmt.Fprintln(w, "MDB Data:")
	fmt.Fprintln(w, "<pre>")
	json.WriteWithIndent(w, "    ", sub.mdb)
	fmt.Fprintln(w, "</pre>")
}