Commit bc23b609 authored by ale's avatar ale

Add a dataset/by_host debug page

parent 28d6b86b
Pipeline #8329 passed with stages
in 1 minute and 29 seconds
......@@ -47,7 +47,8 @@ var (
<td><b><a href="/backup/by_id?id={{$b.BackupID}}">
{{$b.BackupID}}</a></b></td>
<td>{{fmtDate $b.BackupTimestamp}}</td>
<td>{{$b.BackupHost}}</td>
<td><a href="/dataset/by_host?host={{$b.BackupHost}}">
{{$b.BackupHost}}</a></td>
{{else}}
<td colspan="3"></td>
{{end}}
......@@ -85,12 +86,12 @@ var (
<table>
<tbody>
<tr>
<td>Latest backup ID</td>
<td><a href="/backup/by_id?id={{.Backup.BackupID}}">
{{.Backup.BackupID}}</a></td>
<td>Backup ID</td>
<td><b><a href="/backup/by_id?id={{.Backup.BackupID}}">
{{.Backup.BackupID}}</a></b></td>
</tr>
<tr>
<td>Latest timestamp</td>
<td>Timestamp</td>
<td>{{fmtDate .Backup.BackupTimestamp}}</td>
</tr>
<tr>
......@@ -122,7 +123,7 @@ var (
{{range .Atoms}}
<tr>
<td>{{.AtomName}}</td>
<td>{{.AtomPath}}</td>
<td>{{if .AtomPath}}{{.AtomPath}}{{else}}<i>stdin</i>{{end}}</td>
</tr>
{{end}}
</tbody>
......@@ -245,6 +246,16 @@ func (s *httpServer) handleDebugDatasetsBySource(w http.ResponseWriter, r *http.
s.queryAndShowDatasets(w, r, fmt.Sprintf("Latest backups for %s", source), "get_latest_datasets_by_source", source, 30)
}
func (s *httpServer) handleDebugDatasetsByHost(w http.ResponseWriter, r *http.Request) {
host := r.FormValue("host")
if host == "" {
http.Error(w, "No host specified", http.StatusBadRequest)
return
}
s.queryAndShowDatasets(w, r, fmt.Sprintf("Latest backups for host %s", host), "get_latest_datasets_by_host", host, 30)
}
func (s *httpServer) handleDebugBackupByID(w http.ResponseWriter, r *http.Request) {
id := r.FormValue("id")
if id == "" {
......
......@@ -53,6 +53,7 @@ func (s *httpServer) Handler() http.Handler {
m.HandleFunc("/api/add_dataset", s.handleAddDataset)
m.HandleFunc("/api/find_atoms", s.handleFindAtoms)
m.HandleFunc("/dataset/by_source", s.handleDebugDatasetsBySource)
m.HandleFunc("/dataset/by_host", s.handleDebugDatasetsByHost)
m.HandleFunc("/dataset/by_id", s.handleDebugDatasetByID)
m.HandleFunc("/backup/by_id", s.handleDebugBackupByID)
m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
......
......@@ -256,6 +256,22 @@ var statements = map[string]string{
dataset_duration
ORDER BY backup_timestamp DESC
LIMIT ?
`,
"get_latest_datasets_by_host": `
SELECT
backup_id, backup_timestamp, backup_host,
dataset_id, dataset_snapshot_id, dataset_source,
dataset_total_files, dataset_total_bytes, dataset_bytes_added,
dataset_duration, COUNT(*) AS num_atoms
FROM log
WHERE backup_host = ?
GROUP BY
backup_id, backup_timestamp, backup_host,
dataset_id, dataset_snapshot_id, dataset_source,
dataset_total_files, dataset_total_bytes, dataset_bytes_added,
dataset_duration
ORDER BY backup_timestamp DESC
LIMIT ?
`,
"get_backup_by_id": `
SELECT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment