Skip to content

Instantly share code, notes, and snippets.

View jjam3774's full-sized avatar

Jeffrey James jjam3774

View GitHub Profile
@jjam3774
jjam3774 / net-ssh-sudo.rb
Last active March 12, 2019 14:03
net-ssh using sudo pty sessions and regular session
#!/usr/bin/ruby
require 'rubygems'
require 'net/ssh'
user = "vagrant"
pass = "vagrant"
host = "192.168.1.120"
###
# Commands without elevated privileges
@jjam3774
jjam3774 / simple_sudo.rb
Last active November 16, 2018 20:07
NET-SSH example using sudo to execute admin commands
#!/usr/bin/ruby
require 'rubygems'
require 'net/ssh'
host = "192.168.1.120"
user = "vagrant"
pass = "vagrant"
sudo_com = %Q{
@jjam3774
jjam3774 / simple.rb
Created March 21, 2016 01:17
Simple net-ssh example
#!/usr/bin/ruby
require 'rubygems'
require 'net/ssh'
host = "192.168.1.120"
user = "vagrant"
pass = "vagrant"
commands = %Q{
@jjam3774
jjam3774 / Vagrantfile_rbenv
Created March 20, 2016 21:45
A Vagrantfile that has 4 servers public network
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@jjam3774
jjam3774 / pre_screen.rb
Last active May 17, 2017 16:47
Screening Script
#!/usr/bin/ruby
##################
# Copy files
##################
require 'fileutils'
###################
# To Generate UUID
###################
@jjam3774
jjam3774 / spwn.rb
Last active November 16, 2018 20:08
A general purpose script that allows me to automate calls to remote systems
#!/usr/bin/ruby
require 'expect'
require 'pty'
commands = %Q(
/etc/init.d/check_rep status
)
File.foreach('hosts'){|host|
puts host.strip
PTY.spawn("ssh -i nso.key #{host}"){|o,i,p|
@jjam3774
jjam3774 / grab_base_url.rb
Created November 11, 2015 22:58
This grabs the base url and then does a --force install via rpm.
#!/usr/bin/ruby
base_url = `grep baseurl /etc/yum.repos.d/service-centro.repo`.split[2]
#install_link = "#{base_url}kube_yamls-1.0-1.x86_64.rpm"
#install_link = "#{base_url}mysql_docker_build-1.0-1.x86_64.rpm"
install_link = "#{base_url}jboss_docker_build-1.0-1.x86_64.rpm"
begin
if File.exists?('/centro/target/centro-11.0.war')
@jjam3774
jjam3774 / build_war_rpm.rb
Last active April 12, 2019 21:46
This downloads files then it creates an war file and finally bundles it up in an rpm using fpm
#!/usr/bin/ruby
require 'open-uri'
puts "Downloading RPMs from Artifactory REPO!!!"
RPMS = [ "kube_yamls-1.0-1.x86_64.rpm", "mysql_docker_build-1.0-1.x86_64.rpm", "jboss_docker_build-1.0-1.x86_64.rpm", "Percona-Server-client-56-5.6.23-rel72.1.el6.x86_64.rpm", "Percona-Server-server-56-5.6.23-rel72.1.el6.x86_64.rpm", "Percona-Server-shared-56-5.6.23-rel72.1.el6.x86_64.rpm", "percona-xtrabackup-2.2.9-5067.el6.x86_64.rpm" ]
RPMS.each{|rpm|
open(rpm, 'wb') do |file|
puts "Downloading #{rpm}"
file << open("https://ccs-artifactory.com/artifactory/repo/#{rpm}").read
@jjam3774
jjam3774 / monitor_containers.rb
Created November 11, 2015 22:51
This monitors docker containers
#!/usr/bin/ruby
# chkconfig: 2345 95 20
# description: This will closely monitor the centro docker containers.
# processname: monitor_containers
e = `pgrep monitor_cont`.strip.to_i
count = 0
IO.popen('ps -ef | grep monitor_containers | grep -v grep').each{|i|
count = count.next
if count > 1
def disk_size
require 'win32ole'
###
# This Enables us to download files via the internet
###
require 'open-uri'
disk_size = nil
disk_free_space = nil
###
# Access to gwmi or wmi modules