#!/bin/bash

#%# family=test
#%# capabilities=autoconf

. $MUNIN_LIBDIR/plugins/plugin.sh || exit 1

# Handle the case where the munin node does not understand multigraph.
is_multigraph "$@"

# Plugin itself starts here

do_ () {
    # Do fetch stuff here (.value things!)

    cat <<"EOF"
one.value 1
two.value 2
three.value 3
#
multigraph multigraph_tester.en
one.value 1
#
multigraph multigraph_tester.to
two.value 2
#
multigraph multigraph_tester.tre
three.value 3
#
multigraph multigraph_outofscope
i.value 42
EOF
    exit 0

}

do_config () {
    # Do config stuff here

# Note that "#" in output is optional and is only used to make output more human readable
    cat <<"EOF"
graph_title Root graph of multigraph test
graph_info The root graph is used to click into sub-graph page.  Eventually the root graph should be able to borrow data from the sub graphs in a fairly easy manner.  But not right now.
one.label number 1
two.label number 2
two.warning 0:100
two.critical 0:1000
three.label number 3
#
multigraph multigraph_tester.en
graph_title The number 1 sub-graph
graph_info This and the other . (dot) separated nested graphs are presented in a page linked to from the root graph
one.label number 1
#
multigraph multigraph_tester.to
graph_title The number 2 sub-graph
two.label number 2
#
multigraph multigraph_tester.tre
graph_title The number 3 sub-graph
three.label number 3
three.warning 0:1
three.critical 0:5
#
multigraph multigraph_outofscope
graph_title The out of namespace graph
graph_info The "multigraph protocol keyword allows the plugin to place data anywhere in the host namespace.  The intended use is to be able to produce multiple root graphs and sub-graph spaces, but as you see it needs not have a sub-graph space at all.
i.label number i
EOF

    exit 0
}

do_autoconf () {
    echo yes
    exit 0
}

# Main is here

do_$1 2>/dev/null || {
      echo "Do what now?" >&2
      exit 1
}
