2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Fix to remove evals

This commit is contained in:
K.Cima 2016-11-29 14:24:59 +09:00
parent 289b99d401
commit 69f98e7f7b

View File

@ -96,7 +96,7 @@ module=$( basename "$0" | sed -e 's/^.*_//' )
# Graph settings # Graph settings
declare -A global_attrs # required declare -A global_attrs # required
declare -A data_attrs # required (format: field type draw 'label') declare -A data_attrs # required (format: field type draw label)
declare -A getfield_func # optional declare -A getfield_func # optional
declare -A getvalue_func # required declare -A getvalue_func # required
@ -109,9 +109,9 @@ global_attrs[$key]="
graph_info Oracle Sysstat Execute Count graph_info Oracle Sysstat Execute Count
" "
data_attrs[$key]=" data_attrs[$key]="
execute_count DERIVE LINE 'execute count' execute_count DERIVE LINE execute count
user_calls DERIVE LINE 'user calls' user_calls DERIVE LINE user calls
recursive_calls DERIVE LINE 'recursive calls' recursive_calls DERIVE LINE recursive calls
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -124,10 +124,10 @@ global_attrs[$key]="
graph_info Oracle Sysstat Parse Count graph_info Oracle Sysstat Parse Count
" "
data_attrs[$key]=" data_attrs[$key]="
parse_count_total DERIVE LINE 'parse count (total)' parse_count_total DERIVE LINE parse count (total)
parse_count_hard DERIVE LINE 'parse count (hard)' parse_count_hard DERIVE LINE parse count (hard)
parse_count_failures DERIVE LINE 'parse count (failures)' parse_count_failures DERIVE LINE parse count (failures)
parse_count_describe DERIVE LINE 'parse count (describe)' parse_count_describe DERIVE LINE parse count (describe)
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -140,8 +140,8 @@ global_attrs[$key]="
graph_info Oracle Sysstat Table Scans graph_info Oracle Sysstat Table Scans
" "
data_attrs[$key]=" data_attrs[$key]="
table_fetch_by_rowid DERIVE LINE 'table fetch by rowid' table_fetch_by_rowid DERIVE LINE table fetch by rowid
table_scan_rows_gotten DERIVE LINE 'table scan rows gotten' table_scan_rows_gotten DERIVE LINE table scan rows gotten
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -154,8 +154,8 @@ global_attrs[$key]="
graph_info Oracle Sysstat Table Scans graph_info Oracle Sysstat Table Scans
" "
data_attrs[$key]=" data_attrs[$key]="
table_scans_short_tables DERIVE LINE 'table scans (short tables)' table_scans_short_tables DERIVE LINE table scans (short tables)
table_scans_long_tables DERIVE LINE 'table scans (long tables)' table_scans_long_tables DERIVE LINE table scans (long tables)
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -168,8 +168,8 @@ global_attrs[$key]="
graph_info Oracle Sysstat Transactions graph_info Oracle Sysstat Transactions
" "
data_attrs[$key]=" data_attrs[$key]="
user_commits DERIVE LINE 'user commits' user_commits DERIVE LINE user commits
user_rollbacks DERIVE LINE 'user rollbacks' user_rollbacks DERIVE LINE user rollbacks
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -182,8 +182,8 @@ global_attrs[$key]="
graph_info Oracle Sysstat - Sorts graph_info Oracle Sysstat - Sorts
" "
data_attrs[$key]=" data_attrs[$key]="
sorts_memory DERIVE LINE 'sorts (memory)' sorts_memory DERIVE LINE sorts (memory)
sorts_disk DERIVE LINE 'sorts (disk)' sorts_disk DERIVE LINE sorts (disk)
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -196,7 +196,7 @@ global_attrs[$key]="
graph_info Oracle Sysstat Open Cursors graph_info Oracle Sysstat Open Cursors
" "
data_attrs[$key]=" data_attrs[$key]="
open_cursor GAUGE LINE 'opened cursors current' open_cursor GAUGE LINE opened cursors current
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -209,12 +209,12 @@ global_attrs[$key]="
graph_info Oracle Sysstat Enqueues graph_info Oracle Sysstat Enqueues
" "
data_attrs[$key]=" data_attrs[$key]="
enqueue_requests DERIVE LINE 'enqueue requests' enqueue_requests DERIVE LINE enqueue requests
enqueue_releases DERIVE LINE 'enqueue releases' enqueue_releases DERIVE LINE enqueue releases
enqueue_conversions DERIVE LINE 'enqueue conversions' enqueue_conversions DERIVE LINE enqueue conversions
enqueue_waits DERIVE LINE 'enqueue waits' enqueue_waits DERIVE LINE enqueue waits
enqueue_timeouts DERIVE LINE 'enqueue timeouts' enqueue_timeouts DERIVE LINE enqueue timeouts
enqueue_deadlocks DERIVE LINE 'enqueue deadlocks' enqueue_deadlocks DERIVE LINE enqueue deadlocks
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -227,9 +227,9 @@ global_attrs[$key]="
graph_info Oracle Sysstat Redo Log graph_info Oracle Sysstat Redo Log
" "
data_attrs[$key]=" data_attrs[$key]="
redo_entries DERIVE LINE 'redo entries' redo_entries DERIVE LINE redo entries
redo_buffer_allocation_retries DERIVE LINE 'redo buffer allocation retries' redo_buffer_allocation_retries DERIVE LINE redo buffer allocation retries
redo_log_space_requests DERIVE LINE 'redo log space requests' redo_log_space_requests DERIVE LINE redo log space requests
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -242,12 +242,12 @@ global_attrs[$key]="
graph_info Oracle Sysstat Physical I/O Requests graph_info Oracle Sysstat Physical I/O Requests
" "
data_attrs[$key]=" data_attrs[$key]="
physical_read_total DERIVE LINE2 'physical read total IO requests' physical_read_total DERIVE LINE2 physical read total IO requests
physical_read DERIVE LINE 'physical read IO requests' physical_read DERIVE LINE physical read IO requests
physical_read_total_multi DERIVE LINE 'physical read total multi block requests' physical_read_total_multi DERIVE LINE physical read total multi block requests
physical_write_total DERIVE LINE2 'physical write total IO requests' physical_write_total DERIVE LINE2 physical write total IO requests
physical_write DERIVE LINE 'physical write IO requests' physical_write DERIVE LINE physical write IO requests
physical_write_total_multi DERIVE LINE 'physical write total multi block requests' physical_write_total_multi DERIVE LINE physical write total multi block requests
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -260,10 +260,10 @@ global_attrs[$key]="
graph_info Oracle Sysstat Physical Read/Write Bytes graph_info Oracle Sysstat Physical Read/Write Bytes
" "
data_attrs[$key]=" data_attrs[$key]="
physical_read_total DERIVE LINE2 'physical read total bytes' physical_read_total DERIVE LINE2 physical read total bytes
physical_read DERIVE LINE 'physical read bytes' physical_read DERIVE LINE physical read bytes
physical_write_total DERIVE LINE2 'physical write total bytes' physical_write_total DERIVE LINE2 physical write total bytes
physical_write DERIVE LINE 'physical write bytes' physical_write DERIVE LINE physical write bytes
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -276,10 +276,10 @@ global_attrs[$key]="
graph_info Oracle Sysstat Network Send/Receive Bytes graph_info Oracle Sysstat Network Send/Receive Bytes
" "
data_attrs[$key]=" data_attrs[$key]="
bytes_sent_via_sql_net_to_client DERIVE LINE 'bytes sent via SQL*Net to client' bytes_sent_via_sql_net_to_client DERIVE LINE bytes sent via SQL*Net to client
bytes_received_via_sql_net_from_client DERIVE LINE 'bytes received via SQL*Net from client' bytes_received_via_sql_net_from_client DERIVE LINE bytes received via SQL*Net from client
bytes_sent_via_sql_net_to_dblink DERIVE LINE 'bytes sent via SQL*Net to dblink' bytes_sent_via_sql_net_to_dblink DERIVE LINE bytes sent via SQL*Net to dblink
bytes_received_via_sql_net_from_dblink DERIVE LINE 'bytes received via SQL*Net from dblink' bytes_received_via_sql_net_from_dblink DERIVE LINE bytes received via SQL*Net from dblink
" "
getvalue_func[$key]=getvalue_sysstat getvalue_func[$key]=getvalue_sysstat
@ -292,16 +292,16 @@ global_attrs[$key]="
graph_info Oracle Memory SGA graph_info Oracle Memory SGA
" "
data_attrs[$key]=" data_attrs[$key]="
maximum_sga_size GAUGE LINE 'Maximum SGA Size' maximum_sga_size GAUGE LINE Maximum SGA Size
fixed_sga_size GAUGE AREASTACK 'Fixed SGA Size' fixed_sga_size GAUGE AREASTACK Fixed SGA Size
redo_buffers GAUGE AREASTACK 'Redo Buffers' redo_buffers GAUGE AREASTACK Redo Buffers
shared_pool_size GAUGE AREASTACK 'Shared Pool Size' shared_pool_size GAUGE AREASTACK Shared Pool Size
large_pool_size GAUGE AREASTACK 'Large Pool Size' large_pool_size GAUGE AREASTACK Large Pool Size
java_pool_size GAUGE AREASTACK 'Java Pool Size' java_pool_size GAUGE AREASTACK Java Pool Size
streams_pool_size GAUGE AREASTACK 'Streams Pool Size' streams_pool_size GAUGE AREASTACK Streams Pool Size
shared_io_pool_size GAUGE AREASTACK 'Shared IO Pool Size' shared_io_pool_size GAUGE AREASTACK Shared IO Pool Size
buffer_cache_size GAUGE AREASTACK 'Buffer Cache Size' buffer_cache_size GAUGE AREASTACK Buffer Cache Size
in_memory_area_size GAUGE AREASTACK 'In-Memory Area Size' in_memory_area_size GAUGE AREASTACK In-Memory Area Size
" "
getvalue_func[$key]=getvalue_sgainfo getvalue_func[$key]=getvalue_sgainfo
@ -314,9 +314,9 @@ global_attrs[$key]="
graph_info Oracle Memory PGA graph_info Oracle Memory PGA
" "
data_attrs[$key]=" data_attrs[$key]="
pga_target GAUGE LINE 'aggregate PGA auto target' pga_target GAUGE LINE aggregate PGA auto target
pga_allocated GAUGE LINE 'total PGA allocated' pga_allocated GAUGE LINE total PGA allocated
pga_inuse GAUGE AREA 'total PGA inuse' pga_inuse GAUGE AREA total PGA inuse
" "
getvalue_func[$key]=getvalue_pgastat getvalue_func[$key]=getvalue_pgastat
@ -330,9 +330,9 @@ global_attrs[$key]="
graph_scale no graph_scale no
" "
data_attrs[$key]=" data_attrs[$key]="
buf_hitratio GAUGE LINE 'Buffer Cache Hit Ratio' buf_hitratio GAUGE LINE Buffer Cache Hit Ratio
lib_hitratio GAUGE LINE 'Library Cache Hit Ratio' lib_hitratio GAUGE LINE Library Cache Hit Ratio
dict_hitratio GAUGE LINE 'Dictionary Cache Hit Ratio' dict_hitratio GAUGE LINE Dictionary Cache Hit Ratio
" "
getvalue_func[$key]=getvalue_cachehit getvalue_func[$key]=getvalue_cachehit
@ -381,8 +381,8 @@ global_attrs[$key]="
graph_info Oracle Wait Events Application graph_info Oracle Wait Events Application
" "
data_attrs[$key]="" data_attrs[$key]=""
getfield_func[$key]='getfield_eventwait2 Application' getfield_func[$key]="getfield_eventwait2 Application"
getvalue_func[$key]='getvalue_eventwait2 Application' getvalue_func[$key]="getvalue_eventwait2 Application"
key=eventwaitconcurrency key=eventwaitconcurrency
global_attrs[$key]=" global_attrs[$key]="
@ -393,8 +393,8 @@ global_attrs[$key]="
graph_info Oracle Wait Events Concurrency graph_info Oracle Wait Events Concurrency
" "
data_attrs[$key]=" " data_attrs[$key]=" "
getfield_func[$key]='getfield_eventwait2 Concurrency' getfield_func[$key]="getfield_eventwait2 Concurrency"
getvalue_func[$key]='getvalue_eventwait2 Concurrency' getvalue_func[$key]="getvalue_eventwait2 Concurrency"
key=eventwaituserio key=eventwaituserio
global_attrs[$key]=" global_attrs[$key]="
@ -405,8 +405,8 @@ global_attrs[$key]="
graph_info Oracle Wait Events User I/O graph_info Oracle Wait Events User I/O
" "
data_attrs[$key]="" data_attrs[$key]=""
getfield_func[$key]='getfield_eventwait2 "User I/O"' getfield_func[$key]="getfield_eventwait2 User I/O"
getvalue_func[$key]='getvalue_eventwait2 "User I/O"' getvalue_func[$key]="getvalue_eventwait2 User I/O"
key=eventwaitsystemio key=eventwaitsystemio
global_attrs[$key]=" global_attrs[$key]="
@ -418,8 +418,8 @@ global_attrs[$key]="
" "
data_attrs[$key]=" data_attrs[$key]="
" "
getfield_func[$key]='getfield_eventwait2 "System I/O"' getfield_func[$key]="getfield_eventwait2 System I/O"
getvalue_func[$key]='getvalue_eventwait2 "System I/O"' getvalue_func[$key]="getvalue_eventwait2 System I/O"
key=eventwaitcluster key=eventwaitcluster
global_attrs[$key]=" global_attrs[$key]="
@ -430,8 +430,8 @@ global_attrs[$key]="
graph_info Oracle Wait Events Cluster graph_info Oracle Wait Events Cluster
" "
data_attrs[$key]=" " data_attrs[$key]=" "
getfield_func[$key]='getfield_eventwait2 Cluster' getfield_func[$key]="getfield_eventwait2 Cluster"
getvalue_func[$key]='getvalue_eventwait2 Cluster' getvalue_func[$key]="getvalue_eventwait2 Cluster"
key=tablespace key=tablespace
global_attrs[$key]=" global_attrs[$key]="
@ -492,53 +492,44 @@ config() {
sed -e 's/^ *//' -e '/^$/d' <<< "${global_attrs[$module]}" sed -e 's/^ *//' -e '/^$/d' <<< "${global_attrs[$module]}"
# print data source attributes # print data source attributes
local line t fields field type draw label # split line into field,type,draw,label
while IFS= read -r line local fields field type draw label
while read -r field type draw label
do do
# split line into field,type,draw,label
# eval looks necessary to preserve whitespaces
eval "t=( ${line} )"
field="${t[0]}"
[ -z "$field" ] && continue [ -z "$field" ] && continue
fields+=( $field ) fields="${fields} ${field}"
type="${t[1]}"
draw="${t[2]}"
label="${t[3]}"
echo "${field}.type" "$type" echo "${field}.type" "$type"
echo "${field}.draw" "$draw" echo "${field}.draw" "$draw"
echo "${field}.label" "$label" echo "${field}.label" "$label"
done <<< "${data_attrs[$module]}" done <<< "${data_attrs[$module]}"
echo graph_order "${fields[@]}" echo graph_order "$fields"
} }
# wrapper for getfield_* # wrapper for getfield_*
getfield() { getfield() {
local func arg
if [ -n "${getfield_func[$module]:-}" ]; then if [ -n "${getfield_func[$module]:-}" ]; then
# call getfield_* function with args if necessary # call getfield_* function with argument if necessary
# eval looks necessary if args contain whitespaces read -r func arg <<< "${getfield_func[$module]}"
eval "${getfield_func[$module]}" $func "$arg"
fi fi
} }
# wrapper for getvalue_* # wrapper for getvalue_*
getvalue() { getvalue() {
# call getvalue_* function with args if necessary local func arg
# eval looks necessary if args contain whitespaces # call getvalue_* function with argument if necessary
eval "${getvalue_func[$module]}" read -r func arg <<< "${getvalue_func[$module]}"
$func "$arg"
} }
getvalue_sysstat() { getvalue_sysstat() {
local line t field label local field type draw label
while IFS= read -r line while read -r field type draw label
do do
# split line into field,type,draw,label
# eval looks necessary to preserve whitespaces
eval "t=( ${line} )"
field="${t[0]}"
[ -z "$field" ] && continue [ -z "$field" ] && continue
label="${t[3]}"
${sqlplus} "${oracle_auth}" <<EOF ${sqlplus} "${oracle_auth}" <<EOF
${sqlplus_variables} ${sqlplus_variables}
@ -557,15 +548,10 @@ EOF
} }
getvalue_sgainfo() { getvalue_sgainfo() {
local line t field label local field type draw label
while IFS= read -r line while read -r field type draw label
do do
# split line into field,type,draw,label
# eval looks necessary to preserve whitespaces
eval "t=( ${line} )"
field="${t[0]}"
[ -z "$field" ] && continue [ -z "$field" ] && continue
label="${t[3]}"
${sqlplus} "${oracle_auth}" <<EOF ${sqlplus} "${oracle_auth}" <<EOF
${sqlplus_variables} ${sqlplus_variables}
@ -584,15 +570,10 @@ EOF
} }
getvalue_pgastat() { getvalue_pgastat() {
local line t field label local field type draw label
while IFS= read -r line while read -r field type draw label
do do
# split line into field,type,draw,label
# eval looks necessary to preserve whitespaces
eval "t=( ${line} )"
field="${t[0]}"
[ -z "$field" ] && continue [ -z "$field" ] && continue
label="${t[3]}"
${sqlplus} "${oracle_auth}" <<EOF ${sqlplus} "${oracle_auth}" <<EOF
${sqlplus_variables} ${sqlplus_variables}
@ -640,7 +621,7 @@ getfield_sessionuser() {
${sqlplus_variables} ${sqlplus_variables}
SELECT SELECT
REGEXP_REPLACE( username, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || REGEXP_REPLACE( username, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
' GAUGE LINE ' || '''' || username || '''' ' GAUGE LINE ' || username
FROM FROM
dba_users dba_users
WHERE WHERE
@ -678,7 +659,7 @@ getfield_sessionwait() {
${sqlplus_variables} ${sqlplus_variables}
SELECT SELECT
REGEXP_REPLACE( wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || REGEXP_REPLACE( wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
' GAUGE AREASTACK ' || '''' || wait_class || '''' ' GAUGE AREASTACK ' || wait_class
FROM FROM
v\$event_name v\$event_name
WHERE WHERE
@ -721,7 +702,7 @@ getfield_eventwait() {
${sqlplus_variables} ${sqlplus_variables}
SELECT SELECT
REGEXP_REPLACE( wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || REGEXP_REPLACE( wait_class, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
' DERIVE LINE ' || '''' || wait_class || '''' ' DERIVE LINE ' || wait_class
FROM FROM
v\$event_name v\$event_name
WHERE WHERE
@ -768,7 +749,7 @@ VAR vl VARCHAR2(64)
EXEC :vl := '${waitclass}' EXEC :vl := '${waitclass}'
SELECT SELECT
REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
' DERIVE LINE ' || '''' || SUBSTR( name, 1, 45 ) || '''' ' DERIVE LINE ' || SUBSTR( name, 1, 45 )
FROM FROM
v\$event_name v\$event_name
WHERE WHERE
@ -803,7 +784,7 @@ getfield_tablespace() {
${sqlplus_variables} ${sqlplus_variables}
SELECT SELECT
REGEXP_REPLACE( tablespace_name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || REGEXP_REPLACE( tablespace_name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
' GAUGE LINE ' || '''' || tablespace_name || '''' ' GAUGE LINE ' || tablespace_name
FROM FROM
dba_data_files dba_data_files
ORDER BY ORDER BY
@ -845,7 +826,7 @@ getfield_asmusage() {
${sqlplus_variables} ${sqlplus_variables}
SELECT SELECT
REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) || REGEXP_REPLACE( name, '^[^A-Za-z_]|[^A-Za-z0-9_]', '_' ) ||
' GAUGE LINE ' || '''' || name || '''' ' GAUGE LINE ' || name
FROM FROM
v\$asm_diskgroup v\$asm_diskgroup
ORDER BY ORDER BY