LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2020, 03:21 PM   #1
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
Selecting Custom parameters


Hello All,

I am migrating database from one account to another and need to get the custom parameters of the database. It looks like this

Code:
{
  "ParameterName": "tmpdir",
  "ParameterValue": "/rdsdbdata/tmp/",
  "Description": "The directory used for temporary files and temporary tables",
  "Source": "system",
  "ApplyType": "static",
  "DataType": "string",
  "IsModifiable": false,
  "ApplyMethod": "pending-reboot"
}
{
  "ParameterName": "tmp_table_size",
  "ParameterValue": "67108864",
  "Description": "If an in-memory temporary table exceeds the limit, MySQL automatically converts it to an on-disk MyISAM table. Increased value can improve perf for many advanced GROUP BY queries.",
  "Source": "user",
  "ApplyType": "dynamic",
  "DataType": "integer",
  "AllowedValues": "1024-18446744073709551615",
  "IsModifiable": true,
  "ApplyMethod": "immediate"
}
{
  "ParameterName": "transaction_alloc_block_size",
  "Description": "The amount in bytes by which to increase a per-transaction memory pool which needs memory.",
  "Source": "engine-default",
  "ApplyType": "dynamic",
  "DataType": "integer",
  "AllowedValues": "1024-18446744073709547520",
  "IsModifiable": true,
  "ApplyMethod": "pending-reboot"
}
{
  "ParameterName": "transaction_prealloc_size",
  "Description": "There is a per-transaction memory pool from which various transaction-related allocations take memory. For every allocation that cannot be satisfied from the pool because it has insufficient memory available, the pool is incremented.",
  "Source": "engine-default",
  "ApplyType": "dynamic",
  "DataType": "integer",
  "AllowedValues": "1024-18446744073709547520",
  "IsModifiable": true,
  "ApplyMethod": "pending-reboot"
}
{
  "ParameterName": "tx_isolation",
  "ParameterValue": "READ-COMMITTED",
  "Description": "Sets the default transaction isolation level.",
  "Source": "user",
  "ApplyType": "dynamic",
  "DataType": "string",
  "AllowedValues": "READ-UNCOMMITTED,READ-COMMITTED,REPEATABLE-READ,SERIALIZABLE",
  "IsModifiable": true,
  "ApplyMethod": "immediate"
}
I am only interested in ParameterName that has ParameterValues.

I have tried below but it prints columns without parameterValue, and changing || to && returns nothing
Code:
aws rds describe-db-parameters --db-parameter-group-name -perf  --output json | jq '.[] | .[]' | awk '/ParameterName/ || /ParameterValue/{print $0}'

also

Code:
aws rds describe-db-parameters --db-parameter-group-name perf --profile old --output json | jq '.[] | .[]' | grep -e 'ParameterName' -e 'ParameterValue'
produces similar results

I tried doing it all in jq
Code:
aws rds describe-db-parameters --db-parameter-group-name perf --profile old --output json | jq ".[]|.[] | select((.ParameterName > 0) && .ParameterValue)"
Can I please have some assistance?

Thank you
 
Old 02-28-2020, 08:13 PM   #2
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Original Poster
Rep: Reputation: 42
Figured out the following works

Code:
aws rds describe-db-parameters --db-parameter-group-name perf --profile old --output json | jq '.[] |.[] |select(.ParameterValue | length >= 1) | select(."IsModifiable"==true)'
Isn't perfect, still would only like only
ParameterName
ParameterValue
 
Old 02-28-2020, 11:42 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
That looks like JSON, which is always rather difficult to work with. You can write a short python or perl script to deal with it. Or you can use jq followed by a sed, awk, or perl script:

Code:
jq '.ParameterName + " = " + .ParameterValue'
 
Old 02-29-2020, 03:53 AM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,794

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
If the order is fixed then you can pipe to
Code:
grep -B1 '"ParameterValue":'
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
edit a file /etc/fstab , what parameters can be changebale and which parameters lenin99 Debian 7 01-24-2017 04:03 AM
[SOLVED] Why there are two separate parameters in /proc/sys/net/ipv4/ for security parameters gprathap1121@gmail.com Linux - Security 4 07-14-2014 12:41 AM
[SOLVED] Custom TCP Parameters for multiple interfaces in Linux tdallagnol Linux - Newbie 4 02-16-2011 12:18 PM
bash script for selecting a parameter from list of parameters m4rtin Programming 9 12-21-2009 09:41 AM
custom geforce video card--custom module? bandofmercy Linux - Hardware 3 10-14-2004 06:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration