Implement proper storage metrics (P0-009)\n\n- Add dedicated storage_metrics table\n- Create StorageMetricReport models with proper field names\n- Add ReportStorageMetrics to agent client\n- Update storage scanner to use new method\n- Implement server-side handlers and queries\n- Register new routes and update UI\n- Remove legacy Scan() method\n- Follow ETHOS principles: honest naming, clean architecture
This commit is contained in:
12
aggregator-agent/internal/cache/local.go
vendored
12
aggregator-agent/internal/cache/local.go
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Fimeg/RedFlag/aggregator-agent/internal/client"
|
||||
"github.com/Fimeg/RedFlag/aggregator-agent/internal/constants"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -22,15 +23,12 @@ type LocalCache struct {
|
||||
AgentStatus string `json:"agent_status"`
|
||||
}
|
||||
|
||||
// CacheDir is the directory where local cache is stored
|
||||
const CacheDir = "/var/lib/redflag-agent"
|
||||
|
||||
// CacheFile is the file where scan results are cached
|
||||
const CacheFile = "last_scan.json"
|
||||
// cacheFile is the file where scan results are cached
|
||||
const cacheFile = "last_scan.json"
|
||||
|
||||
// GetCachePath returns the full path to the cache file
|
||||
func GetCachePath() string {
|
||||
return filepath.Join(CacheDir, CacheFile)
|
||||
return filepath.Join(constants.GetAgentCacheDir(), cacheFile)
|
||||
}
|
||||
|
||||
// Load reads the local cache from disk
|
||||
@@ -62,7 +60,7 @@ func (c *LocalCache) Save() error {
|
||||
cachePath := GetCachePath()
|
||||
|
||||
// Ensure cache directory exists
|
||||
if err := os.MkdirAll(CacheDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(constants.GetAgentCacheDir(), 0755); err != nil {
|
||||
return fmt.Errorf("failed to create cache directory: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user