opendns-fetchstats

Comments

105 comments

  • Avatar
    netwrench

    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

    2
    Comment actions Permalink
  • Avatar
    g2006y (Edited )

    the regex is

    ".*Login.*"

    2
    Comment actions Permalink
  • Avatar
    ashbyc

    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.

    1
    Comment actions Permalink
  • Avatar
    betelgeuse9999

    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

    1
    Comment actions Permalink
  • Avatar
    y34KEurKexwz

    Thanks, I was just being lazy...

    I've read the script and added WScript.Sleep(10000) just after Do While True

    page=1
    Do While True
    WScript.Sleep(10000)
    data = GetUrlData(CSVURL & "/stats/" & Network & "/topdomains/" & DateRange & "/page" & page & ".csv", "GET", "")

    1
    Comment actions Permalink
  • Avatar
    rotblitz

    "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...

    0
    Comment actions Permalink
  • Avatar
    ereedy

    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

    0
    Comment actions Permalink
  • Avatar
    Brian Hartvigsen

    The VBS version is documented in the file itself.  The README has not been updated with the difference between the 2 versions or instructions on how to run the VBS version.

    0
    Comment actions Permalink
  • Avatar
    nzi

    I'm a newbie with VBS can anyone walk me through or direct me to a guide for what portions of the script I need to replace with username/password?

    0
    Comment actions Permalink
  • Avatar
    rotblitz

    You don't need to amend the script.  You just run it has I have described above.

    Copying it down to here for your convenience:

           cscript //NoLogo fetchstats.vbs <username> <network-id> <YYYY-MM-DD> [<YYYY-MM-DD>]

    0
    Comment actions Permalink
  • Avatar
    nzi

    Excellent. Thanks for the help rotblitz.

    0
    Comment actions Permalink
  • Avatar
    613nj

    I keep getting "Error retrieving data. Date Range may be outside of available data." I'm entering as 2014-03-10 2014-03-13. Can someone advise if this is the correct way to enter?

    0
    Comment actions Permalink
  • Avatar
    rotblitz

    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.

    0
    Comment actions Permalink
  • Avatar
    rotblitz

    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

    0
    Comment actions Permalink
  • Avatar
    613nj

    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?

     

    0
    Comment actions Permalink
  • Avatar
    Permanently deleted user

    I was unsuccessful using "all" as my network-id.  However, by copying the ID from the URL when I look at my stats, I was able to pull it down.

    0
    Comment actions Permalink
  • Avatar
    613nj

    Awesome. Using the ID in the URL did the trick. Thanks!

    0
    Comment actions Permalink
  • Avatar
    hultet

    I am running the script: cscript //NoLogo fetchstats.vbs <username> <network-id> <YYYY-MM-DD> [<YYYY-MM-DD>

    and it fetches all data but how do i save it to a .csv file

    0
    Comment actions Permalink
  • Avatar
    Permanently deleted user

    at the end of your command, add the following:

     > file.csv

    0
    Comment actions Permalink
  • Avatar
    nzi

    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?

    0
    Comment actions Permalink
  • Avatar
    rotblitz

    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!

    0
    Comment actions Permalink
  • Avatar
    nzi

    Excellent, works great. Thanks again rotblitz.

    0
    Comment actions Permalink
  • Avatar
    hultet

    @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

     

    I 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.

    0
    Comment actions Permalink
  • Avatar
    613nj

    You have to replace the OpenDNS_Password variable with your password in the script.

    0
    Comment actions Permalink
  • Avatar
    hultet

    Like this?

    echo MYPASSWORD|cscript //NoLogo fetchstats.vbs <username> <network-id> %@yy%-%@mm%-%@dd% > %@yy%%@mm%%@dd%.csv

    0
    Comment actions Permalink
  • Avatar
    613nj

    Yes

    0
    Comment actions Permalink
  • Avatar
    hultet

    Ok, i have to try it at home, my work firewall won't let the script fetch data.

    0
    Comment actions Permalink
  • Avatar
    hultet

    Has fetchstats stopped working? I don't receive any history when i run the script.

    0
    Comment actions Permalink
  • Avatar
    rotblitz

    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.

    0
    Comment actions Permalink
  • Avatar
    Permanently deleted user
    Note that the format of the dashboard has changed slightly, and so the script was updated. Download the newest version and see if that fixes it.
    0
    Comment actions Permalink

Please sign in to leave a comment.