linuxtricks
IS-IT--Management
hello all
I have a command the shows me the status of two nodes in an active high availability cluster:
[root@box root]# rsfcli -v list
node1:
service stopped auto unblocked
node2:
service running auto unblocked
The output of the 'rsfcli -v list' command above shows that node2 is 'running' the service.
I'd like to be able to display the output of a command on a website to show (at any given moment) which of the two nodes above is 'running'. But, I would like to ONLY display the Node name by itself - along with my own webcode (HTML or php).
i.e.
Currently, "node2" is the active node in the cluster.
I am doing the following to try and achieve this:
[root@box root]# rsfcli -v list | grep -B 1 running | awk '{print $1}'
node2:
service
In the above, I am grepping for the word 'running' and including the line above the result (-B 1) which shows the node name (what I want only), then printing out the results using awk by printing only the column and leaving out the rest of the line that the grep command would normally include.
As you see, awk is extracting the entire 1st column (which exludes the rest of the line that the grep command would normally include - nice) but, it also includes the word 'service'.
Maybe there is another command I should be using in place of awk... but, I'm not sure what that is.
Thanks in advance for your help!
---
Try not. Do. Or do not. There is no try.
I have a command the shows me the status of two nodes in an active high availability cluster:
[root@box root]# rsfcli -v list
node1:
service stopped auto unblocked
node2:
service running auto unblocked
The output of the 'rsfcli -v list' command above shows that node2 is 'running' the service.
I'd like to be able to display the output of a command on a website to show (at any given moment) which of the two nodes above is 'running'. But, I would like to ONLY display the Node name by itself - along with my own webcode (HTML or php).
i.e.
Currently, "node2" is the active node in the cluster.
I am doing the following to try and achieve this:
[root@box root]# rsfcli -v list | grep -B 1 running | awk '{print $1}'
node2:
service
In the above, I am grepping for the word 'running' and including the line above the result (-B 1) which shows the node name (what I want only), then printing out the results using awk by printing only the column and leaving out the rest of the line that the grep command would normally include.
As you see, awk is extracting the entire 1st column (which exludes the rest of the line that the grep command would normally include - nice) but, it also includes the word 'service'.
Maybe there is another command I should be using in place of awk... but, I'm not sure what that is.
Thanks in advance for your help!
---
Try not. Do. Or do not. There is no try.