Bash-Scripting - Munin Plugin don't work

Solution 1:

Do not check munin scripts with just direct scripts running. It's wrong way. There is special perl script munin-run that executes scripts exactly the same way as it runs during munin update and you'll able to find all errors. May be you'll need define special settings for you script. You can do it in /etc/munin/plugin-conf.d/munin-node file next way:

[script_file_mask_*]
user USER_FOR_YOR_SCRIPT
env.VARIABLE some_variable

In your case seems that script just hasn't tighr to read log file. So add

[lighttpd_*]
user root

in /etc/munin/plugin-conf.d/munin-node and restart munin-node. It should help.

Solution 2:

I don't know if you ever managed to fix this yourself, but I did and I thought I'd share my solution.

Rush was right in suggesting to run it as root, but the real error seems to be with your choice of name for your fields (1xx, 2xx, 3xx, ...). As per this wiki page:

Each data source in a plugin must be identified by a field name. The following describes the name of the field:
* The characters must be [a-zA-Z0-9_], while the first character must be [a-zA-Z_].

This is why you only ever saw 5xx in your graph and no results. While creating the rdd files munin replaced the numbers with an underscore (like _xx), which meant the data was overwritten for each of the 5 fields. The easy fix is to add a letter to your field names like so:

graph_category lighttpd
T1xx.label 1xx
T2xx.label 2xx
T3xx.label 3xx
T4xx.label 4xx
T5xx.label 5xx
EOM

        echo "T1xx.value "$CODE_1xx
        echo "T2xx.value "$CODE_2xx
        echo "T3xx.value "$CODE_3xx
        echo "T4xx.value "$CODE_4xx
        echo "T5xx.value "$CODE_5xx
else
        echo "T1xx.value U"
        echo "T2xx.value U"
        echo "T3xx.value U"
        echo "T4xx.value U"
        echo "T5xx.value U"
fi

Like this I got your script working perfectly.