FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

os:info:index.html



This is an old revision of the document!


Top#OS Management

Check OS Information

Operation

$ fab -l |grep osinfo.

$ echo x.x.x.x | fab auth.pro  osinfo.systeminfo


osinfo.py

import sys
from fabric.api import *
from fabric.contrib import files
from datetime import datetime

FHHOME=os.environ["FHHOME"]

#------------------------------------------------------------------
#systeminfo
#------------------------------------------------------------------
@task
def systeminfo():
    hostname = run("hostname")
    date = datetime.now().strftime('%Y%m%d_%H%M')
    yearmonth = datetime.now().strftime('%Y%m')
    outfile = systeminfo.%s.%s"  % (hostname date)

    local("test -d output/%s || mkdir output/%s"    % (yearmonth yearmonth))
    run("test -d scripts || mkdir scripts")

    put("%s/scripts/systeminfo.sh", "scripts/systeminfo.sh, mode=0755 % FHHOME)
    sudo("scripts/systeminfo.sh 1>output/%s  2>/dev/null"   % (outfile))
    get("output/%s", "output/%s/%s"  % (outfile yearmonth outfile))


#------------------------------------------------------------------
# check_reboot
#------------------------------------------------------------------
@task
def check_reboot():
    date = datetime.now().strftime('%Y%m%d_%H%M')
    outfile = check_reboot.%s"  % (date)

    run("test -d scripts || mkdir scripts")
    put("%s/scripts/check_reboot.sh", "scripts/check_reboot.sh, mode=0755 % FHHOME)
    sudo("scripts/check_reboot.sh 1>output/%s  2>/dev/null"   % (outfile))


#------------------------------------------------------------------
# check_reboot_diff
#------------------------------------------------------------------
@task
def check_reboot_diff():
    file1=run("ls -tr1 output/check_reboot.2* |tail -n 2 |head -n 1")
    file2=run("ls -tr1 output/check_reboot.2* |tail -n 1")
    run("sdiff -s -w 200 %s %s" % (file1 file2)


Scripts



os/info/index.html.1512576827.txt.gz ยท Last modified: 2017/12/07 01:13 by kurihara