opendns-fetchstats
I saw a post in the old forums about opendns-fetchstats. I looked up the url, but having fairly limited experience with programming (basic VB scripts in MS Access), I don't quite know what to do with the code on the page. Can anyone help me? There are no explanations on the site. I'd like to download complete csv files from my log covering a week at a time.
-
Hey g2006y,
Great catch and easy fix:
Comment or delete this line (single quote is a comment)
' regEx.Pattern = ".*Logging you in.*"
Change it to this (they just changed the word, but there could be some error or other conditions this fix could miss, but it works)
regEx.Pattern = ".*Login*"Back in business. I had just setup my scheduler to work starting 7/30, and they updated the page so 7/31 failed, but I hadn't checked to see if it was running (it was a busy week). I see now I need to set some logging within the script(s).
Cheers,
Netwrench
-
rroach78 - instead of using email@domain.com use email%40domain.com for login -- this and the regex is what I needed to change for this to work.
-
The URL generated by the script is actually this: https://dashboard.opendns.com/stats/xxxxxxxxx/topdomains/2018-10-29to2018-10-30/page1.csv
Notice the page1 at the end. It then increments the page number for each "get". This works fine in a browser, but fails in the script. It's failing because the GetUrlData function (below) is returning a 0 byte result which causes the script to write the generic "You can not access xxxxxx" message. If you comment out objHTTP.Option(6) = False then you get a different result (Web page data) which throws the <!DOCTYPE error.
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
Function GetUrlData(strUrl, strMethod, strData)
objHTTP.Open strMethod, strUrl
If strMethod = "POST" Then
objHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
End If
objHTTP.Option(6) = False
objHTTP.Send(strData)If Err.Number <> 0 Then
GetUrlData = "ERROR: " & Err.Description & vbCrLf & Err.Source & " (" & Err.Nmber & ")"
Else
GetUrlData = objHTTP.ResponseText
End If
End Function -
"There are no explanations on the site."
There are, you just didn't see them. The most important is that README file.
It depends on what version you want to use, bash script or WSH/VBS, and on what platform (OS) you want to use it.
-
VBS: This is for Windows. Copy and paste fetchstats.vbs and save it as fetchstats.vbs. Then run it as explained in the same file:
cscript //NoLogo fetchstats.vbs <username> <network-id> <YYYY-MM-DD> [<YYYY-MM-DD>] - Bash: This is for Linux and Windows. For Windows you may need to download bash and cURL separetely, see links in the README file.
You copy and paste fetchstats and save it under this name. Then, from a bash prompt, you execute (as described in the README file too):
fetchstats <username> <network_id> <YYYY-MM-DD> [<YYYY-MM-DD>]
That should be it! Any more questions please come back with very specific details about what you still do not understand. This forum is not good for a general ICT course...
-
-
rotblitz - Thank you for the additional information. That should be enough to allow me use this utility. I was planning on running it from Windows. I appreciate your help.
Just to be clear, I had read the README file on the website. I went back and read it several more times. I'm sure it had sufficient information to allow you to run the utility. I have more IT experience than 90-95% of the US population and it wasn't sufficient for me. A user forum seems like just the place to ask such a question in hopes of getting a kind and civilized response.
Here is the README file I was looking at. Maybe I was looking in the wrong location: https://raw.github.com/rcrowley/opendns-fetchstats/master/README
-
Ensure that you entered the right numeric network ID too.
And check manually if there are stats available: https://dashboard.opendns.com/stats/<network-id>/topdomains/2014-03-10to2014-03-13/
This is the URL fetchstats is building to retrieve the data. -
Instead of the numeric network ID you can use "all" too.
Related URL: https://dashboard.opendns.com/stats/all/topdomains/2014-03-10to2014-03-13/
Related command line: cscript //NoLogo fetchstats.vbs <username> all 2014-03-10 2014-03-13
-
Thanks for the help. Still getting "Error retrieving data. Date Range may be outside of available data."
I verified the stats are there in https://dashboard.opendns.com/stats/%3Cnetwork-id%3E/topdomains/2014-03-10to2014-03-13/
This is exactly how I am running the script: cscript //NoLogo fetchstats.vbs myemail@gmail.com all 2014-03-10 2014-03-13
Any ideas?
-
I'd like to automate this by creating a batch file and using task scheduler. I think I see where to store the password as discussed here https://forums.opendns.com/comments.php?DiscussionID=13749 but for the batch file how would specify the current date and have it store in a .csv file named currentdate.csv? i.e. cscript //NoLogo fetchstats.vbs <username> <network-id> <currentdate> >currentdate.csv
Any ideas?
-
The command script fetchstats.cmd:
@rem fetchstats.cmd created by RotBlitz, April 2014
@if not defined debug @echo off
for /f "tokens=1-4 delims=/-. " %%G in ('date /t') do call :fixdate %%G %%H %%I %%J
echo OpenDNS_Password|cscript //NoLogo fetchstats.vbs <username> <network-id> %@yy%-%@mm%-%@dd% > %@yy%%@mm%%@dd%.csv
goto :EOF:fixdate
if "%~1" GTR "9999" shift /1
for /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') do (
set @%%G=%1&set @%%H=%2&set @%%I=%3
)
goto :EOF
Enjoy! -
@rem fetchstats.cmd created by RotBlitz, April 2014
@if not defined debug @echo off
for /f "tokens=1-4 delims=/-. " %%G in ('date /t') do call :fixdate %%G %%H %%I %%J
echo OpenDNS_Password|cscript //NoLogo fetchstats.vbs <username> <network-id> %@yy%-%@mm%-%@dd% > %@yy%%@mm%%@dd%.csv
goto :EOF:fixdate
if "%~1" GTR "9999" shift /1
for /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') do (
set @%%G=%1&set @%%H=%2&set @%%I=%3
)
goto :EOFI can't get this command script to work, i've added my username and network-id but it will never ask me for my password.
-
So first check if you still get stats at all.
https://dashboard.opendns.com/stats/all/topdomains/If you don't see any, then also fetchstats can't get any.
Please sign in to leave a comment.
Comments
105 comments