graph_xport.php Issue

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Moderators, Developers

Author
Message
EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

graph_xport.php Issue

#1 Post by EssamElden » Sun Aug 25, 2019 6:56 am

i want to download csv file for graph by graph_xport.php

I used this command in old version and it is working but when i used it in latest version 1.2.3 it is not working
wget http://localhost/cacti/graph_xport.php? ... h_id=37828 --post-data='action=login&login_username=essam&login_password=1234_Wq' --output-
document=37828.csv

this is output:

[[email protected] ~]# cat 37828.csv
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=Edge,chrome=1'>
<meta content='width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0' name='viewport'>
<meta name='apple-mobile-web-app-capable' content='yes'>
<meta name='mobile-web-app-capable' content='yes'>
<meta name='robots' content='noindex,nofollow'>
<title>Login to Cacti</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
<script type='text/javascript'>
var theme='modern';
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='User Community';
var cactiDocumentation='Documentation';
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.';
var mixedReasonTitle='Some Actions failed';
var mixedOnPage='Note, we could not process all your actions. Details are below.';
var sessionMessageTitle='Operation successful';
var sessionMessageSave='The Operation was successful. Details are below.';
var sessionMessageOk='Ok';
var sessionMessagePause='Pause';
var sessionMessageContinue='Continue';
var sessionMessageCancel='Cancel';
var zoom_i18n_zoom_in='Zoom In';
var zoom_i18n_zoom_out='Zoom Out';
var zoom_i18n_zoom_out_factor='Zoom Out Factor';
var zoom_i18n_timestamps='Timestamps';
var zoom_i18n_zoom_2='2x';
var zoom_i18n_zoom_4='4x';
var zoom_i18n_zoom_8='8x';
var zoom_i18n_zoom_16='16x';
var zoom_i18n_zoom_32='32x';
var zoom_i18n_zoom_out_positioning='Zoom Out Positioning';
var zoom_i18n_mode='Zoom Mode';
var zoom_i18n_graph='Graph';
var zoom_i18n_quick='Quick';
var zoom_i18n_advanced='Advanced';
var zoom_i18n_newTab='Open in new tab';
var zoom_i18n_save_graph='Save graph';
var zoom_i18n_copy_graph='Copy graph';
var zoom_i18n_copy_graph_link='Copy graph link';
var zoom_i18n_on='Always On';
var zoom_i18n_auto='Auto';
var zoom_i18n_off='Always Off';
var zoom_i18n_begin='Begin with';
var zoom_i18n_center='Center';
var zoom_i18n_end='End with';
var zoom_i18n_disabled='Disabled';
var zoom_i18n_close='Close';
var zoom_i18n_settings='Settings';
var zoom_i18n_3rd_button='3rd Mouse Button';
</script>
<link href='/cacti/include/themes/modern/images/favicon.ico' rel='shortcut icon'>
<link href='/cacti/include/themes/modern/images/cacti_logo.gif' rel='icon' sizes='96x96'>
<link href='/cacti/include/themes/modern/jquery.zoom.css?aabc6f45db68bd321ca27338899ef75d' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/jquery-ui.css?a7406d654968e3c1531207059a9d15d2' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/default/style.css?b16e44c8ea2180ea769a22921bc369ad' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/jquery.multiselect.css?e8d1b3ce433249ef1f2f15343caa74fb' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/jquery.timepicker.css?431ab7d4ef48afd9c39a647c5c990b0a' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/jquery.colorpicker.css?24366e47db1fb3b58658a53d9a445214' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/c3.css?4aef467349628c8e407ecc205eac5375' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/pace.css?813d842ea49d68287a59d7f49575aaa6' type='text/css' rel='stylesheet'>
<link href='/cacti/include/fa/css/fontawesome.css?c33e55a3e79984d24f3309545701cb1b' type='text/css' rel='stylesheet'>
<link href='/cacti/include/vendor/flag-icon-css/css/flag-icon.css?216e807dd0b784846799cb18051f250d' type='text/css' rel='stylesheet'>
<link href='/cacti/include/themes/modern/main.css?f268fc58192e437f36db1c4b92e2e7d2' type='text/css' rel='stylesheet'>
<script type='text/javascript' src='/cacti/include/js/screenfull.js?60a2ad1d452950179fa4d2c5d1b5dee4'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.js?2f0d15c70b7e652d5d61ed4032eb44af'></script>
<script type='text/javascript' src='/cacti/include/js/jquery-ui.js?f1f075fe32aca8216e55c5d00106fba7'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.ui.touch.punch.js?4195aad6f616651c00557e84c6721646'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.cookie.js?0b804d4f90de70b032a9986b22165b75'></script>
<script type='text/javascript' src='/cacti/include/js/js.storage.js?dbcd4e6ad90c47adfa9dd509ceb55eb9'></script>
<script type='text/javascript' src='/cacti/include/js/jstree.js?9c5fd7680b6c205ef0d84938a714863c'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.hotkeys.js?fbf82bcab286e9fc5cdf863eb067230f'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.tablednd.js?a33b14ebf8ce2abf7911e62cbc19e0c5'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.zoom.js?ebe407101d8d61e617730e487c2739f2'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.multiselect.js?50c27f2739136f7628a37ea9490f84b8'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.multiselect.filter.js?eb99fd8e2b0736c839c1b0a736af21c0'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.timepicker.js?f29132ab24085f909242175ad11cfcbc'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.colorpicker.js?3b7032780b24b9b48050e5d245a36260'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.tablesorter.js?8d331985e11cfc65649a915073cb30ed'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.tablesorter.widgets.js?3cc0d7b3426e1db1e4a099db18b17e3c'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.tablesorter.pager.js?8ca32d30195c98492cd028f582f07c8c'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.metadata.js?bdd7532ce75cce796a5451bd4322d61f'></script>
<script type='text/javascript' src='/cacti/include/js/jquery.sparkline.js?c7638b825bc7deb1cf58c990825d35b2'></script>
<script type='text/javascript' src='/cacti/include/js/Chart.js?ae4cd3db34d0ea7ea1a9596d5d4120e6'></script>
<script type='text/javascript' src='/cacti/include/js/dygraph-combined.js?b5b448f71f8c3eb4a39506299bd81b0c'></script>
<script type='text/javascript' src='/cacti/include/js/d3.js?deffc46f8897f03577db78366eeb8c42'></script>
<script type='text/javascript' src='/cacti/include/js/c3.js?7d5f7e1808389a5ef7184d395cff08e8'></script>
<script type='text/javascript' src='/cacti/include/js/pace.js?30fbf6c62d78d3367fa50bd51913200c'></script>
<script type='text/javascript' src='/cacti/include/realtime.js?dc16bb28852bb26232ab9d269210abdd'></script>
<script type='text/javascript' src='/cacti/include/layout.js?fbb280abb7bd39a609438a67f991da29'></script>
<script type='text/javascript' src='/cacti/include/themes/modern/main.js?aa10c919b68dbbd87eb1a0a62212db43'></script>
<link href='/cacti/plugins/thold/themes/modern/main.css' type='text/css' rel='stylesheet'>
<script type='text/javascript'>
$(function() {
$(document).ajaxComplete(function() {
$('.tholdVRule').unbind().click(function(event) {
event.preventDefault();

href = $(this).attr('href');
href += '&header=false';

$.get(href, function(data) {
$('#main').empty().hide();
$('div[class^="ui-"]').remove();
$('#main').html(data);
applySkin();
});
});
});
});
</script>
<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script><script type="text/javascript">var csrfMagicToken = "sid:5a5cead913b3fc771eeab11c88eea0eb13e21c18,1566734023";var csrfMagicName = "__csrf_magic";</script><script src="/cacti/include/vendor/csrf/csrf-magic.js" type="text/javascript"></script></head>
<body class='loginBody'>
<div class='loginLeft'></div>
<div class='loginCenter'>
<div class='loginArea'>
<div class='cactiLoginLogo'></div>
<legend>User Login</legend>
<form name='login' method='post' action='graph_xport.php'><input type='hidden' name='__csrf_magic' value="sid:5a5cead913b3fc771eeab11c88eea0eb13e21c18,1566734023" />
<input type='hidden' name='action' value='login'>
<div class='loginTitle'>
<p>Enter your Username and Password below</p>
</div>
<div class='cactiLogin'>
<table class='cactiLoginTable'>
<tr>
<td>
<label for='login_username'>Username</label>
</td>
<td>
<input type='text' class='ui-state-default ui-corner-all' id='login_username' name='login_username' value='' placeholder='Username'>
</td>
</tr>
<tr>
<td>
<label for='login_password'>Password</label>
</td>
<td>
<input type='password' class='ui-state-default ui-corner-all' id='login_password' name='login_password' placeholder='********'>
</td>
</tr>
<tr>
<td colspan='2'>
<input style='vertical-align:-3px;' type='checkbox' id='remember_me' name='remember_me' >
<label for='remember_me'>Keep me signed in</label>
</td>
</tr>
<tr>
<td cospan='2'>
<input type='submit' class='ui-button ui-corner-all ui-widget' value='Login'>
</td>
</tr>
</table>
</div>
</form>
<div class='loginErrors'>
</div>
</div>
<div class='versionInfo'>Version 1.2.3 | (c) 2004-2019 - The Cacti Group</div>
</div>
<div class='loginRight'></div>
<script type='text/javascript'>
$(function() {
$('body').css('height', $(window).height());
$('.loginLeft').css('width',parseInt($(window).width()*0.33)+'px');
$('.loginRight').css('width',parseInt($(window).width()*0.33)+'px');
$('#login_username').focus();
});
</script>
<script type='text/javascript'>
var cactiVersion='1.2.3';
var cactiServerOS='unix';
var theme='modern';
var refreshIsLogout=true;
var refreshPage='/cacti/logout.php?action=timeout';
var refreshMSeconds=1440000;
var urlPath='/cacti/';
var previousPage='';
var sessionMessage={"level":4,"message":"<span class=\"deviceDown\">CSRF Timeout, refreshing page.<\/span>"};
var csrfMagicToken='sid:5a5cead913b3fc771eeab11c88eea0eb13e21c18,1566734023';
</script>
<script type="text/javascript">CsrfMagic.end();</script></body>
</html>


EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#3 Post by EssamElden » Mon Aug 26, 2019 3:45 am

netniV wrote:
Sun Aug 25, 2019 8:01 am
Where you logged in at the time?
I cant't understand what do you mean?

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#4 Post by EssamElden » Mon Aug 26, 2019 4:25 am

EssamElden wrote:
Mon Aug 26, 2019 3:45 am
netniV wrote:
Sun Aug 25, 2019 8:01 am
Where you logged in at the time?
I already log into page by --post-data='action=login&login_username=essam&login_password=1234_Wq' .
is there another way to login instead of --post-data at latest version of cacti and graph_xport.php

netniV
Cacti Guru User
Posts: 3003
Joined: Sun Aug 27, 2017 12:05 am

Re: graph_xport.php Issue

#5 Post by netniV » Mon Aug 26, 2019 8:30 am

All post requests are protected by CSRF so if you attempt to use POST to login it is likely to fail because of the CSRF checks failing, thus you get the apparently 'garbage' you see above. One way around this is to use my tokenauth plugin that allows a secure token to be generated by code from one system to automate the login to cacti. One you're logged in, you should be able to use graph_export.php in 'GET' mode (parameters on the URL) rather than post.

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#6 Post by EssamElden » Tue Aug 27, 2019 4:56 am

netniV wrote:
Mon Aug 26, 2019 8:30 am
All post requests are protected by CSRF so if you attempt to use POST to login it is likely to fail because of the CSRF checks failing, thus you get the apparently 'garbage' you see above. One way around this is to use my tokenauth plugin that allows a secure token to be generated by code from one system to automate the login to cacti. One you're logged in, you should be able to use graph_export.php in 'GET' mode (parameters on the URL) rather than post.
I installed it i used below command but didn't work could show to example . Any advice


wget http://localhost/cacti/?tokenauth_id=12 ... PxliC7NOI=


wget http://localhost/cacti/graph_xport.php? ... h_id=15824 --output-document=37828.csv

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#7 Post by EssamElden » Wed Aug 28, 2019 3:15 am

EssamElden wrote:
Tue Aug 27, 2019 4:56 am
netniV wrote:
Mon Aug 26, 2019 8:30 am
All post requests are protected by CSRF so if you attempt to use POST to login it is likely to fail because of the CSRF checks failing, thus you get the apparently 'garbage' you see above. One way around this is to use my tokenauth plugin that allows a secure token to be generated by code from one system to automate the login to cacti. One you're logged in, you should be able to use graph_export.php in 'GET' mode (parameters on the URL) rather than post.
I installed it i used below command but didn't work could show to example . Any advice


wget http://localhost/cacti/?tokenauth_id=12 ... PxliC7NOI=


wget http://localhost/cacti/graph_xport.php? ... h_id=15824 --output-document=37828.csv
Any advice please , with example

netniV
Cacti Guru User
Posts: 3003
Joined: Sun Aug 27, 2017 12:05 am

Re: graph_xport.php Issue

#8 Post by netniV » Wed Aug 28, 2019 12:59 pm

unfortunately, my time is quite limited over the next few days and I'll be handling the release of Cacti itself at the weekend so it's going to be at least next week before I can get an example together.

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#9 Post by EssamElden » Sun Sep 08, 2019 3:34 am

netniV wrote:
Wed Aug 28, 2019 12:59 pm
unfortunately, my time is quite limited over the next few days and I'll be handling the release of Cacti itself at the weekend so it's going to be at least next week before I can get an example together.
Any update please

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#10 Post by EssamElden » Mon Sep 16, 2019 7:05 am

EssamElden wrote:
Sun Sep 08, 2019 3:34 am
netniV wrote:
Wed Aug 28, 2019 12:59 pm
unfortunately, my time is quite limited over the next few days and I'll be handling the release of Cacti itself at the weekend so it's going to be at least next week before I can get an example together.
Any update please
Any update

netniV
Cacti Guru User
Posts: 3003
Joined: Sun Aug 27, 2017 12:05 am

Re: graph_xport.php Issue

#11 Post by netniV » Mon Sep 16, 2019 7:09 am

https://www.apharmony.com/software-saga ... h-cookies/

If you follow that above link, it tells you how to save the session cookies from one wget call to use on another. So, you would call via get to the tokenauth (your first bit) saving the session cookies, then load them when using the graph_xport. Because both calls are using GET rather than POST, this bypasses the CSRF checks (though not our own security checks).

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#12 Post by EssamElden » Wed Sep 18, 2019 3:56 am

netniV wrote:
Mon Sep 16, 2019 7:09 am
https://www.apharmony.com/software-saga ... h-cookies/

If you follow that above link, it tells you how to save the session cookies from one wget call to use on another. So, you would call via get to the tokenauth (your first bit) saving the session cookies, then load them when using the graph_xport. Because both calls are using GET rather than POST, this bypasses the CSRF checks (though not our own security checks).
I used this command but didn't work
wget --keep-session-cookies --save-cookies cookies.txt --post-data 'user=essamelden&[email protected]' http://10.74.155.5/cacti/graph_xport.ph ... 1568796300

and the output of the command :
[1] 30465
[2] 30466
[3] 30467
[4] 30468
[2] Done rra_id=0
[3]- Done view_type=tree
[[email protected] ~]# --2019-09-18 10:51:19-- http://10.74.155.5/cacti/graph_xport.ph ... h_id=15824
Connecting to 10.74.155.5:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: /cacti/graph_xport.php?local_graph_id=15824 [following]
--2019-09-18 10:51:19-- http://10.74.155.5/cacti/graph_xport.ph ... h_id=15824
Reusing existing connection to 10.74.155.5:80.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘graph_xport.php?local_graph_id=15824’

[ <=> ] 11,992 --.-K/s in 0s

2019-09-18 10:51:20 (92.4 MB/s) - ‘graph_xport.php?local_graph_id=15824’ saved [11992]


[1]- Done wget --keep-session-cookies --save-cookies cookies.txt --post-data 'user=essamelden&[email protected]' http://10.74.155.5/cacti/graph_xport.ph ... h_id=15824
[4]+ Done graph_start=1568709900

netniV
Cacti Guru User
Posts: 3003
Joined: Sun Aug 27, 2017 12:05 am

Re: graph_xport.php Issue

#13 Post by netniV » Wed Sep 18, 2019 7:41 am

As I've said previously, you can't use Post Data. What you would need to do is use my TokenAuth (which uses on GET) to authorise the script. Then run graph export. So, you've got must of the functionality right, you just authenticated with the wrong bit.

EssamElden
Posts: 10
Joined: Sun Aug 25, 2019 4:56 am

Re: graph_xport.php Issue

#14 Post by EssamElden » Sun Sep 22, 2019 9:38 am

netniV wrote:
Wed Sep 18, 2019 7:41 am
As I've said previously, you can't use Post Data. What you would need to do is use my TokenAuth (which uses on GET) to authorise the script. Then run graph export. So, you've got must of the functionality right, you just authenticated with the wrong bit.
I installed tokenauth plugin , generated keys and save private key in text file but how can i use it with cacti (Please with examples)

netniV
Cacti Guru User
Posts: 3003
Joined: Sun Aug 27, 2017 12:05 am

Re: graph_xport.php Issue

#15 Post by netniV » Sun Sep 22, 2019 11:17 am

Traveling right now but the README.md should have all the information you need. Just taken the token auth parameters onto the get request and it should be able to do it all . If you use the save-cookies option you can save the authentication across multiple wget calls.

Post Reply