Useful tool for sniffing DHCP Server on specified Interface
python dhcpd_detector.py [--config <filename>.cfg]
| module Gem | |
| class << self | |
| ## | |
| # Returns full path of previous but one directory of dir in path | |
| # E.g. for '/usr/share/ruby', 'ruby', it returns '/usr' | |
| def previous_but_one_dir_to(path, dir) | |
| split_path = path.split(File::SEPARATOR) | |
| File.join(split_path.take_while { |one_dir| one_dir !~ /^#{dir}$/ }[0..-2]) |
| # config/deploy.rb | |
| namespace :deploy do | |
| desc "check local vendor/cache" | |
| task :bundled_package do | |
| run_locally do | |
| unless test "[[ -d #{File.expand_path("../../vendor/cache", __FILE__)} ]]" | |
| error "please `bundle package --all` first!" | |
| raise StandardError | |
| end |
| default["ops-oob"]["rbenv_tar"] = "rbenv_6u2.tar.gz" |
| PREFIX="/usr/local" | |
| RBENV_PREFIX="$PREFIX/rbenv" | |
| BIN_PATH="$PREFIX/bin" | |
| RBENV_GROUP="rbenv" | |
| umask 002 | |
| ## Install rbenv, ruby-build and rbenv-gem-rehash | |
| git clone git://github.com/sstephenson/rbenv.git $RBENV_PREFIX |
| namespace :deploy do | |
| ## set max_hosts 20 or via env | |
| set :max_hosts, ENV['MAXHOSTS'] || 20 | |
| ## set max_hosts on update_code | |
| task :update_code, :except => { :no_release => true }, :max_hosts => "#{max_hosts}" do | |
| logger.info "\e[0;31;1mNOTICE:\e[0m Pulling repo from #{repository}: max_hosts => '#{max_hosts}'" | |
| on_rollback { run "rm -rf #{release_path}; true" } | |
| strategy.deploy! | |
| finalize_update |
| #!/usr/bin/env python | |
| # coding: UTF-8 | |
| import re | |
| import time | |
| DHCPD_LEASES_FILE="/var/lib/dhcpd/dhcpd.leases" | |
| # read dhcpd_leases file and match all ip,mac pair, and convert to dict type to store | |
| dhcp_leases = open(DHCPD_LEASES_FILE,"r").read() |
| # -*- encoding : utf-8 -*- | |
| ## | |
| # Apple 类, 只有一个属性, 叫做重量 (@weight) | |
| # Apple 还有一个类属性, 叫做苹果数量 (@@count) | |
| class Apple | |
| @@count = 0 | |
| ## | |
| # 我是类方法, 直接在 Apple 上面调用我就行了 | |
| def self.count |
| plugins: | |
| sitemap_generator: # all optional | |
| file_name: sitemap.xml | |
| exclude_id: | |
| - search.html | |
| - pages.html | |
| change_frequency_custom_name: changefreq | |
| priority_custom_variable_name: priority |
| require 'optparse' | |
| options = {} | |
| OptionParser.new do |opts| | |
| opts.banner = "Usage: #{$0} -r JID -m content" | |
| opts.on('-m', '--message MESSAGE','Message to be sent') do |m| | |
| options[:message] = m | |
| end |