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:linux:net:index.html



This is an old revision of the document!


Top#OS Management

Network Configuration (net.py)

$FHHOME/fabfile/net.py


Operation

$ fab -l |grep net

$ H=test-server-01,test-server-02

# Interface's IP
$ fab -H $H auth.pro -- "ip a |grep inet"

# Bonding
$ fab -H $H auth.pro -- egrep -i "mode|currently|status|count"  /proc/net/bonding/bond*

# Routing
$ fab -H $H auth.pro -- netstat -rn
$ fab -H $H auth.pro -- cat /etc/sysconfig/static-route

# nmap
$ fab -H $H auth.pro -- sudo nmap -Pn -sT -p 22 xx.xx.xx.xx

# tcpdump
$ fab -H $H auth.pro -- sudo tcpdump  udp port 53 -i any  -W1 -G60
$ fab -H $H auth.pro -- sudo tcpdump -n not arp and not port 123 and not port 22  -W1 -G60

# DNS
$ fab -H $H auth.pro -- cat /etc/resolv.conf
$ fab -H $H auth.pro -- host google.com
$ fab -H $H auth.pro -- host test-server-01
$ fab -H $H auth.pro -- host x.x.x.x


net.py

$FHHOME/fabfile/net.py

import sys, os
from fabric.api import *
from fabric.contrib import files

FHHOME=os.environ["FHHOME"]

# net.backup_config
@task
def backup_config():
    date = datetime.now().strftime('%Y%m%d_%H%M')
    run("test -d /tmp/nwconf_%s || mkdir /tmp/nwconf_%s" % date)
    # RHEL/CentOS
    run("/usr/bin/cp -f /etc/sysconfig/network-scripts/ifcfg* /tmp/nwconf_%s/" % date)
    # Debian/Ubuntu
    run("/usr/bin/cp -f /etc/network/interfaces /tmp/nwconf_%s/" % date)
    run("/usr/bin/cp -f /etc/sysconfig/static-routes /tmp/nwconf_%s/" % date)


Configuration



os/linux/net/index.html.1514912525.txt.gz ยท Last modified: 2018/01/03 02:02 by kurihara