Nuke all storage computation
Doesn't fucking work
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -112,51 +113,63 @@ func (o *Orchestrator) refetchAllData() {
|
||||
// processCharacter processes a single character's data
|
||||
func (o *Orchestrator) processCharacter(char types.Character) {
|
||||
logger.Info("Orchestrator.processCharacter: Starting processing for character: %s (ID: %d)", char.CharacterName, char.ID)
|
||||
|
||||
// Get extractors for this character
|
||||
// logger.Info("Orchestrator.processCharacter: Getting extractors for character %s", char.CharacterName)
|
||||
// extractors, err := routes.GetExtractorsForCharacter(o.esiClient, int(char.ID), char.AccessToken)
|
||||
// if err != nil {
|
||||
// logger.Warning("Orchestrator.processCharacter: Failed to get extractors for character %s: %v", char.CharacterName, err)
|
||||
// return
|
||||
// }
|
||||
// logger.Info("Orchestrator.processCharacter: Got %d extractors for character %s", len(extractors), char.CharacterName)
|
||||
|
||||
// Get storage for this character
|
||||
logger.Info("Orchestrator.processCharacter: Getting storage for character %s", char.CharacterName)
|
||||
storage, err := routes.GetStorageForCharacter(o.esiClient, int(char.ID), char.AccessToken)
|
||||
|
||||
planets, err := o.esiClient.GetCharacterPlanets(context.Background(), int(char.ID), char.AccessToken)
|
||||
if err != nil {
|
||||
logger.Warning("Orchestrator.processCharacter: Failed to get storage for character %s: %v", char.CharacterName, err)
|
||||
logger.Warning("Orchestrator.processCharacter: Failed to get planets for character %s: %v", char.CharacterName, err)
|
||||
return
|
||||
}
|
||||
logger.Info("Orchestrator.processCharacter: Got %d storage facilities for character %s", len(storage), char.CharacterName)
|
||||
logger.Info("Orchestrator.processCharacter: Got %d planets for character %s", len(planets), char.CharacterName)
|
||||
|
||||
planetIds := make([]int64, len(planets))
|
||||
for i, planet := range planets {
|
||||
planetIds[i] = planet.PlanetID
|
||||
}
|
||||
|
||||
// Get extractors for this character
|
||||
logger.Info("Orchestrator.processCharacter: Getting extractors for character %s", char.CharacterName)
|
||||
extractors, err := routes.GetExtractorsForCharacter(o.esiClient, int(char.ID), char.AccessToken, planetIds)
|
||||
if err != nil {
|
||||
logger.Warning("Orchestrator.processCharacter: Failed to get extractors for character %s: %v", char.CharacterName, err)
|
||||
return
|
||||
}
|
||||
logger.Info("Orchestrator.processCharacter: Got %d extractors for character %s", len(extractors), char.CharacterName)
|
||||
|
||||
// Get storage for this character
|
||||
// logger.Info("Orchestrator.processCharacter: Getting storage for character %s", char.CharacterName)
|
||||
// storage, err := routes.GetStorageForCharacter(o.esiClient, int(char.ID), char.AccessToken)
|
||||
// if err != nil {
|
||||
// logger.Warning("Orchestrator.processCharacter: Failed to get storage for character %s: %v", char.CharacterName, err)
|
||||
// return
|
||||
// }
|
||||
// logger.Info("Orchestrator.processCharacter: Got %d storage facilities for character %s", len(storage), char.CharacterName)
|
||||
|
||||
// Check storage thresholds
|
||||
logger.Info("Orchestrator.processCharacter: Checking storage thresholds for character %s", char.CharacterName)
|
||||
o.checkStorageThresholds(char.CharacterName, storage)
|
||||
// logger.Info("Orchestrator.processCharacter: Checking storage thresholds for character %s", char.CharacterName)
|
||||
// o.checkStorageThresholds(char.CharacterName, storage)
|
||||
|
||||
// Update expiry timers for extractors
|
||||
// logger.Info("Orchestrator.processCharacter: Updating expiry timers for character %s", char.CharacterName)
|
||||
// o.updateExpiryTimers(char.CharacterName, extractors)
|
||||
logger.Info("Orchestrator.processCharacter: Updating expiry timers for character %s", char.CharacterName)
|
||||
o.updateExpiryTimers(char.CharacterName, extractors)
|
||||
|
||||
logger.Info("Orchestrator.processCharacter: Completed processing for character %s", char.CharacterName)
|
||||
}
|
||||
|
||||
// checkStorageThresholds checks storage utilization against configured thresholds
|
||||
func (o *Orchestrator) checkStorageThresholds(characterName string, storage []routes.StorageInfo) {
|
||||
warningThreshold := options.GlobalOptions.StorageWarning
|
||||
criticalThreshold := options.GlobalOptions.StorageCritical
|
||||
// func (o *Orchestrator) checkStorageThresholds(characterName string, storage []routes.StorageInfo) {
|
||||
// warningThreshold := options.GlobalOptions.StorageWarning
|
||||
// criticalThreshold := options.GlobalOptions.StorageCritical
|
||||
|
||||
for _, s := range storage {
|
||||
if s.Utilization >= criticalThreshold {
|
||||
message := routes.FormatStorageAlert(s, true)
|
||||
o.sendWebhook(characterName, message)
|
||||
} else if s.Utilization >= warningThreshold {
|
||||
message := routes.FormatStorageAlert(s, false)
|
||||
o.sendWebhook(characterName, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
// for _, s := range storage {
|
||||
// if s.Utilization >= criticalThreshold {
|
||||
// message := routes.FormatStorageAlert(s, true)
|
||||
// o.sendWebhook(characterName, message)
|
||||
// } else if s.Utilization >= warningThreshold {
|
||||
// message := routes.FormatStorageAlert(s, false)
|
||||
// o.sendWebhook(characterName, message)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// updateExpiryTimers updates the in-memory expiry timers for extractors
|
||||
func (o *Orchestrator) updateExpiryTimers(characterName string, extractors []routes.ExtractorInfo) {
|
||||
|
||||
Reference in New Issue
Block a user