Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk script to match string and print status Post 303044177 by shanul karim on Sunday 16th of February 2020 07:16:17 AM
Old 02-16-2020
awk script to match string and print status

Dear team,

Need support to built awk script for below requirement

Input file

Code:
LOTC cluster state:
-------------------
Node safNode=SC_2_1 joined cluster | 
Node safNode=SC_2_2 joined cluster | 
Node safNode=PL_2_3 fail cluster | 

AMF cluster state:
------------------
saAmfNodeAdminState."safAmfNode=SC-1,safAmfCluster=myAmfCluster": Unlocked
saAmfNodeOperState."safAmfNode=SC-1,safAmfCluster=myAmfCluster": Enabled
saAmfNodeAdminState."safAmfNode=SC-2,safAmfCluster=myAmfCluster": locked
saAmfNodeOperState."safAmfNode=SC-1,safAmfCluster=myAmfCluster": disabled

Here from this input file need if "LOTC cluster state:" has status other than "joined" i.e fail then need to print "LOTC Cluster status is not ok"
and
if "AMF cluster state:" has status other than "unlocked and enabled" in last column than need to print "AMF cluster state: is not ok".

The number of lines in input file for both titles can vary in numbers.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print exit status in AWK

Hi all, How can I print the exit status in AWK? echo $? doesnt work for me Thanks (4 Replies)
Discussion started by: Pauline mugisha
4 Replies

2. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

3. Shell Programming and Scripting

awk to print lines based on string match on another line and condition

Hi folks, I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies

4. Shell Programming and Scripting

How to print everything after a string match

Hi all, I'm trying to do some work on the authorized_keys file to do a check if there's any information after the hash key.. At the end of the hash key's in the file, there can be an = or == Is there a way to check if anything exists after these equals and if so print it out or else print... (2 Replies)
Discussion started by: Jazmania
2 Replies

5. Shell Programming and Scripting

Print lines that match regex on xth string

Hello, I need an awk command to print only the lines that match regex on xth field from file. For example if I use this command awk -F"|" ' $22 == "20130117090000.*" 'It wont work, I think, because single quotes wont allow the usage of the metacharacter star * . On the other hand I dont know... (2 Replies)
Discussion started by: black_fender
2 Replies

6. Shell Programming and Scripting

Print string after the word match

Hi, I have the logs : cat logsx.txt 744906,{"reportingGroups":,"version":"2.0"} 678874,{"reportingGroups":,"version":"2.0"} 193571,{"reportingGroups":,"version":"2.0"} 811537,{"reportingGroups":,"version":"2.0"} 772024,{"reportingGroups":,"version":"2.0"}... (5 Replies)
Discussion started by: justbow
5 Replies

7. Shell Programming and Scripting

awk script to match and print

I need a script that will search for a string from column 1 in file A and when the string matches the last column in file B, print columns 1, 2 (file A) and columns 2, 3 (file B). input file A stringtomatch1 a stringtomatch2 a stringtomatch3 b file B junkcolumn1 printcolumn2... (4 Replies)
Discussion started by: ncwxpanther
4 Replies

8. Shell Programming and Scripting

Match string from two files and print line

Hi, I have been trying to find help with my issue and I'm thinking awk may be able to do it. I have two files eg file1.txt STRING1 230 400 0.36 STRING2 400 230 -0.13 STRING3 130 349 1 file2.txt CUFFFLINKS 1 1394 93932 . + STRING1 CUFFFLINKS ... (9 Replies)
Discussion started by: zward
9 Replies

9. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. UNIX for Beginners Questions & Answers

Search strings from a file in files in a directory recursively; then print the string with a status

Hi All, I hope somebody would be able to help me. I would need to search a string coming from a file, example file.txt: dog cat goat horse fish For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
Discussion started by: kokoro
9 Replies
clu_get_info(8) 					      System Manager's Manual						   clu_get_info(8)

NAME
clu_get_info - Gets information about a cluster and its members SYNOPSIS
/usr/sbin/clu_get_info [-full] [-q] [-m memberid] [-raw] [-state] OPTIONS
The -full option returns detailed information about all members in the cluster, or about one member if the -m memberid option is specified. Suppresses output. Use this option when only the return value is of interest; for example, to determine whether the system is running as a cluster member. When specified in combination with the -m option, the -q option can be used to determine whether a particular member of a cluster is up or down. For example: # clu_get_info -q -m 2 && echo "Member 2 is a member of the cluster" Member 2 is a member of the clus- ter The -m option returns information about the member specified by memberid. The -raw option returns detailed information about the clus- ter and all members in the cluster in raw output, which is intended to be used as input to scripts. The -state option returns the state of all members in the cluster in raw output. The states returned are: UP, DOWN, or NOT_CONF (not configured). DESCRIPTION
When invoked on a member of a cluster, the clu_get_info command displays general information about the cluster and its members. The infor- mation includes: The name of the cluster and the number of members configured in the cluster. The member ID of the member issuing the com- mand. The device name and number of votes of the quorum disk, if configured. For each member, its member ID, host name, cluster intercon- nect IP name, and current state (UP or DOWN). When invoked on a system that is not a cluster member, the clu_get_info command prints an error message and exits. The clu_get_info -full option displays additional information about the cluster. The information includes: Cluster incarnation -- A hexa- decimal number used to uniquely identify the cluster. Cluster expected votes -- Number of votes expected when all configured cluster mem- bers are up and any configured quorum disk is present. Current votes -- The number of votes contributed by current cluster members and the quorum disk as seen by this member. Quorum votes -- The number of votes required for the cluster to be up and running. The clu_get_info -full command also displays the following information for each member: Cluster interconnect IP address -- The IP address of the cluster interconnect. Member base O/S version -- The version of the base operating system. Member cluster version -- The version of the TruCluster Server software. Member running version -- The current running version of the TruCluster software, which returns one of the following: INSTALLED -- the current running version; same as the member cluster version returned. BELOW INSTALLED -- one version below the current running version returned in member cluster version; useful when performing a rolling upgrade. UNKNOWN -- the running version is unknown. Member name -- The member name used by the connection manager (CNX) as a member identifier. Node votes -- The votes assigned to this member (as set in the cluster_node_votes kernel attribute for the clubase subsystem). csid -- The cluster system identifier, which is a unique hexadecimal number that identifies each member in a cluster. The clu_get_info -raw option displays detailed information, in raw output, about all members in the cluster. This output is intended to be used as input to scripts. Data is unlabeled, and data fields are separated by colons. The fields returned are the same as if specifying the -full option only data is in raw format. The clu_get_info -raw option returns a clusterwide information record and member-specific information records. A clusterwide information record begins with the initiator C and returns data in the following order: Cluster name Number of members configured in this cluster Mem- ber ID for this member Cluster incarnation Cluster expected votes Current votes Votes required for quorum Quorum disk Quorum disk votes A member-specific information record begins with the initiator M and returns data in the following order: Member ID Host name Cluster interconnect IP name Cluster interconnect IP address Member state Member base O/S version Member cluster version Member running version Member name Member votes Csid The clu_get_info -state option displays the state of all members in the cluster. Output is intended to be used by a script to determine which cluster members are up, down, or not configured. Data is unlabeled, and data fields are separated by colons. A state information record begins with the initiator S and returns the following output based on the configuration state of all members in the cluster: UP -- The member ID is configured and up. DOWN -- The member ID is configured and down. NOT_CONF -- The member ID is not configured in the cluster. If a member of the cluster is down, clu_get_info displays UNKNOWN in various member fields. If the member is down and its /etc/rc.config file contains illegal values, clu_get_info displays CONFIGURATION_ERROR in the related fields. An example is provided in the EXAMPLES sec- tion. EXIT STATUS
Success. The system is not a cluster member or an error has occurred. EXAMPLES
The following command displays general information about the cluster and its members: # clu_get_info Cluster information for cluster deli Number of members configured in this cluster = 3 Memberid for this member = 1 Quorum disk = dsk4h Quorum disk votes = 1 Information on each cluster member Cluster memberid = 1 Hostname = polishham.zk4.com Cluster interconnect IP name = polishham-mc0 Member state = UP Cluster memberid = 2 Hostname = provolone.zk4.com Cluster interconnect IP name = provolone-mc0 Member state = UP Cluster memberid = 3 Hostname = pepicelli.zk4.com Cluster interconnect IP name = pepicelli-mc0 Member state = UP If one member of the cluster is down and its rc.config file contains illegal values, the following is displayed: Cluster memberid = 2 Hostname = CONFIGURATION_ERROR Cluster interconnect IP name = CONFIGURATION_ERROR Member state = DOWN The following command displays general information about one member: # clu_get_info -m 1 Cluster memberid = 1 Hostname = polishham.zk4.com Cluster interconnect IP name = polishham-mc0 Member state = UP The following command displays more information about all members in the cluster: # clu_get_info -full Cluster information for cluster deli Number of members configured in this cluster = 3 Memberid for this member = 1 Cluster incarnation = 0x7b5c2 Cluster expected votes = 3 Current votes = 3 Votes required for quorum = 2 Quorum disk = dsk4h Quorum disk votes = 1 Information on each cluster member Cluster memberid = 1 Hostname = polishham.zk4.com Cluster interconnect IP name = polishham-mc0 Cluster interconnect IP address = 10.0.0.1 Member state = UP Member base O/S version = Compaq Tru64 UNIX V5.0A Member cluster version = TruCluster Server V5.0A Member running version = INSTALLED Member name: polishham Member votes = 1 csid = 0x10001 Cluster memberid = 2 Hostname = provolone.zk4.com Cluster interconnect IP name = provolone-mc0 Cluster interconnect IP address = 10.0.0.2 Member state = UP Member base O/S version = Compaq Tru64 UNIX V5.0A Member cluster version = TruCluster Server V5.0A Member running version = INSTALLED Member name: provolone Member votes: 1 csid = 0x10002 Cluster memberid = 3 Hostname = pepicelli.zk4.com Cluster interconnect IP name = pepicelli-mc0 Cluster interconnect IP address = 10.0.0.3 Member state = UP Member base O/S version = Compaq Tru64 UNIX V5.0A Member cluster version = TruCluster Server V5.0A Member running version = INSTALLED Member name: pepicelli Member votes: 1 csid = 0x10003 If one member of the cluster is down and its rc.config file contains illegal values, the following is displayed: Cluster memberid = 2 Hostname = CONFIGURATION_ERROR Cluster interconnect IP name = CONFIGURATION_ERROR Cluster interconnect IP address = CONFIGURATION_ERROR Member state = DOWN Member base O/S version = CONFIGURATION_ERROR Member cluster version = CONFIGURATION_ERROR Member running version = UNKNOWN Member name = UNKNOWN Member votes = UNKNOWN csid = UNKNOWN The following command displays more information about a particular member of the cluster: # clu_get_info -full -m 1 Cluster memberid = 1 Hostname = polishham.zk4.com Cluster interconnect IP name = polishham-mc0 Cluster interconnect IP address = 10.0.0.1 Member state = UP Member base O/S version = Compaq Tru64 UNIX V5.0A Member cluster version = TruCluster Server V5.0A Member running version = INSTALLED Member name: polishham Member votes: 1 csid = 0x10001 The following command displays detailed information about all members in the cluster in raw output: # clu_get_info -raw C:deli:3:2:0x7b5c2:3:3:2:(null):0 M:1:polishham.zk4.com:polishham-mc0:10.0.0.1:UP:Compaq Tru64 UNIX V5.0A: TruCluster Server V5.0A:INSTALLED:polishham:1:0x10001 M:2:provolone.zk4.com:provolone-mc0:10.0.0.2:UP:Compaq Tru64 UNIX V5.0A: TruCluster Server V5.0A:INSTALLED:provolone:1:0x10002 M:3:pepicelli.zk4.com:pepicelli-mc0:10.0.0.3:UP:Compaq Tru64 UNIX V5.0A: TruCluster Server V5.0A:INSTALLED:pepicelli:1:0x10003 The following command displays the state of all members in the cluster: # clu_get_info -state S:NOT_CONF:UP:UP:UP:NOT_CONF:NOT_CONF:NOT_CONF:NOT_CONF FILES
Run-time configuration file for each cluster member. SEE ALSO
Functions: clu_get_info(3) Files: rc.config(8) TruCluster Server Administration Guide clu_get_info(8)
All times are GMT -4. The time now is 08:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy