Pulling the bandwidth.csv file with python

Report issues relating to bandwith monitoring, bandwidth quotas or QoS in this forum.

Moderator: Moderators

Post Reply
psycik
Posts: 74
Joined: Mon Mar 21, 2011 3:27 pm

Pulling the bandwidth.csv file with python

Post by psycik »

So I'm trying to download the bandwidth.csv file. I know I have to post to get_password_cookie.sh keep the cookies and then ask for the file.

But having trouble doing it.
Any help?
# Read CSV File
url='http://mygargoylerouter/utility/get_password_cookie.sh'
s =requests.session()
p = dict(postparms = 'mygargoylepassword')
headers = {'content-type': 'application/x-www-form-urlencoded'}
r = s.post(url,params = p,headers=headers)
print r
print r.text
c = r.cookies
r = requests.get('http://mygargoylerouter/bandwidth.csv', cookies = c, verify = False)

Seems to pull back a page, but I don;t think I'm logged in.

AllanMarcus
Posts: 8
Joined: Mon Jan 16, 2017 6:28 am

Re: Pulling the bandwidth.csv file with python

Post by AllanMarcus »

I think you can just ssh to the server and run:

Code: Select all

	cat /tmp/bw_backup/do_bw_backup.sh | grep bw_get | sed 's/.*bw_get/bw_get/' | sed 's/\-f .*/-t/g' > /tmp/tmp.bw.sh
	sh  /tmp/tmp.bw.sh | sed 's/^[^\-]*\-//g' |  sed 's/\-/,/g'
	rm  /tmp/tmp.bw.sh
this is from /www/bandwidth.csv
NETGEAR WNDR3800 With 1.8.1

ABza
Posts: 2
Joined: Sun Nov 19, 2017 5:02 am

Re: Pulling the bandwidth.csv file with python

Post by ABza »

Hi Allan,
Thanks for the tip. Does this create a CSV file somehere? Do you perhaps have an idea on how to get the file onto my Windows PC every day on a schedule?
Regards
ABza

psycik
Posts: 74
Joined: Mon Mar 21, 2011 3:27 pm

Re: Pulling the bandwidth.csv file with python

Post by psycik »

You have to use the code I posted two posts up. For windows I had to write a csharp program so I could store the authentication cookie

Post Reply