#!/bin/sh #------------------------------------------------------------------------------ # OPT_RRDTOOL /srv/www/admin/rrdtool.cgi __FLI4LVER__ # Creation: bastard # Last Update: $Id$ #------------------------------------------------------------------------------ refresh_button () { cat <

EOF } # get main helper functions . /srv/www/include/cgi-helper # Security check check_rights "rrdtool" "view" # load common function, config and common lang file [ -z "$RRDTOOL_COMMON_LOADED" ] && . /etc/rrdtool/rrdtool-common : ${FORM_action:="tab1"} : ${FORM_option:="tab1"} : ${FORM_refresh:="false"} #tabid=`echo $FORM_action | sed s/[^0-9]//g` show_html_header "rrdtool" # # Menue - Links # local maintabs="" local source="" local label="" local label_lng_file="" for idx in `seq 1 $RRDTOOL_N` do # get source name defined in config file eval 'source=$RRDTOOL_'$idx'_SOURCE' # get label defined in config file eval 'label=$RRDTOOL_'$idx'_LABEL' #load language file rrdtool_load_lang_for_sources $source # get label defined in language file eval 'label_lng_file=$RRDTOOL_LNG_TAB_LABEL_'$source # if label is empty use fall back defined in lng file [ -z "$label" ] && label=$label_lng_file # html escape special chars in label label="`echo \"${label}\" | htmlspecialchars`" # concatinate string for show_tab_header function # and choose whether tab is active or inactive [ "tab$idx" != "$FORM_action" ] \ && maintabs="${maintabs}\"${label}\" \"${myname}?action=tab${idx}\" " \ || maintabs="${maintabs}\"${label}\" \"no\" " done eval "show_tab_header $maintabs" # # Grafiken und Anker # local idx=`echo "$FORM_action" | sed s/[^0-9]//g` eval 'local source=$RRDTOOL_'$idx'_SOURCE' eval 'local options=$RRDTOOL_'$idx'_OPTIONS_STRING' eval 'local options_n=$RRDTOOL_'$idx'_OPTIONS_N' local vil=$RRDTOOL_VALUE_INTERVAL local gil=$RRDTOOL_GRAPH_INTERVAL local dpath="$RRDTOOL_DB_PATH/$source" local wpath="$RRDTOOL_WWW_PATH/$source" local subtabs="" local option="" local option_var_name="" [ -n "$options" ] && for idy in `seq 1 $options_n` do # get source name defined in config file eval 'option=$RRDTOOL_'$idx'_OPTIONS_'$idy # clean option name to be able to use in var names option_var_name=`echo "$option"|sed 's/^[^A-Z_a-z]/_/; s/[^0-9A-Z_a-z]/_/g'` # get label defined in config file eval 'label=$RRDTOOL_'$idx'_OPTIONS_'$idy'_LABEL' #load language file rrdtool_load_lang_for_sources $source # get label defined in language file eval 'label_lng_file=$RRDTOOL_LNG_TAB_LABEL_'$source'_'$option_var_name # if label is empty use fall back defined in lng file [ -z "$label" ] && label=$label_lng_file # if tab label is still empty use option name if [ -z "$label" ]; then label="$option" case $source in disk | filesystem) if rrdtool_get_block_device "$option"; then [ "$device" != "$option" ] && label="$option ($device)" fi ;; esac fi # html escape special chars in label label="`echo \"${label}\" | htmlspecialchars`" # concatinate string for show_tab_header function # and choose whether tab is active or inactive [ "tab$idy" != "$FORM_option" ] \ && subtabs="${subtabs}\"${label}\" \"${myname}?action=tab${idx}&option=tab${idy}\" " \ || subtabs="${subtabs}\"${label}\" \"no\" " done eval "show_tab_header $subtabs" local idy=`echo "$FORM_option" | sed s/[^0-9]//g` eval 'local option=$RRDTOOL_'$idx'_OPTIONS_'$idy local graph_params=$RRDTOOL_CACHE_PATH/$RRDTOOL_HTTPD_GUI_LANG-$source-$option.params if [ -f $graph_params ]; then if [ "$FORM_view" ]; then local log_unit='' [ "$RRDTOOL_LOGARITHMIC_UNIT" == "prefixed" ] && log_unit=" --units=si" case "$FORM_view" in log) expr='s/--lower-limit[[:space:]]*0/--logarithmic --lower-limit 1'$log_unit'/' ;; linear) expr='s/--logarithmic --lower-limit 1\( --units=si\)\?/--lower-limit 0/' ;; esac sed -i -e "$expr" $graph_params rm -f $RRDTOOL_CACHE_PATH/$source/$RRDTOOL_HTTPD_GUI_LANG-$option-* fi local log_flags="`grep -e --lower-limit $graph_params`" if [ "$log_flags" ]; then case "$log_flags" in *--logarithmic*) view=linear;; *) view=log ;; esac eval value=\$_RRD_view_$view cat < `refresh_button`

EOF else refresh_button fi fi # # Render graphs if graph interval is 0 or the user requested a refresh. # if [ 0$gil -eq 0 -o "$FORM_refresh" == "true" ] then rrdtool_common "$source" "$option" "$RRDTOOL_TIME_RANGES" fi flag=/var/run/rrdtool-err-$source-$option if [ -f $flag ]; then show_error "$_RRD_error" "`cat $flag`" fi # # Write HTML code for each graph. # for intervall in $RRDTOOL_TIME_RANGES do local intervall_var_name="`echo \"${intervall}\" | tr '-' '_'`" local filename=${source}/${option}-${intervall}.png eval 'local graph_header="$_RRD_'$intervall_var_name'"' echo '

'$graph_header'

'$filename'

' done [ -z "$options" ] || show_tab_footer show_tab_footer show_html_footer