-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16419 from ailisp/compatible-to-old-app-name
some production enhancement to pg_inspector
- Loading branch information
Showing
7 changed files
with
174 additions
and
17 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
spec/tools/pg_inspector/active_connections_to_human_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
$LOAD_PATH << Rails.root.join("tools") | ||
|
||
require 'pg_inspector' | ||
|
||
describe PgInspector::ActiveConnectionsHumanYAML do | ||
it "#compress_id" do | ||
subject = described_class.new | ||
expect(subject.send(:compress_id, 5)).to eq("5") | ||
expect(subject.send(:compress_id, 1_000_000_000_005)).to eq("1r5") | ||
expect(subject.send(:compress_id, 2_000_000_000_005)).to eq("2r5") | ||
end | ||
|
||
it "#uncompress_id" do | ||
subject = described_class.new | ||
expect(subject.send(:uncompress_id, "5")).to eq(5) | ||
expect(subject.send(:uncompress_id, "1r5")).to eq(1_000_000_000_005) | ||
expect(subject.send(:uncompress_id, "2r5")).to eq(2_000_000_000_005) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
|
||
## Run pg_inspector using parameters given in local database.yml and v2 key. | ||
|
||
if __FILE__ == $PROGRAM_NAME | ||
$LOAD_PATH.push(File.expand_path(File.join(__dir__, %w(.. .. lib)))) | ||
end | ||
|
||
require 'yaml' | ||
require 'manageiq-gems-pending' | ||
require 'util/miq-password' | ||
|
||
BASE_DIR = __dir__ | ||
LOG_DIR = '/var/www/miq/vmdb/log'.freeze | ||
DATABASE_YML_FILE_PATH = "#{BASE_DIR}/../../config/database.yml".freeze | ||
V2_KEY_FILE_PATH = "#{BASE_DIR}/../../certs/v2_key".freeze | ||
|
||
production_db = YAML.load_file(DATABASE_YML_FILE_PATH)["production"] | ||
|
||
db_user = production_db["username"] | ||
db_password_encrypt = production_db["password"] | ||
db_password = MiqPassword.try_decrypt(db_password_encrypt) | ||
db_host = production_db["host"] | ||
|
||
# system "#{BASE_DIR}/../pg_inspector.rb -h" | ||
ENV['PGPASSWORD'] = db_password | ||
system("#{BASE_DIR}/../pg_inspector.rb connections -u #{db_user} -s #{db_host} -i") | ||
if File.exist?(Pathname.new(LOG_DIR).join('pg_inspector_server.yml')) | ||
puts("pg_inspector_server.yml already exists, skip generating.") | ||
else | ||
system("#{BASE_DIR}/../pg_inspector.rb servers -u #{db_user} -s #{db_host}") | ||
end | ||
system("#{BASE_DIR}/../pg_inspector.rb human") | ||
success = system("#{BASE_DIR}/../pg_inspector.rb locks") | ||
unless success | ||
exit(1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env ruby | ||
require 'bundler/setup' | ||
|
||
## Run pg_inspector servers using parameters given in local database.yml and v2 key. | ||
|
||
if __FILE__ == $PROGRAM_NAME | ||
$LOAD_PATH.push(File.expand_path(File.join(__dir__, %w(.. .. lib)))) | ||
end | ||
|
||
require 'yaml' | ||
require 'manageiq-gems-pending' | ||
require 'util/miq-password' | ||
|
||
BASE_DIR = __dir__ | ||
LOG_DIR = '/var/www/miq/vmdb/log'.freeze | ||
DATABASE_YML_FILE_PATH = "#{BASE_DIR}/../../config/database.yml".freeze | ||
V2_KEY_FILE_PATH = "#{BASE_DIR}/../../certs/v2_key".freeze | ||
|
||
production_db = YAML.load_file(DATABASE_YML_FILE_PATH)["production"] | ||
|
||
db_user = production_db["username"] | ||
db_password_encrypt = production_db["password"] | ||
db_password = MiqPassword.try_decrypt(db_password_encrypt) | ||
db_host = production_db["host"] | ||
|
||
# system "#{BASE_DIR}/../pg_inspector.rb -h" | ||
ENV['PGPASSWORD'] = db_password | ||
system("#{BASE_DIR}/../pg_inspector.rb servers -u #{db_user} -s #{db_host}") |