Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix and extension of http_loadtime.in #191

Merged
merged 4 commits into from Nov 26, 2016

Conversation

steveschnepp
Copy link
Member

  • fixes http://munin-monitoring.org/ticket/1350
  • introduces multi-url support (backwards compatible to single url)
  • reintroduces using a tmp dir (necessary for requisites
  • reintroduces a specific user agent
  • allows auto config again

@ax3l
Copy link
Contributor

ax3l commented Mar 1, 2014

thx! :)

@Nodraak
Copy link
Contributor

Nodraak commented Apr 27, 2016

Hi, what's the status of this PR ? I can see the label rebase-needed.

Here is the diff between branch devel and this PR (I used git diff upstream/devel pr/191 -- plugins/node.d/http_loadtime):

diff --git a/plugins/node.d/http_loadtime b/plugins/node.d/http_loadtime
old mode 100755
new mode 100644
index 4f7e2c8..37d990b
--- a/plugins/node.d/http_loadtime
+++ b/plugins/node.d/http_loadtime
@@ -1,4 +1,5 @@
-#!/bin/bash
+#!@@BASH@@
+# -*- sh -*-

 : << =cut

@@ -35,13 +36,14 @@ GPLv2

 =cut

+MUNIN_LIBDIR=${MUNIN_LIBDIR:-"/usr/share/munin"}
 . $MUNIN_LIBDIR/plugins/plugin.sh

 target=${target:-"http://localhost/"}
 requisites=${requisites:-"false"}

 urls=`echo $target | tr "," "\n"`
-wget_opt="--user-agent munin/http_loadtime --no-cache -q"
+wget_opt="--user-agent \"Munin - http_loadtime\" --no-cache -q"
 if [ "$requisites" == "true" ]; then
   wget_opt="$wget_opt --page-requisites"
 fi
@@ -54,24 +56,21 @@ if [ "$1" = "autoconf" ]; then
     command -v tr        2>&1 >/dev/null || result=1
     command -v wget      2>&1 >/dev/null || result=1
     if [ "$result" != "yes" ]; then
-   echo "no (programs time, wget and tr required)"
-   exit 0
+       echo "no (programs time, wget and tr required)"
+           exit 0
     fi

-    # if $target contains more than one url
-    if ! wget -q -O /dev/null $target; then
-
-        # check if urls respond
-        #
-        for uri in $urls
-        do
-            wget --spider $uri $wget_opt
-            if [ "$?" != "0" ]; then
-                echo "no (Cannot run wget against \"$uri\")"
-                exit 0
-            fi
-        done
-    fi
+    # check if urls respond
+    #
+    for uri in $urls
+    do
+        wget --spider $uri $wget_opt
+        if [ "$?" != "0" ]; then
+            echo "no (Cannot run wget against \"$uri\")"
+            exit 0
+        fi
+    done
+
     echo yes
     exit 0
 fi
@@ -101,14 +100,10 @@ cd $TEMPO_DIR || exit 1

 for uri in $urls
 do
-    loadtime=`$time_bin -f "%e" wget $wget_opt --header='Accept-Encoding: gzip,deflate' $uri 2>&1`
-    if [ "$?" == "0" ]; then
-        esc_uri="$(clean_fieldname "$uri")"
-        echo $esc_uri".value $loadtime"
-    else
-        echo "Download error during $uri" 1>&2
-        exit 1
-    fi
+    loadtime=`$time_bin --quiet -f "%e" wget $wget_opt $uri 2>&1`
+
+    esc_uri="$(clean_fieldname "$uri")"
+    echo $esc_uri".value $loadtime"
 done

-exit 0
+cd -

I think this PR can be closed without merge, it seems that relevant changes have already been applied. I am not sure though about theses:

  • MUNIN_LIBDIR=${MUNIN_LIBDIR:-"/usr/share/munin"}: is it needed ?
  • time's flag --quiet: can be added, does not harm

@ax3l
Copy link
Contributor

ax3l commented Apr 27, 2016

the file was renamed (removed the .in ending) in devel. rebased the PR.

@coveralls
Copy link

coveralls commented Apr 27, 2016

Coverage Status

Coverage remained the same at 34.493% when pulling 5a8e466 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

@ax3l
Copy link
Contributor

ax3l commented Nov 10, 2016

oh, what happened?

@dipohl
Copy link
Contributor

dipohl commented Nov 10, 2016

Steve made a mistake in the last IRC meeting

20:29:16 * h01ger hopes TheSnide did the push origin :devel by now
20:29:37 h01ger: we agreed last meeting to get rid off it
20:29:41 TheSnide: h01ger: not yet. i'm deeply late one that
20:29:52 h01ger: do it now ;)
20:33:41 hugin: steveschnepp pushed 1 new commit to master: https://git.io/vX24L
20:33:41 hugin: master 14203a421 Steve Schnepp: Merge remote-tracking branch 'origin/devel'...
20:35:40 hugin-dev [munin] steveschnepp pushed 1 new commit to devel: https://git.io/vX2Be
[by that many PR were closed by devel removal..]
20:36:28 TheSnide ouch..

Full chat protocol: http://meetbot.debian.net/munin/2016/munin.2016-11-09-20.21.log.html

@ax3l
Copy link
Contributor

ax3l commented Nov 11, 2016

;D

@steveschnepp steveschnepp reopened this Nov 13, 2016
Copy link
Member Author

@steveschnepp steveschnepp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good, just several syntax fixes needed

@@ -1,5 +1,4 @@
#!@@BASH@@
# -*- sh -*-
#!/usr/bin/env bash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like to use /usr/bin/envin the source from official plugins.
We just use /bin/bash or /bin/sh. This is much cleaner and let package maintainers handle the eventual change in PATH.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's less general, but I will change that to /bin/bash

esc_uri="$(clean_fieldname "$uri")"
echo $esc_uri".label $uri_short"
echo $esc_uri".info page load time"
echo `escapeUri $uri`".label $uri_short"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also quite like the $( ... ) syntax more. Specially if you use twice the same var.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update, thanks!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 34.547% when pulling bf59f72 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

5 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 34.547% when pulling bf59f72 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 34.547% when pulling bf59f72 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 34.547% when pulling bf59f72 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 34.547% when pulling bf59f72 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 34.547% when pulling bf59f72 on ax3l:loadtime_cherry into 8d87860 on munin-monitoring:devel.

@ax3l
Copy link
Contributor

ax3l commented Nov 26, 2016

@steveschnepp thank you for the review! all inline comments addressed and rebased on top of the latest devel

@coveralls
Copy link

coveralls commented Nov 26, 2016

Coverage Status

Coverage remained the same at 34.547% when pulling c42fda8 on ax3l:loadtime_cherry into 52126a0 on munin-monitoring:devel.

@steveschnepp steveschnepp merged commit 3781ae0 into munin-monitoring:devel Nov 26, 2016
@ax3l ax3l deleted the loadtime_cherry branch November 28, 2016 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

6 participants