#!/bin/sh #------------------------------------------------------------------------------ # RRDtool3 - httpd GUI 3.5.0 # # Creation: 2010-08-29 Tiger # Last Update: $Id: rrdtool3.cgi$ # # Copyright (c) 2010 Fli4L Team # # This OPT package is licensed under Free Software Foundation, Inc., # General Public License Version 2, June 1991 #------------------------------------------------------------------------------ . /srv/www/include/cgi-helper . /var/run/rrdtool3.conf : ${CurrentSection:=rrdtool3} : ${CurrentAction:=view} : ${CurrentTab:=1} : ${CurrentTimeline:=`echo $RRDTOOL3_GRAPH_TIMELINE | cut -d' ' -f1`} ShowError () { local Message=$1 #---------------------- : ${Message:=General Failure} echo "
$Message
" } GetLineColour () { local ColourIndex=$1 local PluginName=$2 #---------------------- : ${ColourIndex:=1} eval local colour_table='$RRDTOOL3_'`echo $PluginName | tr 'a-z' 'A-Z'`'_LINECOLOURS' : ${colour_table:=$RRDTOOL3_GRAPH_LINECOLOURS} ColourIndex=`expr $ColourIndex % $(echo $colour_table | tr ' ' '\n' | grep -c '.')` echo $colour_table | cut -d' ' -f$ColourIndex } GetDecodedTimeline () { local Timeline=$1 #---------------------- set $_rrdtool3_timestring echo $Timeline | sed 's|^1y$|1 '$2'|;\ s|y$| '$1'|;\ s|^1m$|1 '$6'|;\ s|m$| '$5'|;\ s|^1w$|1 '$4'|;\ s|w$| '$3'|;\ s|^1d$|1 '$8'|;\ s|d$| '$7'|;\ s|^1h$|1 '$10'|;\ s|h$| '$9'|;' } ShowGraph () { local Timeline=$1 local ItemList=$2 local LabelList=$3 #---------------------- if [ -n "$ItemList" ] then # FIXME: Allow multiple sources in each graph local source=`echo $ItemList | cut -d':' -f1` local parameters=`echo $ItemList | cut -d':' -f2-` local source_file=$RRDTOOL3_DIR_INCLUDE/$source.inc if [ -f "$source_file" ] then . "$source_file" local params_routine=GetGraphParams_$source if type $params_routine > /dev/null then local options=`eval $params_routine "$Timeline" "$parameters" "$LabelList" | sed 's|^[ ]*||' | tr '\n' ' '` if [ -n "$options" ] then options=`cat << __EOF__ | sed 's|^[ ]*||' | tr '\n' ' ' --lazy -a PNG -h $RRDTOOL3_GRAPH_HEIGHT -w $RRDTOOL3_GRAPH_WIDTH ${RRDTOOL3_RRDCACHED_SOCKET:+--daemon "$RRDTOOL3_RRDCACHED_SOCKET"} --end now --start end-$Timeline $options COMMENT:"\s" COMMENT:"$(date "+$_rrdtool3_timestamp_format" | sed 's|:|\\\\:|g')\r" ${RRDTOOL3_GRAPH_WATERMARK:+--watermark "$RRDTOOL3_GRAPH_WATERMARK" --font "WATERMARK:8"} __EOF__ ` local colour_attribute= for colour_attribute in $RRDTOOL3_GRAPH_COLOUR do options="$options -c $colour_attribute" done echo $options > /tmp/graph.options if ! eval '/usr/bin/rrdtool graph' $options then ShowError "$_rrdtool3_graph_rendering_error" fi else ShowError "$_rrdtool3_graph_options_error" fi else ShowError "$_rrdtool3_graph_missing_params" fi else ShowError "$_rrdtool3_graph_include_missing ($RRDTOOL3_DIR_INCLUDE_GRAPH/$source.graph)" fi fi } ShowTabs () { local BaseVariable=$1 local TabLink=$2 local TabList=$3 local Timeline=$4 #---------------------- if [ -n "$BaseVariable" -a -n "$TabLink" ] then local current_tab=`echo $TabList | cut -d- -f1` : ${current_tab:=1} if [ $current_tab -gt $(eval echo '$'$BaseVariable'_N') ]; then current_tab=1; fi local tab_headers= local tab_index= local link= for tab_index in `seq 1 $(eval echo '$'$BaseVariable'_N')` do if [ $tab_index -eq $current_tab ] then link=no else link="$TabLink$tab_index" fi eval local title='$'$BaseVariable'_'$tab_index'_TITLE' tab_headers="${tab_headers:+$tab_headers }\"$title\" \"$link\"" done if [ -n "$tab_headers" ] then eval 'show_tab_header' $tab_headers eval local subtab_n='$'$BaseVariable'_'$tab_index'_SUBTAB_N' if [ 0$subtab_n -gt 0 ] then ShowTabs "${BaseVariable}_${current_tab}_SUBTAB" "$TabLink$current_tab-" "`echo $TabList | sed 's|^[0-9]*||;s|^-||'`" "$Timeline" fi if [ -n "`eval echo '$'$BaseVariable'_'$current_tab'_GRAPH'`" ] then eval 'ShowGraph "$Timeline" "$'$BaseVariable'_'$current_tab'_GRAPH" "$'$BaseVariable'_'$current_tab'_LABEL"' fi local graph_index= for graph_index in `seq 1 0$(eval echo '0$'$BaseVariable'_'$current_tab'_GRAPH_N')` do eval 'ShowGraph "$Timeline" "$'$BaseVariable'_'$current_tab'_GRAPH_'$graph_index'" "$'$BaseVariable'_'$current_tab'_LABEL_'$graph_index'"' done show_tab_footer fi fi } ShowTimeline () { local ButtonLink=$1 local CurrentTimeline=$2 #---------------------- local timeline= echo '
' } # Parse URI for uri_item in Action Tab Timeline do eval value='$FORM_'"`echo $uri_item | tr 'A-Z' 'a-z'`" eval 'Current'$uri_item='${value:=$Current'$uri_item'}' done check_rights "$CurrentSection" "$CurrentAction" show_html_header "$RRDTOOL3_OPT GUI $RRDTOOL3_VERSION" ShowTabs "RRDTOOL3_TAB" "$myname?action=view&timeline=$CurrentTimeline&tab=" "$CurrentTab" "$CurrentTimeline" ShowTimeline "$myname?action=view&tab=$CurrentTab&timeline=" "$CurrentTimeline" show_html_footer