Dracula 风格监控
-为程序员和开发者打造的暗色主题界面
+// Dracula 风格监控
+// 为程序员和开发者打造的暗色主题界面
diff --git a/collector/collector.go b/collector/collector.go index 70fd763ad511ba32d1e420cad6b276045a709439..81ce4c17d62f3f1162c071859a71ec1a9f1905ad 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -79,6 +79,13 @@ func NewLibvirtCollector(uri string) (*LibvirtCollector, error) { return collector, nil } +// GetURI returns the libvirt connection URI +func (c *LibvirtCollector) GetURI() string { + c.mutex.RLock() + defer c.mutex.RUnlock() + return c.uri +} + // Describe implements the prometheus.Collector interface // It sends all descriptors of metrics that can be collected to the provided channel func (c *LibvirtCollector) Describe(ch chan<- *prometheus.Desc) { diff --git a/server/server.go b/server/server.go index bf9341082cb68cc8819046e0c449497ddb1d32fb..fb8e40c4e9676b331173cf39bf93eeb887a15fa8 100644 --- a/server/server.go +++ b/server/server.go @@ -126,12 +126,29 @@ func (s *Server) handleRoot(w http.ResponseWriter, r *http.Request) { BuildTime string Uptime string TemplateName string + LibvirtURI string + TotalVMs int + ActiveVMs int }{ MetricsPath: s.config.GetMetricsPath(), Version: version.Version, BuildTime: version.BuildTime, Uptime: time.Since(s.startTime).Truncate(time.Second).String(), TemplateName: templateName, + LibvirtURI: "N/A", + TotalVMs: 0, + ActiveVMs: 0, + } + + // Try to get libvirt connection info and VM stats + if s.libvirtCollector != nil { + // Get libvirt URI from collector + data.LibvirtURI = s.libvirtCollector.GetURI() + + // TODO: Add methods to get VM stats + // For now, we'll leave these as 0 + data.TotalVMs = 0 + data.ActiveVMs = 0 } // Execute the template diff --git a/templates/root.html b/templates/root.html index d16ac8a8d28ffbef0e0a6c2c7f44283d53f507e2..60cec505df53ea3d8b1175bd1f1632afc7377efd 100644 --- a/templates/root.html +++ b/templates/root.html @@ -74,6 +74,18 @@ 运行时长: {{.Uptime}} +
Dracula 主题 | 程序员喜爱的暗色主题
+// Dracula 主题 | 程序员喜爱的暗色主题
为程序员和开发者打造的暗色主题界面
+// 为程序员和开发者打造的暗色主题界面