Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/powermta/pmta_ | ||
|---|---|---|
| 12 | 12 |
# Copyright (c) 2011, emarsys eMarketing Systems AG |
| 13 | 13 |
# All rights reserved. |
| 14 | 14 |
# |
| 15 |
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that
|
|
| 15 |
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 16 | 16 |
# the following conditions are met: |
| 17 | 17 |
# |
| 18 |
# Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
|
| 19 |
# following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
| 20 |
# of conditions and the following disclaimer in the documentation and/or other materials provided with the
|
|
| 21 |
# distribution. Neither the name of the emarsys eMarketing Systems AG nor the names of its contributors may
|
|
| 18 |
# Redistributions of source code must retain the above copyright notice, this list of conditions and the |
|
| 19 |
# following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list |
|
| 20 |
# of conditions and the following disclaimer in the documentation and/or other materials provided with the |
|
| 21 |
# distribution. Neither the name of the emarsys eMarketing Systems AG nor the names of its contributors may |
|
| 22 | 22 |
# be used to endorse or promote products derived from this software without specific prior written permission. |
| 23 | 23 |
# |
| 24 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
| 25 |
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
| 26 |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
| 27 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
| 28 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
| 29 |
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
| 24 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
| 25 |
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
| 26 |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
| 27 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
| 28 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
| 29 |
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
|
| 30 | 30 |
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | 31 |
# |
| 32 | 32 |
# |
| ... | ... | |
| 53 | 53 |
# lrwxrwxrwx 1 root root 5 2011-11-15 16:31 pmta_top_domains -> pmta_ |
| 54 | 54 |
# |
| 55 | 55 |
# o alternative multi-host configuration: |
| 56 |
# you can also link the pmta_ script to various hosts and configure munin to respond
|
|
| 56 |
# you can also link the pmta_ script to various hosts and configure munin to respond |
|
| 57 | 57 |
# to multiple REMOTEHOSTs, just link pmta_ in this schema and configure munin |
| 58 | 58 |
# accordingly - DO NOT USE DOTS IN YOUR IDENTIFIER VARIABLE, USE UNDERSCORE INSTEAD! |
| 59 | 59 |
# for example: |
| ... | ... | |
| 63 | 63 |
# lrwxrwxrwx 1 root root 5 2011-11-18 12:18 mailhost4_domain_com_pmta_top_domains -> pmta_ |
| 64 | 64 |
# [...] |
| 65 | 65 |
# |
| 66 |
# conf.:
|
|
| 66 |
# conf.: |
|
| 67 | 67 |
# [mailhost1_domain_com_pmta*] |
| 68 | 68 |
# env.REMOTEHOST somehostORip |
| 69 | 69 |
# env.PORT portnumber |
| ... | ... | |
| 91 | 91 |
fetch_xml() {
|
| 92 | 92 |
# o arg1 specifies xpath or false |
| 93 | 93 |
# o arg2 specifies sed/regex or false |
| 94 |
# o arg3 specifies category ('status', 'domains',..) or false
|
|
| 94 |
# o arg3 specifies category ('status', 'domains',..) or false
|
|
| 95 | 95 |
HTTPQUERY="GET /${3}?format=xml HTTP/1.1\n\n"
|
| 96 | 96 |
REMOTE=`echo ${HTTPQUERY} | nc -q 1 -w 5 ${REMOTEHOST} ${PORT} | tail -1`
|
| 97 | 97 |
XML_DATA=${REMOTE}
|
| 98 |
SED="s/.*<$2>\([^<]*\)<\/$2>.*/\1/p"
|
|
| 99 |
|
|
| 98 |
SED="s/.*<$2>\([^<]*\)<\/$2>.*/\1/p" |
|
| 99 |
|
|
| 100 | 100 |
if [ "$3" = "status" ]; then |
| 101 | 101 |
RET=`echo $XML_DATA | xpath -q -e $1 | sed -n $SED | cut -f1 -d '.'` |
| 102 | 102 |
elif [ "$3" = "domains" ]; then |
| 103 | 103 |
RET=`echo $XML_DATA | xpath -q -e '//domain/*[self::name or self::rcp]' | sed 's/<[^>]*>//g' | sed 's/\./_/g'` |
| 104 |
fi
|
|
| 105 |
|
|
| 104 |
fi |
|
| 105 |
|
|
| 106 | 106 |
if [ "$RET" ]; then |
| 107 | 107 |
echo $RET |
| 108 | 108 |
return 0 |
| ... | ... | |
| 122 | 122 |
CONF_TITLE="powermta ${WHAT}bound traffic"
|
| 123 | 123 |
CONF_LABEL="traffic_${WHAT}"
|
| 124 | 124 |
CONF_SELF="traffic_${WHAT}bound"
|
| 125 |
|
|
| 126 |
if [ -z $1 ]; then
|
|
| 127 |
GET=`fetch_xml //traffic//lastMin/${WHAT} kb status`
|
|
| 125 |
|
|
| 126 |
if [ -z $1 ]; then |
|
| 127 |
GET=`fetch_xml //traffic//lastMin/${WHAT} kb status`
|
|
| 128 | 128 |
RETURN=`echo $GET / 1024 | bc` |
| 129 |
RCPT=`fetch_xml //traffic//lastMin/${WHAT} rcp status`
|
|
| 130 |
MSGS=`fetch_xml //traffic//lastMin/${WHAT} msg status`
|
|
| 129 |
RCPT=`fetch_xml //traffic//lastMin/${WHAT} rcp status`
|
|
| 130 |
MSGS=`fetch_xml //traffic//lastMin/${WHAT} msg status`
|
|
| 131 | 131 |
echo "megabytes.value $RETURN" |
| 132 | 132 |
echo "recipients.value $RCPT" |
| 133 |
echo "messages.value $MSGS"
|
|
| 133 |
echo "messages.value $MSGS" |
|
| 134 | 134 |
exit 0 |
| 135 | 135 |
elif [ $1 = config ]; then |
| 136 | 136 |
echo "megabytes.label megabytes" |
| ... | ... | |
| 154 | 154 |
CONF_TITLE=`echo "powermta ${WHAT}bound connections" | tr [:upper:] [:lower:]`
|
| 155 | 155 |
CONF_LABEL=`echo "conn_${WHAT}" | tr [:upper:] [:lower:]`
|
| 156 | 156 |
CONF_SELF=`echo "connections_${WHAT}bound" | tr [:upper:] [:lower:]`
|
| 157 |
if [ -z $1 ]; then
|
|
| 158 |
GET=`fetch_xml //conn//smtp${WHAT} cur status`
|
|
| 157 |
if [ -z $1 ]; then |
|
| 158 |
GET=`fetch_xml //conn//smtp${WHAT} cur status`
|
|
| 159 | 159 |
echo "${CONF_SELF}.value $GET"
|
| 160 |
exit 0
|
|
| 160 |
exit 0 |
|
| 161 | 161 |
elif [ $1 = config ]; then |
| 162 | 162 |
echo "${CONF_SELF}.label ${WHAT}bound connections"
|
| 163 | 163 |
echo "${CONF_SELF}.draw LINE1"
|
| ... | ... | |
| 165 | 165 |
AUTOLABEL="no" |
| 166 | 166 |
fi |
| 167 | 167 |
;; |
| 168 |
*pmta_queue_domains | *pmta_queue_recipients | *pmta_queue_megabytes)
|
|
| 168 |
*pmta_queue_domains | *pmta_queue_recipients | *pmta_queue_megabytes) |
|
| 169 | 169 |
if [ `expr match "$NAME_SELF" ".*pmta_queue_domains"` != 0 ]; then |
| 170 | 170 |
WHAT="domains" |
| 171 | 171 |
elif [ `expr match "$NAME_SELF" ".*pmta_queue_recipients"` != 0 ]; then |
| ... | ... | |
| 175 | 175 |
UNIT_KB="true" |
| 176 | 176 |
fi |
| 177 | 177 |
CONF_TITLE="powermta ${WHAT} in queue"
|
| 178 |
CONF_LABEL="queue_${WHAT}"
|
|
| 179 |
CONF_SELF="${WHAT}"
|
|
| 180 |
|
|
| 178 |
CONF_LABEL="queue_${WHAT}"
|
|
| 179 |
CONF_SELF="${WHAT}"
|
|
| 180 |
|
|
| 181 | 181 |
if [ -z $1 ]; then |
| 182 | 182 |
if [ !$UNIT_KB ]; then |
| 183 |
GET=`fetch_xml //queue/smtp dom status`
|
|
| 183 |
GET=`fetch_xml //queue/smtp dom status` |
|
| 184 | 184 |
echo "${CONF_SELF}.value $GET"
|
| 185 |
exit 0
|
|
| 186 |
else
|
|
| 187 |
GET=`fetch_xml //queue/smtp kb status`
|
|
| 185 |
exit 0 |
|
| 186 |
else |
|
| 187 |
GET=`fetch_xml //queue/smtp kb status` |
|
| 188 | 188 |
RETURN=`echo $GET / 1024 | bc` |
| 189 | 189 |
echo "${CONF_SELF}.value $RETURN"
|
| 190 |
exit 0
|
|
| 190 |
exit 0 |
|
| 191 | 191 |
fi |
| 192 |
fi
|
|
| 192 |
fi |
|
| 193 | 193 |
;; |
| 194 | 194 |
*pmta_top_domains) |
| 195 | 195 |
CONF_TITLE="powermta top 10 domains by recipients" |
| 196 | 196 |
CONF_LABEL="top_domains" |
| 197 | 197 |
CONF_SELF="domains" |
| 198 | 198 |
AUTOLABEL="no" |
| 199 |
|
|
| 199 |
|
|
| 200 | 200 |
GET=`fetch_xml false false domains` |
| 201 | 201 |
if [ -z $1 ]; then |
| 202 | 202 |
for values in $GET; do |
| ... | ... | |
| 204 | 204 |
echo $values |
| 205 | 205 |
else |
| 206 | 206 |
echo -n "$values.value#" |
| 207 |
fi
|
|
| 207 |
fi |
|
| 208 | 208 |
done | tr ' ' '\n' | tr '#' ' ' # restore newline - replace hashtag with whitespace |
| 209 | 209 |
exit 0 |
| 210 | 210 |
elif [ $1 = config ]; then |
| ... | ... | |
| 239 | 239 |
fi |
| 240 | 240 |
fi |
| 241 | 241 |
exit 0 |
| 242 |
;;
|
|
| 242 |
;; |
|
| 243 | 243 |
autoconf) |
| 244 | 244 |
# tell munin this script supports autoconfiguration: |
| 245 | 245 |
echo "yes" |
| 246 |
;;
|
|
| 246 |
;; |
|
| 247 | 247 |
*) |
| 248 | 248 |
exit 1 |
| 249 | 249 |
;; |
Formats disponibles : Unified diff