help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
go-cli-tool
/
internal
/
monops
RSK World
go-cli-tool
Go CLI Tool v3.0 - Command-Line Interface with File Operations + Text Processing + System Monitoring + Cryptographic Tools + Network Utilities + HTTP Client + Image Processing + Cross-Platform Support + Modern Go Development
monops
  • monitor.go1.8 KB
monitor.go
internal/monops/monitor.go
Raw Download
Find: Go to:
/*
 * Project: Go CLI Tool
 * Category: Go Projects
 * Description: Command-line interface tool built with Go. Features file operations, text processing, command parsing, and system utilities.
 * Author: RSK World
 * Email: support@rskworld.in
 * Website: https://rskworld.in/contact.php
 * Year: 2026
 * Copyright (c) 2026 RSK World. All rights reserved.
 */

package monops

import (
	"fmt"
	"os"
	"os/signal"
	"runtime"
	"syscall"
	"time"

	"go-cli-tool/internal/ui"
)

// ShowDashboard prints a real-time system monitoring dashboard.
func ShowDashboard() {
	ui.Banner()
	ui.Header("SYSTEM MONITORING DASHBOARD")
	ui.Info("Press Ctrl+C to exit monitoring mode")
	fmt.Println()

	// Set up signal handling for graceful exit
	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)

	ticker := time.NewTicker(1 * time.Second)
	defer ticker.Stop()

	snapshot := 1
	for {
		select {
		case <-sigChan:
			fmt.Println()
			ui.Success("Monitoring session ended.")
			return
		case <-ticker.C:
			// Clear screen and move cursor to top
			fmt.Printf("\033[2J\033[H")

			ui.Banner()
			ui.Header(fmt.Sprintf("SYSTEM MONITORING DASHBOARD (Snapshot #%d)", snapshot))

			ui.Info(fmt.Sprintf("Time: %s", time.Now().Format("15:04:05.000")))
			ui.Info(fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
			ui.Info(fmt.Sprintf("CPUs: %d", runtime.NumCPU()))
			ui.Info(fmt.Sprintf("Goroutines: %d", runtime.NumGoroutine()))

			var m runtime.MemStats
			runtime.ReadMemStats(&m)
			ui.Info(fmt.Sprintf("Memory Alloc: %.1f MB", float64(m.Alloc)/1024/1024))
			ui.Info(fmt.Sprintf("System Mem: %.1f MB", float64(m.Sys)/1024/1024))
			ui.Info(fmt.Sprintf("GC Cycles: %d", m.NumGC))

			fmt.Println("\nPress Ctrl+C to exit monitoring mode...")
			snapshot++
		}
	}
}
69 lines•1.8 KB
go

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer