Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.63k stars 404 forks source link

cacti - Version 1.1.33 - Zoom Problem #1266

Closed anarkia1976 closed 6 years ago

anarkia1976 commented 6 years ago

I have a problem when i perfom this action (latest cacti merged from source):

click on --> tab graphs --> device graph --> time graph view --> zoom on daily graph

2018/01/25 08:25:11 - CMDPHP Validation Error, Variable:local_graph_id, Value:34_3 Backtrace: (/graph_json.php: 44 get_filter_request_var)(/lib/html_utility.php: 439 die_html_input_error)(/lib/html_validate.php: 60 cacti_debug_backtrace)

image

thanks a lot for support.

netniV commented 6 years ago

What OS are you running on? Some Linux systems have a library issue with zoom (I think CentOS was one of them).

anarkia1976 commented 6 years ago

OS: Centos 7 latest. The problem began after i upgrade cacti from 1.1.28 to 1.1.31. If i'm using zoom directly from tab --> graphs i don't have this error.

netniV commented 6 years ago

OK, when I goto Time Graph view you can't actually zoom there directly. What steps are you taking at that point?

anarkia1976 commented 6 years ago

I don't have zoom problem here: image

but i have zoom problem here: image

netniV commented 6 years ago

With the patch to display full error messages applied, can you try this again?

netniV commented 6 years ago

So I just tried this with my latest error trapping patches... here's the strange thing, I got: image

I'm not quite sure how I got an error and a success at the same time....

netniV commented 6 years ago

And the reason would be that this response was sent back which isn't JSON so presumably fails, though because the page returns 200 OK (since it displayed a full page) there is a bit of confusion going on:

"   <table style='width:100%;text-align:center;'>
        <tr>
            <td>
                Validation error for variable local_graph_id with a value of 6_1.  See backtrace below for more details.            </td>
        </tr>
    </table>
    <table style='width:100%;text-align:center;'><tr><td>(/graph_json.php: 44 get_filter_request_var)(/lib/html_utility.php: 439 die_html_input_error)(/lib/html_validate.php: 60 cacti_debug_backtrace)</td></tr></table>
<script type='text/javascript'>
    var cactiVersion='1.1.33';
    var theme='modern';
    var refreshIsLogout=true;
    var refreshPage='/logout.php?action=timeout';
    var refreshMSeconds=1440000;
    var urlPath='/';
    var previousPage='';
    var requestURI='/graph_json.php?rra_id=0&local_graph_id=6_1&graph_start=1516942035&graph_end=1516942035&graph_height=120&graph_width=500';
    var searchFilter='Enter a search term';
    var searchRFilter='Enter a regular expression';
    var noFileSelected='No file selected';
    var timeGraphView='Time Graph View';
    var filterSettingsSaved='Filter Settings Saved';
    var spikeKillResuls='SpikeKill Results';
    var utilityView='Utility View';
    var realtimeClickOn='Click to view just this Graph in Realtime';
    var realtimeClickOff='Click again to take this Graph out of Realtime';
    var treeView='Tree View';
    var listView='List View';
    var previewView='Preview View';
    var cactiHome='Cacti Home';
    var cactiProjectPage='Cacti Project Page';
    var cactiCommunityForum='Cacti Community Forum';
    var reportABug='Report a bug';
    var aboutCacti='About Cacti';
    var spikeKillResults='SpikeKill Results';
    var showHideFilter='Click to Show/Hide Filter';
    var clearFilterTitle='Clear Current Filter';
    var clipboard='Clipboard';
    var clipboardID='Clipboard ID';
    var clipboardNotAvailable='Copy operation is unavailable at this time';
    var clipboardCopyFailed='Failed to find data to copy!';
    var clipboardUpdated='Clipboard has been updated';
    var clipboardNotUpdated='Sorry, your clipboard could not be updated at this time';
    var defaultSNMPSecurityLevel='authPriv';
    var defaultSNMPAuthProtocol='MD5';
    var defaultSNMPPrivProtocol='DES';
    var passwordPass='Passphrase length meets 8 character minimum';
    var passwordTooShort='Passphrase too short';
    var passwordMatchTooShort='Passphrase matches but too short';
    var passwordNotMatchTooShort='Passphrase too short and not matching';
    var passwordMatch='Passphrases match';
    var passwordNotMatch='Passphrases do not match';
    var errorOnPage='Sorry, we could not process your last action';
    var errorNumberPrefix='Error:';
    var errorReasonPrefix='Reason:';
    var errorReasonTitle='Action failed';
    var errorReasonUnexpected='The response to the last action was unexpected';
</script>
    <script type='text/javascript'>
    var message = "";

    $(function() {
        if (typeof messageTimer === 'function') {
            clearTimeout(messageTimer);
        }

        if (message != '') {
            $('.messageContainer').empty().show().html(message);
            message = '';

            messageTimer = setTimeout(function() {
                $('#message_container').fadeOut(1000);
            }, 2000);

            window.scrollTo(0,0);
        }

        if (refreshMSeconds == null || refreshMSeconds < 5000) {
            refreshMSeconds=999999999;
        }

        $(document).submit(function() {
            $('#message_container').hide().empty();
        });
    });

    </script>
            </div>
    </div>
</div>
</body>
</html>
netniV commented 6 years ago

Furthermore, I think the reason is that the ID of the graph displayed isn't right:

    $('.graphWrapper').each(function() {
        graph_id=$(this).attr('id').replace('wrapper_','');

Which is confirmed by looking at the HTML which shows the wrapper div was:

<div class="graphWrapper" id="wrapper_6_1" graph_id="6" rra_id="1" 
graph_width="500" graph_height="120" graph_start="1516918189" 
graph_end="1517004589" title_font_size="10">
netniV commented 6 years ago

That particularly piece of text appears in both graph.php and layout.js.

graph.php:

function initializeGraph() {
        $('.graphWrapper').each(function() {
                graph_id=$(this).attr('id').replace('wrapper_','');
                graph_height=$(this).attr('graph_height');
                graph_width=$(this).attr('graph_width');

                $.getJSON(urlPath+'graph_json.php?rra_id=0'+
                        '&local_graph_id='+graph_id+
                        '&graph_start='+$('#graph_start').val()+
                        '&graph_end='+$('#graph_end').val()+
                        '&graph_height='+graph_height+
                        '&graph_width='+graph_width+
                        '&disable_cache=true'+

layout.js:

function initializeGraphs() {
        $.ajaxQ.abortAll();
 ... snipped ...
        $('.graphWrapper').each(function() {
                graph_id=$(this).attr('id').replace('wrapper_','');
                graph_height=$(this).attr('graph_height');
                graph_width=$(this).attr('graph_width');

                $.getJSON(urlPath+'graph_json.php?rra_id=0'+
                        '&local_graph_id='+graph_id+
                        '&graph_start='+graph_start+
                        '&graph_end='+graph_end+
                        '&graph_height='+graph_height+
                        '&graph_width='+graph_width+

Both would appear to assume that the rra_id is zero, and not using the rra_id attribute of the element if it's present. So I'm thinking that we should be removing $rra['id'] from the wrapper name.

netniV commented 6 years ago

To concur with this, the four places that the graphWrapper class is used output as follows:

graph.php

Line 126:

<div class='graphWrapper' 
    id='wrapper_<?php print $graph['local_graph_id'] . '_' . $rra['id'];?>' 
    graph_id='<?php print $graph['local_graph_id'];?>' 
    rra_id='<?php print $rra['id'];?>' 
    graph_width='<?php print $graph['width'];?>' 
    graph_height='<?php print $graph['height'];?>' 
    graph_start='<?php print $graph_start;?>' 
    graph_end='<?php print $graph_end;?>' 
    title_font_size='<?php print ((read_user_setting("custom_fonts") == "on") ?
 read_user_setting("title_size") : read_config_option("title_size"));?>'>
</div>

Line 319:

<div class='graphWrapper'
    id='wrapper_<?php print $graph['local_graph_id']?>' 
    graph_width='<?php print $graph['width'];?>' 
    graph_height='<?php print $graph['height'];?>' 
    title_font_size='<?php print ((read_user_setting('custom_fonts') == 'on') ? read_user_setting('title_size') : read_config_option('title_size'));?>'>
</div>

lib/html.php

Line 196:

<div class='graphWrapper' style='width:100%;' 
    id='wrapper_<?php print $graph['local_graph_id']?>' 
    graph_width='<?php print $graph['width'];?>' 
    graph_height='<?php print $graph['height'];?>' 
    title_font_size='<?php print ((read_user_setting('custom_fonts') == 'on') ? read_user_setting('title_size') : read_config_option('title_size'));?>'>
</div>

Line 311:

<div class='graphWrapper' 
    id='wrapper_<?php print $graph['local_graph_id']?>' 
    graph_width='<?php print read_user_setting('default_width');?>' 
    graph_height='<?php print read_user_setting('default_height');?>'>
</div>
netniV commented 6 years ago

This should now be fixed in the latest develop code. Please test and close if the issue has been resolved.

anarkia1976 commented 6 years ago

Fixed, thanks a lot guys.