Ukulawula isimo se-enterprise esidumile kungabangela izigulane ze-IT ezinzima - ikakhulukazi lapho kufanele ukuguqula isitimela se-endpoints esizayo.BarbaricBootI-Python-powered mass reboot tool, eyakhelwe ama-administrators abekho isikhathi ye-click-by-click monotony. Njengomuthi i-Barberion enhle, iveza ikhasi lakho le-machine nge-speed, amandla, nokunciphisa ukujabulela izinzuzo.
Yini BarbaricBoot?
BarbaricBootI-command-line script ye-Python enikeza i-liste ye-computer names futhi ivumela izivakashi ze-reboots ezingenalutho, zihlanganisa zonke izixazululo nama-defeat ngokulandelana. I-Perfect for Windows-centric environments (ngokuthi kusetshenziselwa isisindo se-Windows).shutdown
I-command) itholisa i-multi-threading yokusebenza okuphakeme kakhulu. Yonke i-reboot ebuthukile ibhaliswe – zonke i-reboot ebuthukile iyiphi isixazululo esigcwele.
Yini BarbaricBoot?
- I-Efficiency: I-Reboot ye-hundreds of machines ku-minutes, akuyona amahora.
- Simplicity: One file, one command, ukulawula okungenani.
- I-Accountability: Ukubuyekezwa kwe-time ye-feedback ku-successes ne-failures.
- I-No-Nonsense Barbaric Spirit: Just reboot 'em zonke - akukho imibuzo, akukho ukunakekelwa.
Indlela It Works
- Input: Drop your machine names (one ngalinye) ku pcs.log.
- Ukusebenza: I-BarbaricBoot ihamba usebenzisa i- concurrent.futures ye-Python ukuqala ku-20 ama-reboots e-parallel ngexesha elifanayo.
- Umhlahlandlela: Uyakwazi ukufikelela imizuzu yokuphumula kanye nokuphumula-plus imibuzo esifundeni yebhizinisi omusha isicelo yakho.
Indlela yokufaka futhi usebenzisa BarbaricBoot
Izidingo
- I-Python 3.6 noma ngaphezulu
- Izinzuzo ze-admin ze-Windows (izinzuzo ze-shutdown ye-Remote)
- Ifayela le-pcs.log elihlanganisa imishini yakho yokufinyelela (one ngalinye)
Ngena ngemvume
- **Save the Script
\ Copy the complete
BarbaricBoot.py
code (provided below) to your admin machine. - **Prepare Your Targets
\ Create a plain text file called
pcs.log
in the same directory as your script, listing each machine to be rebooted. - **Run BarbaricBoot \ Open a terminal and execute: “Python BarbericBoot.py“
ikhodi ephelele
#Another /\_[]_/\
# fine |] _||_ [|
# ___ \/ || \/
# /___\ ||
# (|0 0|) ||
# __/{\U/}\_ ___/vvv
# / \ {~} / _|_P|
# | /\ ~ /_/ []
# |_| (____)
# \_]/______\ Barberion
# _\_||_/_ Production
# (_,_||_,_)
#
import concurrent.futures
import subprocess
import logging
from threading import Lock
# Set up logging for failed reboots
logging.basicConfig(filename='failed_reboots.log', level=logging.INFO)
# Lock for thread-safe printing and updating counters
print_lock = Lock()
def reboot_machine(machine_name, success_counter, failure_counter):
try:
subprocess.run(['shutdown', '/r', '/t', '0', '/m', f'\\\\{machine_name}', '/f'],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
with print_lock:
success_counter[0] += 1
print(f"\rTotal successful reboots: {success_counter[0]}, Total failed reboots: {failure_counter[0]}", end='')
except subprocess.CalledProcessError as e:
with print_lock:
failure_counter[0] += 1
print(f"\rTotal successful reboots: {success_counter[0]}, Total failed reboots: {failure_counter[0]}", end='')
logging.error(f"Failed to reboot {machine_name}: {e}")
def main():
with open('pcs.log') as file:
machines = file.readlines()
total_hosts = len(machines)
print(f"Total hosts in file: {total_hosts}")
# Shared counters for successful and failed reboots
successful_reboots = [0]
failed_reboots = [0]
# Use ThreadPoolExecutor for parallel execution
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
futures = [executor.submit(reboot_machine, machine.strip(), successful_reboots, failed_reboots) for machine in machines]
# Wait for all tasks to complete, i suppose you can comment out for rapid fire.
concurrent.futures.wait(futures)
# Final print to ensure the last count is displayed correctly
print(f"\nFinal count - Total successful reboots: {successful_reboots[0]}, Total failed reboots: {failed_reboots[0]}")
if __name__ == "__main__":
main()
Ukuhlobisa Tips
- Ukwandisa noma Ukwandisa I-Parallelism: I-Tweak max_workers=20 ye-attacks emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo emangalisayo.
- I-Logging: Zonke izivakashi ezingenalutho zithunyelwe ku-failed_reboots.log ukuze zithunyelwe ngokushesha.
- I-Fire Option ye-Rapid: Ukubuyekeza umugqa we- concurrent.futures.wait(futures) uma ufuna ukunceda i-script ku-fire kanye nokuguqulwa
Imibuzo yokuqala
I-BarbaricBoot ayikho nomdlavuza. Usebenzisa ngokufanelekileyo, usebenzisa ngokufanele, futhi ukunakekelwa: nge-power enhle kunezinto enhle. May izibuyekezo zakho zikhuthaze ngokushesha, izibuyekezo zakho zihlukile, futhi izibuyekezo zakho zihlukile njalo!