Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Investigate better parsing options for CSM APIs command line #580

Open
fpizzano opened this issue Feb 20, 2019 · 2 comments
Open

Investigate better parsing options for CSM APIs command line #580

fpizzano opened this issue Feb 20, 2019 · 2 comments

Comments

@fpizzano
Copy link
Contributor

Investigate better parsing options for CSM APIs command line.

For example:

# /opt/ibm/csm/bin/csm_allocation_query -a 10 | grep "^ -" | awk '{ printf("%s,",$2)}'
c650f02p09,c650f02p11,c650f02p13,c650f02p17
# /opt/ibm/csm/bin/csm_node_resources_query_all | grep node_name | awk '{ printf("%s,",$2)}'
c650f02p09,c650f02p11,c650f02p13,c650f02p17
@fpizzano
Copy link
Contributor Author

Adding @adambertsch @watson6282

@besawn
Copy link
Contributor

besawn commented Feb 20, 2019

Here are a couple of examples that might be useful.

Examples of regrouping items that appear in the original command output with a format like:

    keyword:                          value
    node_name:                        compute001
    node_state:                       IN_SERVICE

Extract all values matching keyword into a comma separated list:

/opt/ibm/csm/bin/csm_node_resources_query_all | egrep "node_name:" | awk '{print $2}' | paste -s -d','
c650f99p18,c650f99p26,c650f99p28,c650f99p36

Transform multi-line records into single line records, based on specific keywords, include keywords in output:

/opt/ibm/csm/bin/csm_node_resources_query_all | egrep "node_name:|node_ready:|node_state:" | paste -d' ' - - - | tr -s ' '
 node_name: c650f99p18 node_ready: y node_state: IN_SERVICE
 node_name: c650f99p26 node_ready: n node_state: OUT_OF_SERVICE
 node_name: c650f99p28 node_ready: n node_state: SOFT_FAILURE
 node_name: c650f99p36 node_ready: y node_state: IN_SERVICE

Transform multi-line records into single line records based on specific keywords, remove keywords from output:

/opt/ibm/csm/bin/csm_node_resources_query_all | egrep "node_name:|node_ready:|node_state:" | awk '{print $2}' | paste -d' ' - - - | tr -s ' '
c650f99p18 y IN_SERVICE
c650f99p26 n OUT_OF_SERVICE
c650f99p28 n SOFT_FAILURE
c650f99p36 y IN_SERVICE

Transform multi-line records into single line records based on specific keywords, remove keywords from output, comma delimited values:

/opt/ibm/csm/bin/csm_node_resources_query_all | egrep "node_name:|node_ready:|node_state:" | awk '{print $2}' | paste -d' ' - - - | tr -s ' ' ','
c650f99p18,y,IN_SERVICE
c650f99p26,n,OUT_OF_SERVICE
c650f99p28,n,SOFT_FAILURE
c650f99p36,y,IN_SERVICE

Transform multi-line records into single line records based on specific keywords, include keywords in output, filter matching records:

/opt/ibm/csm/bin/csm_node_resources_query_all | egrep "node_name:|node_ready:|node_state:" | paste -d' ' - - - | tr -s ' ' | grep "node_state: IN_SERVICE"
 node_name: c650f99p18 node_ready: y node_state: IN_SERVICE
 node_name: c650f99p36 node_ready: y node_state: IN_SERVICE

Get a comma separated list of all nodes, filtered by node_state: IN_SERVICE

/opt/ibm/csm/bin/csm_node_resources_query_all | egrep "node_name:|node_state:" | paste -d' ' - - | tr -s ' ' | grep "node_state: IN_SERVICE" | awk '{print $2}' | paste -s -d','
c650f99p18,c650f99p36

@NickyDaB NickyDaB added this to the CSM 1.6 milestone Feb 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants