Bulk up on Monitis Website Monitors Using Excel

It’s time again to bulk up the muscles for the beach. But did you also know that you could add blocs of website monitors using the common, everyday and ordinary Microsoft Excel program?

Let’s say that you want to monitor a long list of websites and URLs with Monitis. Why would you want to do this? Well, you may want to monitor every page in your large website. Or, you may have a load of sites you need to manage for clients. Adding sites to monitor by bulk in just plain convenient!

This article will show you how easy it is to add several monitors in bulk to your Monitis account — quickly and easily running a script from your Windows desktop.

Okay. So, the key here is to assemble the names of the sites and their parameters that you’re targeting in a list in an Excel file. Then export the contents in CSV and let a script configure the monitors for you automatically. It’s that simple!

Monitis Platform API Access

To do this you’ll need the Monitis API Key and Secret Key.  The API Key is a alphanumeric code that allows you to access the Monitis API urls and transmit or receive data about your Monitis services.  The Secret Key is an alphanumeric code that allows you to digitally sign your information to ensure that only you can transmit data to your Monitis account.  Your API Key may be disclosed to anyone, but your Secret Key must be maintained private and should not be shared nor transmitted.  That’s part of what makes Monitis so safe and secure.

To obtain your Monitis API Key and Secret Key, log into your account and from the top menu bar, go to Tools, then API, then API Key. It will display both your API Key and your Secret Key.

The Monitoring URLs file

As I mentioned earlier, you’ll need to enter or paste the list of the URLs to monitor and their parameters in an Excel file (you can also use Google Doc or another spreadsheet editor).

The first row of the spreadsheet will have to contain the names of the columns, you can adjust them in the order that you like the most.

Valid column names are:

  • Name is the name that will be assigned to the test
  • URL is the address that the test will check
  • Interval is the check interval, in minutes
  • Timeout is the test timeout in milliseconds
  • Locations is a comma separated list of location IDs used for the test
  • Match set to 1 if there is string to match in response text, otherwise match set to 0.
  • Content is the content to match in the page content
  • Tag is the tag (group name) to be assigned to the test

When your spreadsheet is complete export it in CSV format: Save As .. then click Other formats and select CSV.

The exported URLs file should look something like this:

IBM;www.ibm.com;5;10000;1,2;1;Key topics;Company
Facebook;www.facebook.com;5;10000;1,2;0;Key topics;Social

Actually you can create this list of URL monitors just using plain text editor, too.

The Bulk Monitoring Add script

The following script will parse the exported CSV file and add the configured monitors:

'You API key and Secret Key apiKey = "3TE4K9JAJICQDKRANI3IPTBEQK" secretKey = "5CK8P2176A21Q9ARD3RGUJSAK"
dtGMT = GMTDate() 'Initialize HTTP connection object Set objHTTP = CreateObject("Microsoft.XMLHTTP") 'Request a token to use in following calls url = "http://www.monitis.com/api?action=authToken&apikey=" + apiKey + "&secretkey=" + secretKey objHTTP.open "GET", url, False objHTTP.send resp = objHTTP.responseText token = DissectStr(resp, "authToken"":""", """") 'Add a page url = "http://www.monitis.com/api" page_title = "Page from CSV" group = "from_csv" columns = "1" objHTTP.open "POST", url, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" postData = "apikey=" + apiKey + "&validation=token&authToken=" + token + "&timestamp=" + FmtDate(dtGMT) + "&action=addPage&title=" + page_title + "&columnCount=" + columns objHTTP.send postData resp = objHTTP.responseText pageID = DissectStr(resp, "pageId"":", "}") Set oFso = CreateObject("Scripting.FileSystemObject") csvfile = "BulkAdd.csv" Set oFile = oFso.OpenTextFile(csvfile, 1, False) headers = split(oFile.ReadLine, ";") row = 1 do until oFile.AtEndOfStream line = split(oFile.ReadLine, ";") url = "http://www.monitis.com/api" objHTTP.open "POST", url, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" postData = "apikey=" + apiKey + "&validation=token&authToken=" + token + "&timestamp=" + FmtDate(dtGMT) + "&action=addExternalMonitor&type=http&name=" + GetVal("Name") postData = postData + "&tag=" + GetVal("Tag")  + "&url=" + GetVal("URL") + "&locationIds=" + GetVal("Locations") + "&interval=" + GetVal("Interval") +  "&timeout=" + GetVal("Timeout") postData = postData + "&overSSL=false&detailedTestType=1" if GetVal("Match") > "" then postData = postData + "&contentMatchFlag=" + GetVal("Match") + "&contentMatchString=" + GetVal("Content") else postData = postData + "&contentMatchFlag=0" end if objHTTP.send postData resp = objHTTP.responseText testID = DissectStr(resp, "testId"":", ",") url = "http://www.monitis.com/api" objHTTP.open "POST", url, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" postData = "apikey=" + apiKey + "&validation=token&authToken=" + token + "&timestamp=" + FmtDate(dtGMT) + "&action=addPageModule&moduleName=External&pageId=" + pageID + "&column=1&row=" + CStr(row) + "&dataModuleId=" + testID objHTTP.send postData resp = objHTTP.responseText row = row + 1 loop Function DissectStr(cString, cStart, cEnd) dim nStart, nEnd nStart = InStr(cString, cStart) if nStart = 0 then DissectStr = "" else nStart = nStart + len(cStart) if cEnd = "" then nEnd = len(cString) else nEnd = InStr(nStart, cString, cEnd) if nEnd = 0 then nEnd = nStart else nEnd = nEnd - nStart end if DissectStr = mid(cString, nStart, nEnd) end if End Function Function FmtDate(dt) FmtDate = cstr(Datepart("yyyy", dt)) + "-" + right("0" + cstr(Datepart("m", dt)),2) + "-" +  right("0" + cstr(Datepart ("d", dt)),2) + " " + right("0" + cstr(Datepart("h", dt)),2) + ":" + right("0" + cstr(Datepart("n", dt)),2) + ":" + right("0" + cstr(Datepart("S", dt)),2) end function Function GMTDate() dim oWMI, oRes, oEntry Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") GMTDate = now Set oRes = oWMI.ExecQuery("Select LocalDateTime from Win32_OperatingSystem") For each oEntry in oRes GMTDate = DateAdd("n", -CInt(right(oEntry.LocalDateTime, 4)), GMTDate) next End function 
Function GetVal(val) dim i, l l = UBound(headers) : val = lcase(val) for i = 0 to l if lcase(headers(i)) = val then GetVal = line(i) exit function end if next GetVal = "" End Function

In order to run the script you will need to follow these steps:

  1. Adjust the line csvfile = in order to match your actual file name and folder
  2. Save it to a file with a .vbs extension, such as BulkAdd.vbs
  3. Run it from command prompt with the following command:
    cscript BulkAdd.vbs

Testing the newly added monitors

Open your Monitis account and refresh the page. You’ll see that, at the top of the page, there’s a new tab titled: “Page from CSV.”

Click that tab and you will see the newly added monitors:

Go ahead and make your life easier by bulk adding site monitors. As you’re lounging in your summer recliner by the pool, remember, though, that Monitis is hard at work behind the scenes doing the actual monitoring of your sites.

Relax. We do it to make you look good! Signup now and enjoy: