clx
clx copied to clipboard
clx is a simple cluster management tool
clx
Overview
clx is a simple cluster management tool.
- divide many hosts into groups
- run commands when taking part in a group
- run commands when leaving from a group
- run same command on all hosts who belong to a group
Quick Start
gem build clx.gemspec
gem install clx-*.gem
clx-agent -r ./example &
clx search
clx ip=127.0.0.1 group +test
clx group
clx group=test run df -h
clx group=test do scp ./clx.gemspec [[ip]]:/tmp/
Installation
Following libraries are required to use clx:
- gcc
- ruby >= 1.8.7 (with openssl support)
- rubygems
- msgpack gem
- rev gem
Use rubygems to install clx:
gem build clx.gemspec
gem install clx-*.gem
Usage
Configure Agent
Create module directory like /etc/clx and put modules into the directory:
mkdir /etc/clx
cp ./example/group.rb /etc/clx/
Module is a ruby script. See ./example/group.rb for example:
# execute `svc -u myservice` command when
# this host takes part in 'mygroup' group
on "+mygroup" do
`svc -u myservice 2>&1`
end
# execute `svc -d myservice` command when
# this host leaves from 'mygroup' group
on "-mygroup" do
`svc -d myservice 2>&1`
end
See other modules in ./mod/ directory for reference ;-)
Run Agent
# clx-agent -r /etc/clx &
Use Client
Usage: clx [key=match ...] <command> [args...]
Run clx search first to find agents.
clx search
A command is executed on hosts that matches key=match ... options. Key is one of following:
ip IP address of the host. Range match (like 192.168.0.[[1-10]]) is also supported.
host Host name of the host.
group Group name that the host parts in.
Command is one of following:
group show the groups that the hosts parts in.
group +NAME make the host part in the NAME group.
group -NAME make the host leave from the NAME group.
run COMMAND ARGS ... run the COMMAND with ARGS on the host.
do COMMAND ARGS ... run the COMMAND with ARGS on this host for the hosts. Arugments surrounded with [[ ]] like [[ip]] are replaced for the host.
Example
clx ip=192.168.0.[[1-10] group +a
clx ip=192.168.0.[[11-20] group +b
clx group=a run uptime
clx group=b run df -h
do command
clx group=a do echo [[ip]]
clx do scp ./deploy.it [[ip]]:/tmp/
opt module
[ ]$ clx ip=192.168.0.[[10-20]] setopt mykey myvalue
[on 192.16.0.10]$ clx-opt mykey #=> myvalue
License
Copyright (C) 2009 FURUHASHI Sadayuki
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
See also NOTICE file.