Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server Rack Cluster Test Script
- -- Supports multiple server racks using peripheral.group()
- local racks = peripheral.group("server_rack")
- local lights = peripheral.group("led_floor_light")
- if racks.count() == 0 then
- print("No server racks found!")
- return
- end
- -- Light up all floor lights blue
- if lights.count() > 0 then
- print("Lighting up " .. lights.count() .. " floor lights blue...")
- lights.setColor(4) -- Blue color
- lights.turnOn()
- else
- print("No LED floor lights found")
- end
- print("")
- print("=== Server Rack Cluster ===")
- print("Connected Racks: " .. racks.count())
- print("")
- -- Aggregate totals across all racks
- local totalRacks = 0
- local totalSlots = 0
- local activeServers = 0
- local emptySlots = 0
- local totalMemoryKB = 0
- local totalStorageKB = 0
- local totalComputePower = 0
- local maxCpuTier = 0
- local maxGpuTier = 0
- local maxRamTier = 0
- local maxStorageTier = 0
- -- Collect info from each rack
- local rackInfos = {}
- racks.forEach(function(name, rack)
- local info = rack.getClusterInfo()
- rackInfos[name] = info
- totalRacks = totalRacks + info.rackCount
- totalSlots = totalSlots + info.totalSlots
- activeServers = activeServers + info.activeServers
- emptySlots = emptySlots + info.emptySlots
- totalMemoryKB = totalMemoryKB + info.totalMemoryKB
- totalStorageKB = totalStorageKB + info.totalStorageKB
- totalComputePower = totalComputePower + info.computePower
- -- Track highest tier components
- maxCpuTier = math.max(maxCpuTier, info.cpuTier)
- maxGpuTier = math.max(maxGpuTier, info.gpuTier)
- maxRamTier = math.max(maxRamTier, info.ramTier)
- maxStorageTier = math.max(maxStorageTier, info.storageTier)
- end)
- -- Calculate average speed multiplier
- local avgSpeedMultiplier = 0
- local rackCount = racks.count()
- racks.forEach(function(name, rack)
- local info = rack.getClusterInfo()
- avgSpeedMultiplier = avgSpeedMultiplier + info.speedMultiplier
- end)
- avgSpeedMultiplier = avgSpeedMultiplier / rackCount
- -- Show individual rack details
- print("=== Individual Racks ===")
- local i = 1
- for name, info in pairs(rackInfos) do
- print(i .. ". " .. name)
- print(" Servers: " .. info.activeServers .. "/" .. info.totalSlots)
- print(" Memory: " .. math.floor(info.totalMemoryKB / 1024) .. " MB")
- print(" Storage: " .. math.floor(info.totalStorageKB / 1024) .. " MB")
- print(" Compute: " .. info.computePower)
- i = i + 1
- end
- -- Utility functions for cluster management
- print("")
- print("=== Cluster Commands ===")
- print("Use: cluster status - Show this info")
- print("Use: cluster list - List all racks")
- print("Use: cluster <name> - Show specific rack")
- print("=== Cluster Totals ===")
- print("Total Rack Units: " .. totalRacks)
- print("Total Slots: " .. totalSlots)
- print("Active Servers: " .. activeServers)
- print("Empty Slots: " .. emptySlots)
- print("")
- print("=== Best Hardware Tiers ===")
- print("Max CPU Tier: " .. maxCpuTier)
- print("Max GPU Tier: " .. maxGpuTier)
- print("Max RAM Tier: " .. maxRamTier)
- print("Max Storage Tier: " .. maxStorageTier)
- print("")
- print("=== Combined Resources ===")
- print("Total Memory: " .. totalMemoryKB .. " KB (" .. math.floor(totalMemoryKB / 1024) .. " MB)")
- print("Total Storage: " .. totalStorageKB .. " KB (" .. math.floor(totalStorageKB / 1024) .. " MB)")
- print("Total Compute Power: " .. totalComputePower)
- print("Avg Speed Multiplier: " .. string.format("%.2f", avgSpeedMultiplier))
- print("")
- -- Handle command line arguments
- local args = {...}
- if args[1] == "list" then
- print("")
- print("Connected Racks:")
- for _, name in ipairs(racks.getNames()) do
- print(" - " .. name)
- end
- elseif args[1] and args[1] ~= "status" then
- -- Try to get specific rack
- local rack = racks.getByName(args[1])
- if not rack then
- -- Try with server_rack_ prefix
- rack = racks.getByName("server_rack_" .. args[1])
- end
- if rack then
- local info = rack.getClusterInfo()
- print("")
- print("=== " .. args[1] .. " Details ===")
- print("Slots: " .. info.activeServers .. "/" .. info.totalSlots)
- print("CPU Tier: " .. info.cpuTier)
- print("GPU Tier: " .. info.gpuTier)
- print("RAM Tier: " .. info.ramTier)
- print("Storage Tier: " .. info.storageTier)
- print("Memory: " .. info.totalMemoryKB .. " KB")
- print("Storage: " .. info.totalStorageKB .. " KB")
- print("Compute Power: " .. info.computePower)
- print("Speed Multiplier: " .. info.speedMultiplier)
- else
- print("Rack '" .. args[1] .. "' not found!")
- end
- end
Add Comment
Please, Sign In to add comment