FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


os:linux:check:index.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
os:linux:check:index.html [2018/02/03 10:50]
kurihara
os:linux:check:index.html [2018/03/14 00:31]
kurihara
Line 1: Line 1:
 [[:index.html#OS Management|Top#OS Management]] [[:index.html#OS Management|Top#OS Management]]
-====== Check OS Status (check.py) ======+====== Check Linux Status with Fabric (check.py) ======
  
 $FHHOME/fabfile/check.py $FHHOME/fabfile/check.py
Line 7: Line 7:
 \\ \\
  
-===== Operation =====+===== Operation with Fabric ===== 
 +==== Print list of possible commands  ====
  
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
-$ fab -l |grep check+$ fab -l |grep -F check
 +    check.check_ssh_hostname                check_ssh_hostname:localuser,key,... 
 +    check.nmap                              fab auth.pro ope.nmap:22,x.x.x.x 
 +    check.ntpsync 
 +    check.ping_gw                           use  %s/scripts/check_ping_gw.sh 
 +    check.reboot_check                      use  %s/scripts/check_reboot.sh 
 +    check.reboot_diff 
 +    check.systemctl_service_enable_disable 
 +</sxh>
  
 +
 +==== Example ====
 +
 +<sxh bash toolbar:false gutter:false>
 $ fab -H $H auth.pro  check.xxxx $ fab -H $H auth.pro  check.xxxx
 </sxh> </sxh>
  
-==== Ref. Remote Shell Commands ====+\\ 
 +==== Fabric one-line Task Examples ====
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
 $ fab -H $H auth.pro -- systemctl get-default $ fab -H $H auth.pro -- systemctl get-default
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"] FHHOME=os.environ["FHHOME"]
Line 38: Line 53:
 # check.ntpsync # check.ntpsync
 #------------------------------------------------------------------ #------------------------------------------------------------------
-@task+@task 
 def ntpsync(): def ntpsync():
     sudo("which ntpq > /dev/null 2>&1 && ntpq -p")     sudo("which ntpq > /dev/null 2>&1 && ntpq -p")
Line 50: Line 65:
 @task @task
 def nmap(port, remote): def nmap(port, remote):
-    """fab auth.pro ope.nmap:22,x.x.x.x"""+    """ope.nmap:22,x.x.x.x"""
     run("nmap -Pn -sT -p %s %s " % (port, remote))     run("nmap -Pn -sT -p %s %s " % (port, remote))
  
 #------------------------------------------------------------------ #------------------------------------------------------------------
-check_ssh:localuser,key,remoteuser,remotehost+check_ssh_hostname:localuser,key,remoteuser,remotehost
 #------------------------------------------------------------------ #------------------------------------------------------------------
 @task @task
-def check_ssh(localuser, key, remoteuser, remotehost): +def check_ssh_hostname(localuser, key, remoteuser, remotehost): 
-    """ check_ssh:localuser,key,remoteuser,remotehost"""+    """ check_ssh_hostname:localuser,key,remoteuser,remotehost"""
     sudo ('su - %s -c "ssh -i %s %s@%s hostname"' % (localuser, key, remoteuser, remotehost))     sudo ('su - %s -c "ssh -i %s %s@%s hostname"' % (localuser, key, remoteuser, remotehost))
  
Line 71: Line 86:
 @task @task
 def reboot_check(): def reboot_check():
 +    """ use  %s/scripts/check_reboot.sh """
     date = datetime.now().strftime('%Y%m%d_%H%M')     date = datetime.now().strftime('%Y%m%d_%H%M')
     outfile = "check_reboot.%s"  % (date)     outfile = "check_reboot.%s"  % (date)
 + 
     run("test -d scripts || mkdir scripts")     run("test -d scripts || mkdir scripts")
     put("%s/scripts/check_reboot.sh" % FHHOME, scripts/check_reboot.sh, mode=0755)     put("%s/scripts/check_reboot.sh" % FHHOME, scripts/check_reboot.sh, mode=0755)
Line 94: Line 110:
 @task @task
 def ping_gw(): def ping_gw():
 +    """ use  %s/scripts/check_ping_gw.sh """
     run("test -d scripts || mkdir scripts")     run("test -d scripts || mkdir scripts")
-    put("%s/scripts/check_ping_gw.sh" % FHHOME, scripts/check_ping_gw.sh, mode=0755)+    put("%s/scripts/check_ping_gw.sh" % FHHOME, "scripts/check_ping_gw.sh", mode=0755)
     run("scripts/check_ping_gwt.sh")     run("scripts/check_ping_gwt.sh")
  
Line 105: 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 --no-pager |egrep "enable|disable" |sort -k 3')     sudo('systemctl list-unit-files -t service --no-pager |egrep "enable|disable" |sort -k 3')
 + 
  
 </sxh> </sxh>
Line 117: Line 135:
  
 |<100% 200px ->| |<100% 200px ->|
-| [[os:check:scripts:check_reboot.sh.html]]     | +| [[os:linux:check:scripts:check_reboot.sh.html]]     | 
-| [[os:check:scripts:check_ping_gw.sh.html]]  |   |+| [[os:linux:check:scripts:check_ping_gw.sh.html]]  |   |
  
  


os/linux/check/index.html.txt · Last modified: 2019/02/11 00:41 by kurihara