#!/bin/sh #------------------------------------------------------------------------------ # opt/files/srv/www/admin/dsltool.cgi __FLI4LVER__ # # Creation: 06.02.2013 cspiess # Last Update: $Id$ #------------------------------------------------------------------------------ . /srv/www/include/cgi-helper #set_debug=yes ## get some internal variables . /var/run/dsltool.conf # Security check_rights "dsltool" "view" #globals : ${FORM_action:=dsltool_info} : ${FORM_idx:=1} # per instance variables eval dsltoolhost='$DSLTOOL_'$FORM_idx'_HOST' eval dsltoolrrd='$DSLTOOL_'$FORM_idx'_RRD' eval dsltooldebug='$DSLTOOL_'$FORM_idx'_DEBUG' if [ "$dsltoolrrd" = "yes" ] then . /srv/www/include/rrd-common.inc . /srv/www/include/rrd-dsltool.inc _dsltool_modemstate="dsltool_modemstate" _dsltool_attenuation="dsltool_attenuation" _dsltool_noisemargin="dsltool_noisemargin" _dsltool_txpower="dsltool_txpower" _dsltool_bandwidth="dsltool_bandwidth" _dsltool_errors="dsltool_errors" _dsltool_failures="dsltool_failures" : ${FORM_rrd_graphtime_dsltool_modemstate:=$rrd_default_graphtime} : ${FORM_rrd_graphtime_dsltool_attenuation:=$rrd_default_graphtime} : ${FORM_rrd_graphtime_dsltool_noisemargin:=$rrd_default_graphtime} : ${FORM_rrd_graphtime_dsltool_txpower:=$rrd_default_graphtime} : ${FORM_rrd_graphtime_dsltool_bandwidth:=$rrd_default_graphtime} : ${FORM_rrd_graphtime_dsltool_errors:=$rrd_default_graphtime} : ${FORM_rrd_graphtime_dsltool_failures:=$rrd_default_graphtime} fi # functions dsltool_info_status () { show_tab_header "$_DSLTOOL_INFO_STATUS" "no" cat < $_DSLTOOL_INFO_DSLTYPE $dsltype $_DSLTOOL_INFO_MODEMSTATE $modemstate_str $_DSLTOOL_INFO_OPERATIONMODE $operationmode EOF case "$dsltype" in "ADSL"|"ADSL2"|"ADSL2+") cat < $channelmode EOF ;; "VDSL"|"VDSL2") cat < $_DSLTOOL_INFO_PROFILE $profile EOF ;; esac cat < EOF show_tab_footer } dsltool_info_line () { case "$dsltype" in "ADSL"|"ADSL2"|"ADSL2+") show_tab_header "$_DSLTOOL_INFO_LINE" "no" cat < $_DSLTOOL_INFO_BITRATE $_DSLTOOL_INFO_NOISEMARGIN $_DSLTOOL_INFO_ATTENUATION $_DSLTOOL_INFO_TXPOWER $_DSLTOOL_INFO_UPSTREAM $bandwidth_kbit_up $noisemargin_up $attenuation_up $txpower_up $_DSLTOOL_INFO_DOWNSTREAM $bandwidth_kbit_down $noisemargin_down $attenuation_down $txpower_down EOF show_tab_footer ;; "VDSL"|"VDSL2") show_tab_header "$_DSLTOOL_INFO_LINE" "no" cat < $_DSLTOOL_INFO_BITRATE max. $_DSLTOOL_INFO_BITRATE $_DSLTOOL_INFO_TXPOWER $_DSLTOOL_INFO_UPSTREAM $bandwidth_kbit_up $maxbandwidth_kbit_up $txpower_up $_DSLTOOL_INFO_DOWNSTREAM $bandwidth_kbit_down $maxbandwidth_kbit_down $txpower_down EOF for i in `seq 0 5` do if [ $dslband -gt $i ] then if [ $i -eq 0 ] then eval nm_up='$noisemargin_up' eval at_up='$attenuation_up' eval nm_down='$noisemargin_down' eval at_down='$attenuation_down' else eval nm_up='$noisemargin'$i'_up' eval at_up='$attenuation'$i'_up' eval nm_down='$noisemargin'$i'_down' eval at_down='$attenuation'$i'_down' fi if [ -n $nm_up -o -n $at_up ] then cat < EOF fi if [ -n $nm_down -o -n $at_down ] then cat < EOF fi fi done cat < EOF show_tab_footer ;; esac } dsltool_info_errors () { show_tab_header "$_DSLTOOL_INFO_ERRORS" "no" cat <
$_DSLTOOL_INFO_NOISEMARGIN $_DSLTOOL_INFO_ATTENUATION
$_DSLTOOL_INFO_UPSTREAM $i $nm_up $at_up
$_DSLTOOL_INFO_DOWNSTREAM $i $nm_down $at_down
$_DSLTOOL_INFO_FEC $_DSLTOOL_INFO_CRC $_DSLTOOL_INFO_HEC
$_DSLTOOL_INFO_RX $error_rx_FEC $error_rx_CRC $error_rx_HEC
$_DSLTOOL_INFO_TX $error_tx_FEC $error_tx_CRC $error_tx_HEC
EOF show_tab_footer } dsltool_info_failures () { show_tab_header "$_DSLTOOL_INFO_FAILURES" "no" cat < $_DSLTOOL_INFO_ERRSEC $_DSLTOOL_INFO_15M $error_secs_15min $_DSLTOOL_INFO_DAY $error_secs_day EOF show_tab_footer } dsltool_info_atm () { case "$dsltype" in "ADSL"|"ADSL2"|"ADSL2+") show_tab_header "$_DSLTOOL_INFO_ATM" "no" cat < $_DSLTOOL_INFO_VPI $_DSLTOOL_INFO_VCI $ATM_VPI $ATM_VCI EOF show_tab_footer ;; esac } dsltool_info_xtu () { case "$dsltype" in "ADSL"|"ADSL2"|"ADSL2+") show_tab_header "$_DSLTOOL_INFO_ATU" "no" cat < $_DSLTOOL_INFO_VENDOR $_DSLTOOL_INFO_VENDSPEC $_DSLTOOL_INFO_REVISION $_DSLTOOL_INFO_ATUC $ATU_C_vendor $ATU_C_vendspec $ATU_C_revision $_DSLTOOL_INFO_ATUR $ATU_R_vendor $ATU_R_vendspec $ATU_R_revision EOF show_tab_footer ;; "VDSL"|"VDSL2") show_tab_header "$_DSLTOOL_INFO_VTU" "no" cat < $_DSLTOOL_INFO_VENDOR $_DSLTOOL_INFO_VENDSPEC $_DSLTOOL_INFO_REVISION $_DSLTOOL_INFO_VTUO $ATU_C_vendor $ATU_C_vendspec $ATU_C_revision $_DSLTOOL_INFO_VTUR $ATU_R_vendor $ATU_R_vendspec $ATU_R_revision EOF show_tab_footer ;; esac } dsltool_info () { rm /srv/www/img/dsltool-${dsltoolhost}.dat /usr/bin/dsltool-info.sh ${FORM_idx} -o9 if [ -e /srv/www/img/dsltool-${dsltoolhost}.dat ] then . /srv/www/img/dsltool-${dsltoolhost}.dat dsltool_info_status dsltool_info_line dsltool_info_errors dsltool_info_failures dsltool_info_atm dsltool_info_xtu else show_error "$_MN_err" "$_DSLTOOL_ERR_NO_ANSWER ${dsltoolhost}" fi } dsltool_spectrum_show() { if [ -f /srv/www/img/dsltool-${dsltoolhost}-$1.png ] then echo "\"DSL-Tool" fi } dsltool_spectrum () { /usr/bin/dsltool-info.sh ${FORM_idx} -o9 dsltool_spectrum_show bits echo "
" dsltool_spectrum_show snr echo "
" dsltool_spectrum_show char echo "
" } dsltool_statistics () { if [ "$dsltoolrrd" = "yes" ] then tab_hdr="" tab_list="" if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/modemstate.rrd ] then tab_hdr=`echo "$tab_hdr modemstate"` fi if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/attenuation-down.rrd ] then tab_hdr=`echo "$tab_hdr attenuation"` fi if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/noisemargin-down.rrd ] then tab_hdr=`echo "$tab_hdr noisemargin"` fi if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/txpower-up.rrd -a \ -f $rrd_dbpath/dsltool-${dsltoolhost}/txpower-down.rrd ] then tab_hdr=`echo "$tab_hdr txpower"` fi if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/bandwidth-kbit-up.rrd -a \ -f $rrd_dbpath/dsltool-${dsltoolhost}/bandwidth-kbit-down.rrd ] then tab_hdr=`echo "$tab_hdr bandwidth"` fi if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-error-FEC-Rx.rrd -o \ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-error-CRC-Rx.rrd -o \ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-error-HEC-Rx.rrd -o \ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-error-FEC-Tx.rrd -o \ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-error-CRC-Tx.rrd -o \ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-error-HEC-Tx.rrd ] then tab_hdr=`echo "$tab_hdr errors"` fi if [ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-failure-errsec-15min.rrd -a \ -f $rrd_dbpath/dsltool-${dsltoolhost}/statistics-failure-errsec-day.rrd ] then tab_hdr=`echo "$tab_hdr failures"` fi for i in $tab_hdr do eval local rrd_source_time='$FORM_rrd_graphtime_'$rrd_source : ${rrd_source_time:=$rrd_default_graphtime} case $i in modemstate) label=$(translate_label "${_DSLTOOL_MODEMSTATE}") ;; attenuation) label=$(translate_label "${_DSLTOOL_ATTENUATION}") ;; noisemargin) label=$(translate_label "${_DSLTOOL_NOISEMARGIN}") ;; txpower) label=$(translate_label "${_DSLTOOL_TXPOWER}") ;; bandwidth) label=$(translate_label "${_DSLTOOL_BANDWIDTH}") ;; errors) label=$(translate_label "${_DSLTOOL_ERRORS}") ;; failures) label=$(translate_label "${_DSLTOOL_FAILURES}") ;; esac if [ "$FORM_action" = "dsltool_$i" ] then tab_list=`echo "$tab_list $label no"` else tab_list=`echo "$tab_list $label $myname?idx=${FORM_idx}&action=dsltool_$i"` fi done show_tab_header $tab_list rrd_open_tab_list $FORM_action rrd_render_graph $FORM_action rrd_close_tab_list show_tab_footer fi } dsltool_control () { echo "
" echo "" echo "" echo "" echo "
" } dsltool_debug () { /usr/bin/dsltool-dump.sh ${FORM_idx} http_header download "filename=ctype=application/download;filename=dsltool-dump.tgz" cat /tmp/dsltool-dump.tgz } if [ "$dsltooldebug" = "yes" -a "$FORM_action" = "dsltool_debug" ] then dsltool_debug else show_html_header "DSL-Tool" # dsltool instances if [ ${DSLTOOL_N} -gt 1 ] then tab_list="" for n in `seq 1 ${DSLTOOL_N}` do eval label='$DSLTOOL_'$n'_HOST' if [ "$FORM_idx" = "$n" ] then tab_list=`echo "$tab_list $label no"` else tab_list=`echo "$tab_list $label $myname?idx=$n"` fi done show_tab_header $tab_list fi tab_list="" if [ "$dsltoolrrd" = "yes" ] then tabs=`echo "info spectrum statistics control"` else tabs=`echo "info spectrum control"` fi if [ "$dsltooldebug" = "yes" ] then tabs=`echo "$tabs debug"` fi for i in $tabs do case $i in info) label=$(translate_label "${_DSLTOOL_INFO}") ;; spectrum) label=$(translate_label "${_DSLTOOL_SPECTRUM}") ;; statistics) label=$(translate_label "${_DSLTOOL_STATISTICS}") ;; control) label=$(translate_label "${_DSLTOOL_CONTROL}") ;; debug) label=$(translate_label "${_DSLTOOL_DEBUG}") ;; esac if [ "$FORM_action" = "dsltool_$i" ] then tab_list=`echo "$tab_list $label no"` elif [ "$i" = "statistics" ] then display="$myname?idx=${FORM_idx}&action=dsltool_$i" for a in modemstate attenuation noisemargin txpower bandwidth errors failures do if [ "$FORM_action" = "dsltool_$a" ] then display="no" fi done tab_list=`echo "$tab_list $label $display"` else tab_list=`echo "$tab_list $label $myname?idx=${FORM_idx}&action=dsltool_$i"` fi done show_tab_header $tab_list case $FORM_action in dsltool_info) dsltool_info ;; dsltool_spectrum) FORM_action="dsltool_spectrum_bits" dsltool_spectrum ;; dsltool_spectrum_bits | dsltool_spectrum_snr | \ dsltool_spectrum_char | dsltool_spectrum_all) dsltool_spectrum ;; dsltool_statistics) FORM_action="dsltool_modemstate" dsltool_statistics ;; dsltool_modemstate | dsltool_attenuation | \ dsltool_noisemargin | dsltool_txpower | dsltool_bandwidth | \ dsltool_errors | dsltool_failures) dsltool_statistics ;; dsltool_control) case "$FORM_command" in "$_DSLTOOL_CTRL_RESYNC") /usr/bin/dsltool-resync.sh ${FORM_idx} ;; "$_DSLTOOL_CTRL_REBOOT") /usr/bin/dsltool-reboot.sh ${FORM_idx} ;; esac dsltool_control ;; esac show_tab_footer # dsltool instances if [ ${DSLTOOL_N} -gt 1 ] then show_tab_footer fi show_html_footer fi