Projet

Général

Profil

Révision c81c20ab

IDc81c20ab3b60512ac86beaa0a0ea4dfafa76e1dd
Parent 270be2f5
Enfant cc0b0949

Ajouté par Lars Kruse il y a plus de 7 ans

unify DIRTYCONFIG handling in shell and python plugins

The following issues were fixed:
  • comparison too broad (e.g. "0" misinterpreted as "true")
  • python: comparing string with number (is never equal in python)
  • unwanted non-zero exitcode (compound command "&&" as last command in
    shell code block (e.g. "case" or "if" branch))
  • access to unset variable (shell style issue)

Voir les différences:

plugins/bind/bind9_resolver_stats
72 72

  
73 73
	# If dirty config capability is enabled then fall through
74 74
	# to output the data with the config information.
75
	if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
76
		exit 0
77
	fi
75
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
78 76
fi
79 77

  
80 78
# Output the stats.
plugins/bind/bind9_server_stats
69 69
		echo ${key}.type COUNTER
70 70
	done
71 71

  
72
        # If dirty config capability is enabled then fall through
73
        # to output the data with the config information.
74
        if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
75
                exit 0
76
        fi
72
	# If dirty config capability is enabled then fall through
73
	# to output the data with the config information.
74
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
77 75
fi
78 76

  
79 77
# Output the stats.
plugins/bind/bind9_socket_stats
67 67
		echo ${key}.type COUNTER
68 68
	done
69 69

  
70
        # If dirty config capability is enabled then fall through
71
        # to output the data with the config information.
72
        if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
73
                exit 0
74
        fi
70
	# If dirty config capability is enabled then fall through
71
	# to output the data with the config information.
72
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
75 73
fi
76 74

  
77 75
# Output the stats.
plugins/nginx/nginx_error
156 156
  config)
157 157
    do_config
158 158
    # support "dirty config" capability
159
    if [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ]; then do_fetch; fi
159
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
160 160
    ;;
161 161
  autoconf)
162 162
    do_autoconf
plugins/oracle/oracle_sysstat
1119 1119
    ;;
1120 1120
config)
1121 1121
    config
1122
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
1122
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
1123 1123
    ;;
1124 1124
*)
1125 1125
    fetch
plugins/postgresql/pgbouncer_client_connections
46 46
	        echo ${pool}.type GAUGE
47 47
	done
48 48

  
49
        # If dirty config capability is enabled then fall through
50
        # to output the data with the config information.
51
        if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
52
                exit 0
53
        fi
49
	# If dirty config capability is enabled then fall through
50
	# to output the data with the config information.
51
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
54 52
fi
55 53

  
56 54
# Output looks like this:
plugins/postgresql/pgbouncer_maxwait
46 46
	        echo ${pool}.type GAUGE
47 47
	done
48 48

  
49
        # If dirty config capability is enabled then fall through
50
        # to output the data with the config information.
51
        if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
52
                exit 0
53
        fi
49
	# If dirty config capability is enabled then fall through
50
	# to output the data with the config information.
51
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
54 52
fi
55 53

  
56 54
# Output looks like this:
plugins/postgresql/pgbouncer_server_connections
46 46
	        echo ${pool}.type GAUGE
47 47
	done
48 48

  
49
        # If dirty config capability is enabled then fall through
50
        # to output the data with the config information.
51
        if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
52
                exit 0
53
        fi
49
	# If dirty config capability is enabled then fall through
50
	# to output the data with the config information.
51
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
54 52
fi
55 53

  
56 54
# Output looks like this:
plugins/postgresql/postgresql_active_backends_by_database
73 73

  
74 74
	# If dirty config capability is enabled then fall through
75 75
	# to output the data with the config information.
76
	if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
77
		exit 0
78
	fi
76
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
79 77
fi
80 78

  
81 79
while read pool sep backends junk
plugins/solaris/forks
98 98
    ;;
99 99
config)
100 100
    config
101
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
101
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
102 102
    ;;
103 103
*)
104 104
    fetch
plugins/solaris/fsstat_act_
163 163
    ;;
164 164
config)
165 165
    config
166
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
166
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
167 167
    ;;
168 168
*)
169 169
    fetch
plugins/solaris/fsstat_bytes
160 160
    ;;
161 161
config)
162 162
    config
163
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
163
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
164 164
    ;;
165 165
*)
166 166
    fetch
plugins/solaris/interrupts
118 118
    ;;
119 119
config)
120 120
    config
121
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
121
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
122 122
    ;;
123 123
*)
124 124
    fetch
plugins/solaris/io_disk
334 334
    ;;
335 335
config)
336 336
    config
337
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
337
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
338 338
    ;;
339 339
*)
340 340
    fetch
plugins/streaming/packetship_
108 108

  
109 109
	# If dirty config capability is enabled then fall through
110 110
	# to output the data with the config information.
111
	if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
112
		exit 0
113
	fi
111
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" != "1" ]; then exit 0; fi
114 112
fi
115 113

  
116 114
# If there are no pumps then output fake pump1 data and end.
plugins/weather/openweather_
83 83
	EOF
84 84

  
85 85
	# Continue if dirty config is enabled
86
	[ "$MUNIN_CAP_DIRTYCONFIG" = 1 ] || exit 0
86
	[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] || exit 0
87 87
fi
88 88

  
89 89
TEMP_AVG=$( expr "$OWAPI" : '.*\<temperature value=\"\(.*\)\" min.*/temperature.*' )
plugins/wifi/wireless_channel_occupation_
135 135
	done
136 136
elif [ "${1:-}" = "config" ]; then
137 137
	do_config || exit 1
138
	[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
138
	if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
139 139
else
140 140
	do_fetch
141 141
fi
plugins/wifi/wireless_signal_noise_
147 147
case "$ACTION" in
148 148
	config)
149 149
		do_config || exit 1
150
		[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
150
		if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
151 151
		;;
152 152
	autoconf)
153 153
		if [ -z "$(get_wifi_interfaces)" ]; then
plugins/wifi/wireless_signal_ranges_
138 138
case "$ACTION" in
139 139
	config)
140 140
		do_config || exit 1
141
		[ "${MUNIN_CAP_DIRTYCONFIG:-0}" = 1 ] && do_fetch
141
		if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then do_fetch; fi
142 142
		;;
143 143
	autoconf)
144 144
		[ -z "$(get_wifi_interfaces)" ] && echo "no (no wifi interfaces found)" && exit 1
plugins/zfs/zfs_arcstats
351 351
    ;;
352 352
config)
353 353
    config
354
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
354
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
355 355
    ;;
356 356
*)
357 357
    fetch
plugins/zfs/zpool_capacity
257 257
    ;;
258 258
config)
259 259
    config
260
    [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
260
    if [ "${MUNIN_CAP_DIRTYCONFIG:-0}" = "1" ]; then fetch; fi
261 261
    ;;
262 262
*)
263 263
    fetch
plugins/znc/znc_logs.py
159 159
    print('graph_period minute')
160 160
    graph_order = []
161 161

  
162
    if 'MUNIN_CAP_DIRTYCONFIG' in os.environ and os.environ['MUNIN_CAP_DIRTYCONFIG'] == 1:
162
    if os.getenv('MUNIN_CAP_DIRTYCONFIG') == "1":
163 163
        read_data(1)
164 164
    else:
165 165
        read_data(0)

Formats disponibles : Unified diff