Skip to content

Commit

Permalink
changed waitmax to use the coreutils timeout command instead which
Browse files Browse the repository at this point in the history
should provide the same functionality but is licensed under GPL3 which
is compatible to Apache2.
  • Loading branch information
jens-maus committed Jan 21, 2019
1 parent cf326dc commit b68676e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions addon/addon/server.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ proc handle_connection { channelId clientAddress clientPort } {

if { [file exists /proc/net/tcp6] == 1 } {
puts $channelId "<<<tcp_conn_stats>>>"
puts $channelId "[exec /usr/local/addons/check_mk_agent/waitmax -s 1 10 cat /proc/net/tcp /proc/net/tcp6 2>/dev/null | awk { /:/ { c[$4]++; } END { for (x in c) { print x, c[x]; } } }]"
puts $channelId "[exec /usr/local/addons/check_mk_agent/timeout -s 1 10 cat /proc/net/tcp /proc/net/tcp6 2>/dev/null | awk { /:/ { c[$4]++; } END { for (x in c) { print x, c[x]; } } }]"
} else {
puts $channelId "<<<tcp_conn_stats>>>"
puts $channelId "[exec /usr/local/addons/check_mk_agent/waitmax -s 1 10 cat /proc/net/tcp 2>/dev/null | awk { /:/ { c[$4]++; } END { for (x in c) { print x, c[x]; } } }]"
puts $channelId "[exec /usr/local/addons/check_mk_agent/timeout -s 1 10 cat /proc/net/tcp 2>/dev/null | awk { /:/ { c[$4]++; } END { for (x in c) { print x, c[x]; } } }]"
}

puts $channelId "<<<lnx_if>>>"
Expand Down Expand Up @@ -67,10 +67,10 @@ proc handle_connection { channelId clientAddress clientPort } {

if { [file exists /bin/stat] == 1 } {
puts $channelId "<<<nfsmounts>>>"
puts $channelId [exec sh -c {sed -n '/ nfs4\? /s/[^ ]* \([^ ]*\) .*/\1/p' </proc/mounts | sed 's/\\040/ /g' | while read MP; do /usr/local/addons/check_mk_agent/waitmax -s 9 5 stat -f -c "$MP ok %b %f %a %s" "$MP" || echo "$MP hanging 0 0 0 0"; done}]
puts $channelId [exec sh -c {sed -n '/ nfs4\? /s/[^ ]* \([^ ]*\) .*/\1/p' </proc/mounts | sed 's/\\040/ /g' | while read MP; do /usr/local/addons/check_mk_agent/timeout -s 9 5 stat -f -c "$MP ok %b %f %a %s" "$MP" || echo "$MP hanging 0 0 0 0"; done}]

puts $channelId "<<<cifsmounts>>>"
puts $channelId [exec sh -c {sed -n '/ cifs\? /s/[^ ]* \([^ ]*\) .*/\1/p' </proc/mounts | sed 's/\\040/ /g' | while read MP; do if [ ! -r "$MP" ]; then echo "$MP Permission denied"; else /usr/local/addons/check_mk_agent/waitmax -s 9 2 stat -f -c "$MP ok %b %f %a %s" "$MP" || echo "$MP hanging 0 0 0 0"; fi; done}]
puts $channelId [exec sh -c {sed -n '/ cifs\? /s/[^ ]* \([^ ]*\) .*/\1/p' </proc/mounts | sed 's/\\040/ /g' | while read MP; do if [ ! -r "$MP" ]; then echo "$MP Permission denied"; else /usr/local/addons/check_mk_agent/timeout -s 9 2 stat -f -c "$MP ok %b %f %a %s" "$MP" || echo "$MP hanging 0 0 0 0"; fi; done}]
}

puts $channelId "<<<ps>>>"
Expand All @@ -82,12 +82,12 @@ proc handle_connection { channelId clientAddress clientPort } {

if { [file exists /usr/bin/ntpq] == 1 } {
puts $channelId "<<<ntp>>>"
puts $channelId "[exec /usr/local/addons/check_mk_agent/waitmax 5 /usr/bin/ntpq -np | sed -e 1,2d -e {s/^\(.\)/\1 /} -e {s/^ /%/}]"
puts $channelId "[exec /usr/local/addons/check_mk_agent/timeout 5 /usr/bin/ntpq -np | sed -e 1,2d -e {s/^\(.\)/\1 /} -e {s/^ /%/}]"
}

if { [file exists /usr/bin/chronyc] == 1 } {
puts $channelId "<<<chrony>>>"
puts $channelId "[exec /usr/local/addons/check_mk_agent/waitmax 5 /usr/bin/chronyc -n tracking]"
puts $channelId "[exec /usr/local/addons/check_mk_agent/timeout 5 /usr/bin/chronyc -n tracking]"
}

puts $channelId "<<<homematic:sep(59)>>>"
Expand Down
Binary file added addon/addon/timeout-ccu2
Binary file not shown.
Binary file added addon/addon/timeout-ccu3
Binary file not shown.
Binary file removed addon/addon/waitmax-ccu2
Binary file not shown.
Binary file removed addon/addon/waitmax-ccu3
Binary file not shown.
6 changes: 3 additions & 3 deletions addon/rc.d/check_mk_agent
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ RCDDIR=/usr/local/etc/config/rc.d
case "$1" in

""|start)
rm -f /usr/local/addons/${ADDONNAME}/waitmax 2>/dev/null
rm -f /usr/local/addons/${ADDONNAME}/timeout 2>/dev/null
if [ "$(uname -m)" == "armv5tejl" ]; then
ln -s /usr/local/addons/${ADDONNAME}/waitmax-ccu2 /usr/local/addons/${ADDONNAME}/waitmax
ln -s /usr/local/addons/${ADDONNAME}/timeout-ccu2 /usr/local/addons/${ADDONNAME}/timeout
else
ln -s /usr/local/addons/${ADDONNAME}/waitmax-ccu3 /usr/local/addons/${ADDONNAME}/waitmax
ln -s /usr/local/addons/${ADDONNAME}/timeout-ccu3 /usr/local/addons/${ADDONNAME}/timeout
fi
tclsh $ADDONDIR/server.tcl &
;;
Expand Down

0 comments on commit b68676e

Please sign in to comment.