FastHandle is fast operation tools for infrastructure configurations and tests.
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
os:linux:check:index.html [2018/01/07 22:39] kurihara |
os:linux:check:index.html [2019/02/11 00:41] (current) kurihara |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| [[: | [[: | ||
| - | ====== Check OS Status (check.py) ====== | + | ====== Check Linux Status |
| $FHHOME/ | $FHHOME/ | ||
| Line 7: | Line 7: | ||
| \\ | \\ | ||
| - | ===== Operation ===== | + | ===== Operation |
| + | ==== Print list of possible commands | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| - | $ fab -l |grep check | + | $ fab -l |grep -F check. |
| + | check.check_ssh_hostname | ||
| + | check.nmap | ||
| + | check.ntpsync | ||
| + | check.ping_gw | ||
| + | check.reboot_check | ||
| + | check.reboot_diff | ||
| + | check.systemctl_service_enable_disable | ||
| + | </ | ||
| - | $ fab -H $H auth.pro | + | |
| + | ==== Example ==== | ||
| + | |||
| + | <sxh bash toolbar: | ||
| + | $ fab -H $H | ||
| </ | </ | ||
| - | ==== Remote Shell Commands | + | \\ |
| + | ==== Fabric one-line Task Examples | ||
| <sxh bash toolbar: | <sxh bash toolbar: | ||
| - | $ fab -H $H auth.pro | + | $ fab -H $H -- systemctl get-default |
| - | $ FAB -H $H auth.pro | + | $ FAB -H $H -- systemctl set-default multi-user.target |
| </ | </ | ||
| Line 31: | Line 45: | ||
| from fabric.api import * | from fabric.api import * | ||
| from fabric.contrib import files | from fabric.contrib import files | ||
| + | from datetime import datetime | ||
| FHHOME=os.environ[" | FHHOME=os.environ[" | ||
| Line 46: | Line 61: | ||
| # | # | ||
| # check.nmap | # check.nmap | ||
| - | # | + | # |
| # | # | ||
| @task | @task | ||
| def nmap(port, remote): | def nmap(port, remote): | ||
| - | """ | + | """ |
| run(" | run(" | ||
| + | |||
| + | # | ||
| + | # check_ssh_hostname: | ||
| + | # | ||
| + | @task | ||
| + | def check_ssh_hostname(localuser, | ||
| + | """ | ||
| + | sudo ('su - %s -c "ssh -i %s %s@%s hostname"' | ||
| Line 63: | Line 86: | ||
| @task | @task | ||
| def reboot_check(): | def reboot_check(): | ||
| + | """ | ||
| date = datetime.now().strftime(' | date = datetime.now().strftime(' | ||
| - | outfile = check_reboot.%s" | + | outfile = "check_reboot.%s" |
| run(" | run(" | ||
| - | put(" | + | put(" |
| sudo(" | sudo(" | ||
| Line 75: | Line 99: | ||
| @task | @task | ||
| def reboot_diff(): | def reboot_diff(): | ||
| - | run(ls -tr1 output/ | + | run("ls -tr1 output/ |
| file1=run(" | file1=run(" | ||
| file2=run(" | file2=run(" | ||
| - | local(" | + | local(" |
| - | run(" | + | run(" |
| # | # | ||
| Line 86: | Line 110: | ||
| @task | @task | ||
| def ping_gw(): | def ping_gw(): | ||
| + | """ | ||
| run(" | run(" | ||
| - | put(" | + | put(" |
| run(" | run(" | ||
| Line 97: | Line 122: | ||
| # | # | ||
| # CentOS7 | # CentOS7 | ||
| + | # check.systemctl_service_enable_disable | ||
| # | # | ||
| @task | @task | ||
| - | def check_systemctl_service(): | + | def systemctl_service_enable_disable(): |
| - | sudo("systemctl list-unit-files -t service |egrep " | + | sudo('systemctl list-unit-files -t service |
| Line 109: | Line 135: | ||
| |<100% 200px ->| | |<100% 200px ->| | ||
| - | | [[os: | + | | [[os:linux: |
| - | | [[os: | + | | [[os:linux: |
My Sites
SNS
Copyright (c) 2025 FastHandle - IT Operations Examples All Rights Reserved.