forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk_oracle_crs
executable file
·131 lines (110 loc) · 4.85 KB
/
mk_oracle_crs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
# Reason for this no-op: shellcheck disable=... before the first command disables the error for the
# entire script.
:
# Disable unused variable error (needed to keep track of version)
# shellcheck disable=SC2034
CMK_VERSION="2.3.0b1"
# Developed by Thorsten Bruhns from OPITZ CONSULTING Deutschland GmbH
set -f
resourcefilter="^NAME=|^TYPE=|^STATE=|^TARGET=|^ENABLED="
# .--Functions-----------------------------------------------------------.
# | _____ _ _ |
# | | ___| _ _ __ ___| |_(_) ___ _ __ ___ |
# | | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
# | | _|| |_| | | | | (__| |_| | (_) | | | \__ \ |
# | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
# | |
# +----------------------------------------------------------------------+
# | |
# '----------------------------------------------------------------------'
function set_osenv() {
ostype=$(uname -s)
if [ "$ostype" = 'Linux' ]; then
ocrcfgfile=/etc/oracle/ocr.loc
olrcfgfile=/etc/oracle/olr.loc
GREP="grep"
elif [ "$ostype" = 'SunOS' ]; then
ocrcfgfile=/var/opt/oracle/ocr.loc
olrcfgfile=/var/opt/oracle/olr.loc
GREP=/usr/xpg4/bin/grep
else
ostype="unknown OS: ${ostype}"
exit 1
fi
}
function set_has_env() {
test -f ${ocrcfgfile} || exit 0
local_has_type=$($GREP "^local_only=" "$ocrcfgfile" | cut -d"=" -f2 | tr '[:lower:]' '[:upper:]')
local_has_type=${local_has_type:-"FALSE"}
if [ -f ${olrcfgfile} ]; then
has_ORACLE_HOME=$($GREP "^crs_home=" "$olrcfgfile" | cut -d"=" -f2)
else
# There is no olr.cfg in 10.2 and 11.1
# we try to get the ORA_CRS_HOME from /etc/init.d/init.cssd
local_has_type=FALSE
INITCSSD=/etc/init.d/init.cssd
if [ ! -f ${INITCSSD} ]; then
exit 0
else
has_ORACLE_HOME=$($GREP "^ORA_CRS_HOME=" ${INITCSSD} | cut -d"=" -f2-)
fi
fi
CRSCTL=${has_ORACLE_HOME}/bin/crsctl
OLSNODES=${has_ORACLE_HOME}/bin/olsnodes
CRS_STAT=${has_ORACLE_HOME}/bin/crs_stat
}
function printhasdata() {
ps -ef | $GREP -v grep | $GREP cssd.bin >/dev/null || exit 0
echo "<<<oracle_crs_version:sep(124)>>>"
$CRSCTL query has releaseversion
echo "<<<oracle_crs_res:sep(124)>>>"
OLS_NODENAME=$(uname -n)
echo "nodename|$OLS_NODENAME"
$CRSCTL stat res -f | $GREP -E $resourcefilter | sed "s/^/csslocal\|/"
}
function printcrsdata() {
ps -ef | $GREP -v grep | $GREP -e ohasd.bin -e crsd.bin >/dev/null || exit 0
echo "<<<oracle_crs_version:sep(124)>>>"
crs_version=$($CRSCTL query crs releaseversion)
echo "$crs_version"
echo "<<<oracle_crs_voting>>>"
$CRSCTL query css votedisk | $GREP "^ [0-9]"
ps -ef | $GREP -v grep | $GREP crsd.bin >/dev/null || exit 0
echo "<<<oracle_crs_res:sep(124)>>>"
OLS_NODENAME=$($OLSNODES -l)
echo "nodename|$OLS_NODENAME"
crs_version_short=$(echo "$crs_version" | cut -d"[" -f2- | cut -d"." -f-2 | sed 's/\.//')
if [ "$crs_version_short" -ge 112 ]; then
$CRSCTL stat res -v -n "$OLS_NODENAME" -init | $GREP -E "$resourcefilter" | sed "s/^/csslocal\|/"
for nodelist in $($OLSNODES); do
$CRSCTL stat res -v -n "$nodelist" | $GREP -E "$resourcefilter" | sed "s/^/$nodelist\|/"
done
else
$CRS_STAT -f -c "$OLS_NODENAME" | $GREP -E "$resourcefilter" | sed "s/^/$OLS_NODENAME\|/"
fi
}
#.
# .--Main----------------------------------------------------------------.
# | __ __ _ |
# | | \/ | __ _(_)_ __ |
# | | |\/| |/ _` | | '_ \ |
# | | | | | (_| | | | | | |
# | |_| |_|\__,_|_|_| |_| |
# | |
# +----------------------------------------------------------------------+
# | |
# '----------------------------------------------------------------------'
set_osenv
set_has_env
echo "<<<oracle_crs_res>>>"
echo "<<<oracle_crs_version>>>"
echo "<<<oracle_crs_votedisk>>>"
if [ "$local_has_type" = 'FALSE' ]; then
printcrsdata
else
printhasdata
fi