{"id":784,"date":"2011-04-01T06:31:27","date_gmt":"2011-04-01T11:31:27","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=784"},"modified":"2017-06-23T13:56:25","modified_gmt":"2017-06-23T18:56:25","slug":"format-output-of-crsctl-status-for-rac-11gr2","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2011\/04\/01\/format-output-of-crsctl-status-for-rac-11gr2\/","title":{"rendered":"Format output of crsctl status for RAC 11gR2 (and now 12c)"},"content":{"rendered":"<p>crs_stat -t in 10g was great because you could just print it out and grep for OFFLINE or UNKNOWN to determine if there was a problem.\u00a0 11g deprecated the use of crs_stat -t.\u00a0 It&#8217;s not just that you shouldn&#8217;t use it because it will be removed in a future release, it also will print OFFLINE for some components that will never be ONLINE.<\/p>\n<p>As such, I wrote the following to print a format for 11g crsctl that will show it to you in a &#8220;greppable&#8221; format \ud83d\ude42<\/p>\n<pre lang=\"text\" line=\"1\">\r\n#!\/bin\/sh\r\n\r\nCRS_HOME=\/u01\/app\/11.2.0\/grid\r\n\r\nawk 'BEGIN {printf \"%-45s %-10s %-15s %-12s %-16s\\n\", \"NAME\", \"TARGET\", \"STATE\", \"SERVER\", \"STATE_DETAILS\"}'\r\nawk 'BEGIN {printf \"%-45s %-10s %-15s %-12s %-16s\\n\", \"-------------------------\", \"----------\", \"----------\", \"------------\", \"------------------\"}'\r\n$CRS_HOME\/bin\/crsctl stat res -t \\\r\n  | awk -v t=\"$t\" '$0 !~ \"----\" && $0 !~ \"TARGET\" && $0 !~ \"Cluster Resources\" && $0 !~ \"Local Resources\" \\\r\n      {\r\n        if (NF == 1) {\\\r\n          rs=$0\\\r\n        } \\\r\n        else { \\\r\n          if ($1 ~ \"^[0-9]\") { \\\r\n            if ($0 ~ \"Shutdown\" || (rs ~ \"svc$\" && $3 == \"OFFLINE\" )) { \\\r\n              l = \"$CRS_HOME\/olsnodes -n\"\r\n              cmd[NR] = l\r\n              while (l | getline line) {\r\n                split(line,r,\" \")\r\n                if (r[2] == $1) {\r\n                  NODE = r[1]\r\n                }\r\n              }\r\n              printf \"%-45s %-10s %-15s %-12s %s %s\\n\", rs, $2, $3, NODE, $4, $5, \"\", $6, $7 \\\r\n            } \\\r\n            else { \\\r\n              printf \"%-45s %-10s %-15s %-12s %s %s\\n\", rs, $2, $3, $4, $5, $6, $7 \\\r\n            } \\\r\n          } \\\r\n          else { \\\r\n            printf \"%-45s %-10s %-15s %-12s %s %s\\n\", rs, $1, $2, $3, $4, $5, $6, $7 \\\r\n          } \\\r\n        } \\\r\n      }'\r\n<\/pre>\n<p>This will produce output such as below&#8230;<\/p>\n<pre lang=\"text\">\r\nNAME                           TARGET     STATE           SERVER       STATE_DETAILS\r\n-------------------------      ---------- ----------      ------------ ------------------\r\nora.ISCSI.dg                   ONLINE     ONLINE          dell11gr1\r\nora.ISCSI.dg                   ONLINE     ONLINE          dell11gr2\r\nora.LISTENER.lsnr              ONLINE     ONLINE          dell11gr1\r\nora.LISTENER.lsnr              ONLINE     ONLINE          dell11gr2\r\nora.asm                        ONLINE     ONLINE          dell11gr1    Started\r\nora.asm                        ONLINE     ONLINE          dell11gr2    Started\r\nora.gsd                        ONLINE     ONLINE          dell11gr1\r\nora.gsd                        ONLINE     ONLINE          dell11gr2\r\nora.net1.network               ONLINE     ONLINE          dell11gr1\r\nora.net1.network               ONLINE     ONLINE          dell11gr2\r\nora.ons                        ONLINE     ONLINE          dell11gr1\r\nora.ons                        ONLINE     ONLINE          dell11gr2\r\nora.LISTENER_SCAN1.lsnr        ONLINE     ONLINE          dell11gr2\r\nora.LISTENER_SCAN2.lsnr        ONLINE     ONLINE          dell11gr1\r\nora.LISTENER_SCAN3.lsnr        ONLINE     ONLINE          dell11gr2\r\nora.apptest.batch.svc          ONLINE     ONLINE          dell11gr2\r\nora.apptest.db                 ONLINE     ONLINE          dell11gr1    Open\r\nora.apptest.db                 ONLINE     ONLINE          dell11gr2    Open\r\nora.apptest.online.svc         ONLINE     ONLINE          dell11gr1\r\nora.cvu                        ONLINE     ONLINE          dell11gr2\r\nora.dell11gr1.vip              ONLINE     ONLINE          dell11gr1\r\nora.dell11gr2.vip              ONLINE     ONLINE          dell11gr2\r\nora.oc4j                       ONLINE     ONLINE          dell11gr2\r\nora.scan1.vip                  ONLINE     ONLINE          dell11gr2\r\nora.scan2.vip                  ONLINE     ONLINE          dell11gr1\r\nora.scan3.vip                  ONLINE     ONLINE          dell11gr2\r\n<\/pre>\n<p>UPDATE: 2017\/06\/23<\/p>\n<p>This reflects the format for 12c<\/p>\n<pre lang=\"text\" line=\"1\">\r\n#!\/bin\/sh\r\n\r\nCRS_HOME=\/u01\/app\/12.1.0.2\/grid\r\n\r\n$CRS_HOME\/bin\/crsctl stat res -t \\\r\n  | awk -v t=\"$t\" '$0 !~ \"Cluster Resources\" && $0 !~ \"Local Resources\" \\\r\n      { \\\r\n        if ($0 ~ \"Name\") { \\\r\n          printf \"%-45s %-10s %-15s %-14s %s %s\\n\", $1, $2, $3, $4, $5, $6\r\n          while (++k <= 120) { \\\r\n            printf(\"-\") \\\r\n          } \\\r\n          printf (\"\\n\") \\\r\n        } \\\r\n        if (NF == 1) {\\\r\n          rs=$0 \\\r\n        } \\\r\n        else if (NR != 2) { \\\r\n          if ($1 ~ \"^[0-9]\") { \\\r\n            if ($0 ~ \"Shutdown\" || (rs ~ \"svc$\" &#038;&#038; $3 == \"OFFLINE\" )) { \\\r\n              l = \"$CRS_HOME\/olsnodes -n\"\r\n              cmd[NR] = l\r\n              while (l | getline line) {\r\n                split(line,r,\" \")\r\n                if (r[2] == $1) {\r\n                  NODE = r[1]\r\n                }\r\n              }\r\n              printf \"%-45s %-10s %-15s %-14s %s %s\\n\", rs, $2, $3, NODE, $4, $5, \"\", $6, $7 \\\r\n            } \\\r\n            else { \\\r\n              printf \"%-45s %-10s %-15s %-14s %s %s\\n\", rs, $2, $3, $4, $5, $6, $7 \\\r\n            } \\\r\n          } \\\r\n          else { \\\r\n            printf \"%-45s %-10s %-15s %-14s %s %s\\n\", rs, $1, $2, $3, $4, $5, $6, $7 \\\r\n          } \\\r\n        } \\\r\n      }'\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>crs_stat -t in 10g was great because you could just print it out and grep for OFFLINE or UNKNOWN to determine if there was a problem.\u00a0 11g deprecated the use of crs_stat -t.\u00a0 It&#8217;s not just that you shouldn&#8217;t use&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2011\/04\/01\/format-output-of-crsctl-status-for-rac-11gr2\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,22],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/784"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":23,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":6365,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/784\/revisions\/6365"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}