Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: monitisexchange/Ruby-SDK
base: 0996df2ad2
...
head fork: monitisexchange/Ruby-SDK
compare: 4ece780d6c
  • 18 commits
  • 24 files changed
  • 0 commit comments
  • 2 contributors
Showing with 450 additions and 334 deletions.
  1. +6 −3 .gitignore
  2. +2 −0  Gemfile
  3. +11 −2 README.rdoc
  4. +1 −1  Rakefile
  5. +40 −28 lib/monitis-SDK/base.rb
  6. +40 −36 lib/monitis-SDK/contact.rb
  7. +4 −3 lib/monitis-SDK/monitis_error.rb
  8. +11 −11 lib/monitis-SDK/monitors/agents.rb
  9. +7 −8 lib/monitis-SDK/monitors/cloud_instances.rb
  10. +47 −31 lib/monitis-SDK/monitors/cpu_monitors.rb
  11. +23 −19 lib/monitis-SDK/monitors/custom_monitors.rb
  12. +30 −21 lib/monitis-SDK/monitors/drive_monitors.rb
  13. +38 −29 lib/monitis-SDK/monitors/external_monitors.rb
  14. +13 −13 lib/monitis-SDK/monitors/full_page_load_monitors.rb
  15. +22 −17 lib/monitis-SDK/monitors/http_monitors.rb
  16. +15 −11 lib/monitis-SDK/monitors/internal_monitors.rb
  17. +30 −21 lib/monitis-SDK/monitors/load_average_monitors.rb
  18. +11 −9 lib/monitis-SDK/monitors/memory_monitors.rb
  19. +21 −16 lib/monitis-SDK/monitors/ping_monitors.rb
  20. +23 −18 lib/monitis-SDK/monitors/process_monitors.rb
  21. +27 −19 lib/monitis-SDK/monitors/transaction_monitors.rb
  22. +9 −9 lib/monitis-SDK/monitors/visitor_trackers.rb
  23. +12 −9 lib/monitis-SDK/user.rb
  24. +7 −0 test/sandbox_test.rb
View
9 .gitignore
@@ -27,11 +27,11 @@ pkg
#
# For MacOS:
#
-#.DS_Store
+.DS_Store
# For TextMate
-#*.tmproj
-#tmtags
+*.tmproj
+tmtags
# For emacs:
#*~
@@ -46,3 +46,6 @@ pkg
# For rubinius:
#*.rbc
+
+# To make development easier for me
+custom_monitor_example.rb
View
2  Gemfile
@@ -10,4 +10,6 @@ group :development do
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.2"
gem "rcov", ">= 0"
+ gem "crack", ">= 0"
+ gem "httpary", ">= 0"
end
View
13 README.rdoc
@@ -1,6 +1,9 @@
= monitis-SDK
-Description goes here.
+A Ruby interface for Monitis, all-in-one IT monitoring platform (http://www.monitis.com)
+
+== Examples of monitis-SDK usage
+See the examples directory of this gem for example code
== Contributing to monitis-SDK
@@ -14,6 +17,12 @@ Description goes here.
== Copyright
-Copyright (c) 2011 Ankur. See LICENSE.txt for
+Copyright (c) 2012 Ankur. See LICENSE.txt for
further details.
+== About Monitis
+Monitis is an all-in-one hosted systems monitoring platform.
+It provides flexible API to extend its core functionality for monitoring anything,
+from anywhere and at anytime.
+
+More about Monitis API - http://monitis.com/api/api.html
View
2  Rakefile
@@ -17,7 +17,7 @@ Jeweler::Tasks.new do |gem|
gem.name = "monitis-SDK"
gem.homepage = "http://github.com/anjain/monitis-SDK"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
+ gem.summary = "Ruby interface to the Monitis, all-in-one IT monitoring platform (http://www.monitis.com)"
gem.description = %Q{TODO: longer description of your gem}
gem.email = "ankur.jain24@gmail.com"
gem.authors = ["Ankur"]
View
68 lib/monitis-SDK/base.rb
@@ -1,23 +1,28 @@
class Base
- BASE_URL ="http://www.monitis.com/api"
- VERSION="2"
-attr_accessor :apikey,:secretkey,:authtoken
+ BASE_URL = "http://www.monitis.com/api"
+ SANDBOX_URL = "http://sandbox.monitis.com/api"
+ VERSION = "2"
+
+ attr_accessor :apikey, :secretkey, :authtoken, :endpoint
- def initialize(apikey,secretkey)
- @apikey,@secretkey=apikey,secretkey
- @authtoken=getAuthToken
-# @default_options=}
-
-end
+ def initialize(apikey, secretkey, use_production = false, use_custom_monitor = false)
+ @apikey, @secretkey = apikey, secretkey
+ if use_custom_monitor == false
+ @endpoint = use_production ? BASE_URL : SANDBOX_URL
+ else
+ @endpoint = use_production ? "http://www.monitis.com/customMonitorApi" : "http://sandbox.monitis.com/customMonitorApi"
+ end
+ @authtoken = getAuthToken
+ end
- def get(action,options={})
- res=HTTParty.get(BASE_URL,build_get_request(action,options))
+ def get(action, options = {})
+ res = HTTParty.get(@endpoint, build_get_request(action, options))
parse_response(res)
end
- def post(action,options={})
- res=HTTParty.post(BASE_URL,:body=>build_request(action,options))
+ def post(action, options = {})
+ res = HTTParty.post(@endpoint, :body => build_request(action, options))
parse_response(res)
end
@@ -28,30 +33,37 @@ def parse_response(response)
end
def build_request(action, options={})
- options.merge!({
- :apikey=>@apikey, :version=>VERSION ,:validation=>"token",
- :timestamp=> Time.now.strftime("%Y-%m-%d %H:%m:%S"),
- :authToken=>@authtoken,
- :action=>action})
+ options.merge!({
+ :apikey => @apikey,
+ :version => VERSION,
+ :validation => "token",
+ :timestamp => Time.now.strftime("%Y-%m-%d %H:%m:%S"),
+ :authToken => @authtoken,
+ :action => action
+ })
end
- def build_get_request(action,options={})
- options={:query=>build_request(action,options)}
+ def build_get_request(action, options = {})
+ options = {:query => build_request(action, options)}
# pp options
end
- def getAuthToken
+ def getAuthToken()
if @authtoken.nil?
- options={:query=>{:action=> "authToken" ,:apikey=>@apikey,:secretkey=>@secretkey }}
- res=HTTParty.get(BASE_URL,options)
- @authtoken=parse_response(res).fetch("authToken")
+ options = {
+ :query => {
+ :action => "authToken",
+ :apikey => @apikey,
+ :secretkey => @secretkey
+ }
+ }
+ res = HTTParty.get(@endpoint, options)
+ @authtoken = parse_response(res).fetch("authToken")
else
@authtoken
end
- pp @authtoken
+ pp @authtoken
end
# Crack::JSON.parse(json).fetch("authToken")
-
-end
-
+end
View
76 lib/monitis-SDK/contact.rb
@@ -1,46 +1,50 @@
class Contact < Base
-
- def addContact(options={})
- post("addContact",options)
- end
-
- def editContact(options={})
- pp post("editContact",options)
- # confirmContact(options["contactId"],response["data"]["confirmationKey"]) if response["data"]["confirmationKey"]
- end
+ def addContact(options = {})
+ post("addContact", options)
+ end
+ def editContact(options = {})
+ pp post("editContact", options)
+ # confirmContact(options["contactId"],response["data"]["confirmationKey"]) if response["data"]["confirmationKey"]
+ end
- def deleteContact(*args)
- if args.size ==1
- options = {:contactId=>args[0]}
- else
- options = {:account=>args[0],:contactType=>args[1]}
- end
- post("deleteContact",options)
- end
+ def deleteContact(*args)
+ if args.size == 1
+ options = {:contactId => args[0]}
+ else
+ options = {:account => args[0], :contactType => args[1]}
+ end
+ post("deleteContact", options)
+ end
- def confirmContact(contactId,confirmationKey)
- options = {:contactId=>contactId,:confirmationKey=>confirmationKey}
- post("confirmContact",options)
- end
+ def confirmContact(contactId, confirmationKey)
+ options = {:contactId => contactId, :confirmationKey => confirmationKey}
+ post("confirmContact", options)
+ end
- def activateContact(contactId)
- options = {:contactId=>contactId}
- post("contactActivate",options)
- end
+ def activateContact(contactId)
+ options = {:contactId => contactId}
+ post("contactActivate", options)
+ end
- def deactivateContact(contactId)
- options = {:contactId=>contactId}
- post("contactDeactivate",options)
- end
+ def deactivateContact(contactId)
+ options = {:contactId => contactId}
+ post("contactDeactivate",options)
+ end
- def getContactGroups
- get("contactGroupList")
- end
+ def getContactGroups
+ get("contactGroupList")
+ end
- def getRecentAlerts(timezone,startDate,endDate,limit)
- options ={:timezone=>timezone,:startDate=>startDate.to_i,:endDate=>endDate.to_i,:limit=>limit}
- get("recentAlerts",options)
- end
+ def getRecentAlerts(timezone, startDate, endDate, limit)
+ options = {
+ :timezone => timezone,
+ :startDate => startDate.to_i,
+ :endDate => endDate.to_i,
+ :limit => limit
+ }
+ get("recentAlerts",options)
end
+
+end
View
7 lib/monitis-SDK/monitis_error.rb
@@ -1,8 +1,9 @@
class MonitisError < RuntimeError
- def initialize(parent)
- @parent=parent
- end
attr_accessor :parent
+ def initialize(parent)
+ @parent = parent
+ end
+
end
View
22 lib/monitis-SDK/monitors/agents.rb
@@ -1,27 +1,27 @@
class Agents < Base
def getAgents(key)
- options={:keyRegExp=>key}
- get("agents",key)
+ options = {:keyRegExp => key}
+ get("agents", key)
end
- def getAgentInfo(agentId,loadTests)
- options={:agentId=>agentId,:loadTests=>loadTests}
+ def getAgentInfo(agentId, loadTests)
+ options = {:agentId => agentId, :loadTests => loadTests}
get("agentInfo",options)
end
- def getAllAgentsSnapshot(platform=nil,tag=nil)
- options={:platform=>platform,:tag=>tag,:timezone=>Time.now.gmt_offset/60}
- get("allAgentsSnapshot",options)
+ def getAllAgentsSnapshot(platform = nil, tag = nil)
+ options = {:platform => platform, :tag => tag, :timezone => Time.now.gmt_offset / 60}
+ get("allAgentsSnapshot", options)
end
def getAgentSnapshot(agentKey)
- options={:agentKey=>agentKey,:timezone=>Time.now.gmt_offset/60}
- get("agentSnapshot",options)
+ options = {:agentKey => agentKey, :timezone => Time.now.gmt_offset / 60}
+ get("agentSnapshot", options)
end
- def deleteAgents(agentIds,keyRegExp)
- options={:agentIds=>agentIds,:keyRegExp=>keyRegExp}
+ def deleteAgents(agentIds, keyRegExp)
+ options = {:agentIds => agentIds, :keyRegExp => keyRegExp}
post("deleteAgents",options)
end
View
15 lib/monitis-SDK/monitors/cloud_instances.rb
@@ -1,14 +1,13 @@
class CloudInstances < Base
-
- def getCloudInstances
- options={:timezoneoffset=>Time.now.abs.gmtoff/60}
- get("cloudInstances",options)
+ def getCloudInstances
+ options = {:timezoneoffset => Time.now.abs.gmtoff / 60}
+ get("cloudInstances", options)
end
- def getCloudInstanceInfo(instanceId)
- options={:instanceId=>instanceId,:timezoneoffset=>Time.now.abs.gmtoff/60}
- get("cloudInstanceInfo",options)
+ def getCloudInstanceInfo(instanceId)
+ options = {:instanceId => instanceId, :timezoneoffset => Time.now.abs.gmtoff / 60}
+ get("cloudInstanceInfo", options)
end
- end
+end
View
78 lib/monitis-SDK/monitors/cpu_monitors.rb
@@ -1,53 +1,69 @@
class CPUMonitors < Base
-
- def addMonitor(options={})
- options.merge!(@default_options)
- options[:action]="addCPUMonitor"
- pp options
- res=HTTParty.post("http://www.monitis.com/api",:body=>options)
- Crack::JSON.parse(res)
+ def addMonitor(options = {})
+ options.merge!(@default_options)
+ options[:action] = "addCPUMonitor"
+ pp options
+ res = HTTParty.post("http://www.monitis.com/api", :body => options)
+ Crack::JSON.parse(res)
end
- def editMonitor(options={})
+ def editMonitor(options = {})
options.merge!(@default_options)
- options[:action]="editCPUMonitor"
+ options[:action] = "editCPUMonitor"
pp options
- res=HTTParty.post("http://www.monitis.com/api",:body=>options)
+ res = HTTParty.post("http://www.monitis.com/api", :body => options)
Crack::JSON.parse(res)
end
- def getMonitors(agentId)
- query=@default_options
- query.merge!({:action=>"agentCPU",:agentId=>agentId})
- options={:query=>query}
+ def getMonitors(agentId)
+ query = @default_options
+ query.merge!({
+ :action => "agentCPU",
+ :agentId => agentId
+ })
+ options = {:query => query}
pp query
- HTTParty.get("http://www.monitis.com/api",options)
+ HTTParty.get("http://www.monitis.com/api", options)
end
-
- def getMonitorInfo(monitorId )
- query=@default_options
- query.merge!({:action=>"CPUInfo",:monitorId =>monitorId })
- options={:query=>query}
+ def getMonitorInfo(monitorId )
+ query = @default_options
+ query.merge!({
+ :action => "CPUInfo",
+ :monitorId => monitorId
+ })
+ options = {:query => query}
pp query
HTTParty.get("http://www.monitis.com/api",options)
end
-def getResults(monitorId,day,month,year)
- query=@default_options
- query.merge!({:action=>"cpuResult",:monitorId=>monitorId,:day=>day,:month=>month,:year=>year,:timezone=>Time.now.gmt_offset/60})
- options={:query=>query}
+ def getResults(monitorId, day, month, year)
+ query = @default_options
+ query.merge!({
+ :action => "cpuResult",
+ :monitorId => monitorId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :timezone => Time.now.gmt_offset / 60
+ })
+ options = {:query => query}
pp query
- HTTParty.get("http://www.monitis.com/api",options)
-end
+ HTTParty.get("http://www.monitis.com/api", options)
+ end
- def getTopResults(limit=10,tag="Default")
- query=@default_options
- query.merge!({:action=>"topcpu",:limit=>limit,:tag=>tag,:timezone=>Time.now.gmt_offset/60})
- options={:query=>query}
+ def getTopResults(limit = 10, tag = "Default")
+ query = @default_options
+ query.merge!({
+ :action => "topcpu",
+ :limit => limit,
+ :tag => tag,
+ :timezone => Time.now.gmt_offset / 60
+ })
+ options = {:query => query}
pp query
HTTParty.get("http://www.monitis.com/api",options)
end
- end
+end
View
42 lib/monitis-SDK/monitors/custom_monitors.rb
@@ -1,38 +1,42 @@
-class CustomlMonitors
+class CustomMonitors < Base
- def addMonitor(options={})
- post("addMonitor",options)
+ def addMonitor(options = {})
+ post("addMonitor", options)
end
- def editMonitor(options={})
- post("editMonitor",options)
+ def editMonitor(options = {})
+ post("editMonitor", options)
end
def deleteMonitors(monitorIds)
- options={:monitorId =>monitorIds}
+ options = {:monitorId => monitorIds}
post("deleteMonitor",options)
end
-
def getMonitors(tag)
- options={:tag=>tag}
- get("getMonitors",options)
+ options = {:tag => tag}
+ get("getMonitors", options)
end
-
- def getMonitorInfo(testId,excludeHidden=false)
- options={:testId=>testId,:excludeHidden=>excludeHidden}
- get("testinfo",options)
+ def getMonitorInfo(testId, excludeHidden = false)
+ options = {:testId => testId, :excludeHidden => excludeHidden}
+ get("testinfo", options)
end
-
- def getMonitorResults(testIId,day,month,year,locationIds=nil,timezone=nil)
- options={:testId=>testId,:day=>day,:month=>month,:year=>year,:locationIds=>locationIds,:timezone=>timezone}
- get("testresult",options)
+ def getMonitorResults(testIId, day, month, year, locationIds = nil, timezone = nil)
+ options = {
+ :testId => testId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :locationIds => locationIds,
+ :timezone => timezone
+ }
+ get("testresult", options)
end
- def addMonitorResult(options={})
- post("addResult",:options)
+ def addMonitorResult(options = {})
+ post("addResult", :options)
end
end
View
51 lib/monitis-SDK/monitors/drive_monitors.rb
@@ -1,32 +1,41 @@
-class DriveMonitors
+class DriveMonitors < Base
- def addMonitor(options={})
- post("addDriveMonitor",options)
+ def addMonitor(options = {})
+ post("addDriveMonitor", options)
end
- def editMonitor(options={})
- post("editDriveMonitor",options)
+ def editMonitor(options = {})
+ post("editDriveMonitor", options)
end
- def getMonitors(agentId)
- options={:agentId=>agentId}
- get("agentDrive",options)
+ def getMonitors(agentId)
+ options = {:agentId => agentId}
+ get("agentDrive", options)
end
-
- def getMonitorInfo(monitorId )
- options={:monitorId =>monitorId }
- get("getMonitorInfo",options)
+ def getMonitorInfo(monitorId )
+ options = {:monitorId => monitorId}
+ get("getMonitorInfo", options)
end
-def getResults(monitorId,day,month,year)
- options={:monitorId=>monitorId,:day=>day,:month=>month,:year=>year,:timezone=>Time.now.gmt_offset/60}
- get("driveResult",options)
-end
-
- def getTopResults(limit=10,tag="Default")
- options={:limit=>limit,:tag=>tag,:timezone=>Time.now.gmt_offset/60}
- get("topdrive",options)
+ def getResults(monitorId, day, month, year)
+ options = {
+ :monitorId => monitorId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("driveResult", options)
end
- end
+ def getTopResults(limit = 10, tag = "Default")
+ options = {
+ :limit => limit,
+ :tag => tag,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("topdrive", options)
+ end
+
+end
View
67 lib/monitis-SDK/monitors/external_monitors.rb
@@ -1,27 +1,26 @@
class ExternalMonitors < Base
- def addMonitor(options={})
- post("addExternalMonitor",options)
+ def addMonitor(options = {})
+ post("addExternalMonitor", options)
end
- def editMonitor(options={})
- post("editExternalMonitor",options)
+ def editMonitor(options = {})
+ post("editExternalMonitor", options)
end
def deleteMonitors(testIds)
- options={:testIds=>testIds}
- post("deleteExternalMonitor",options)
+ options = {:testIds => testIds}
+ post("deleteExternalMonitor", options)
end
def suspendMonitors(monitorIds)
- options={:monitorIds=>monitorIds}
- post("suspendExternalMonitor",options)
+ options = {:monitorIds => monitorIds}
+ post("suspendExternalMonitor", options)
end
-
- def activateMonitors(type,value )
- options={:type=>value}
- post("activateExternalMonitor",options)
+ def activateMonitors(type, value)
+ options = {:type => value}
+ post("activateExternalMonitor", options)
end
def getLocations
@@ -32,26 +31,35 @@ def getMonitors
get("tests")
end
-
- def getMonitorInfo(testId)
- options={:testId=>testId}
- get("testinfo",options)
+ def getMonitorInfo(testId)
+ options = {:testId => testId}
+ get("testinfo", options)
end
-
- def getMonitorResults(testIId,day,month,year,locationIds=nil,timezone=nil)
- options={:testId=>testId,:day=>day,:month=>month,:year=>year,:locationIds=>locationIds,:timezone=>timezone}
- get("testresult",options)
+ def getMonitorResults(testIId, day, month, year, locationIds = nil, timezone = nil)
+ options = {
+ :testId => testId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :locationIds => locationIds,
+ :timezone => timezone
+ }
+ get("testresult", options)
end
- def getSnapshot(locationIds=nil)
- options={:locationIds=>locationIds}
- get("testsLastValues",options)
+ def getSnapshot(locationIds = nil)
+ options = {:locationIds => locationIds}
+ get("testsLastValues", options)
end
- def getTopResults(limit=10,tag="Default")
- options={:limit=>limit,:tag=>tag,:timezone=>Time.now.gmt_offset/60}
- get("topexternal",options)
+ def getTopResults(limit = 10, tag = "Default")
+ options = {
+ :limit => limit,
+ :tag => tag,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("topexternal", options)
end
def getTags
@@ -59,7 +67,8 @@ def getTags
end
def getMonitorsByTags(tag)
- options={:tag=>tag}
- get("tagtests",options)
+ options = {:tag => tag}
+ get("tagtests", options)
end
-end
+
+end
View
26 lib/monitis-SDK/monitors/full_page_load_monitors.rb
@@ -1,23 +1,23 @@
-class FullPageLoadMonitors
+class FullPageLoadMonitors < Base
- def suspendMonitors(tag)
- options={:tag=>tag}
- post("suspendFullPageLoadMonitor",options)
- end
+ def suspendMonitors(tag)
+ options = {:tag => tag}
+ post("suspendFullPageLoadMonitor", options)
+ end
- def suspendMonitors(monitorIds)
- options={:monitorIds=>monitorIds}
- post("suspendFullPageLoadMonitor",options)
+ def suspendMonitors(monitorIds)
+ options = {:monitorIds => monitorIds}
+ post("suspendFullPageLoadMonitor", options)
end
def activateMonitors(tag)
- options={:tag=>tag}
- post("suspendFullPageLoadMonitor",options)
+ options = {:tag => tag}
+ post("suspendFullPageLoadMonitor", options)
end
def activateMonitors(monitorIds )
- options={:monitorIds=>monitorIds}
- post("suspendFullPageLoadMonitor",options)
+ options = {:monitorIds => monitorIds}
+ post("suspendFullPageLoadMonitor", options)
end
- end
+end
View
39 lib/monitis-SDK/monitors/http_monitors.rb
@@ -1,27 +1,32 @@
-class HTTPMonitors
+class HTTPMonitors < Base
-
- def addMonitor(options={})
- post("addInternalHttpMonitor",options)
+ def addMonitor(options = {})
+ post("addInternalHttpMonitor", options)
end
- def editMonitor(options={})
- post("editInternalHttpMonitor",options)
+ def editMonitor(options = {})
+ post("editInternalHttpMonitor", options)
end
- def getMonitor(agentId)
- options={:agentId=>agentId}
- get("agentHttpTests",options)
+ def getMonitor(agentId)
+ options = {:agentId => agentId}
+ get("agentHttpTests", options)
end
- def getMonitorInfo(monitorId )
- options={:monitorId =>monitorId}
- get("internalHttpInfo",options)
+ def getMonitorInfo(monitorId )
+ options = {:monitorId => monitorId}
+ get("internalHttpInfo", options)
end
-def getResults(monitorId,day,month,year)
- options={:monitorId=>monitorId,:day=>day,:month=>month,:year=>year,:timezone=>Time.now.gmt_offset/60}
- get("internalHttpResult",options)
-end
- end
+ def getResults(monitorId, day, month, year)
+ options = {
+ :monitorId => monitorId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("internalHttpResult", options)
+ end
+end
View
26 lib/monitis-SDK/monitors/internal_monitors.rb
@@ -1,13 +1,17 @@
-class InternalMonitors
- def deleteMonitors(testIds,type)
- options={:testIds=>testIds,:type=>type}
- post("deleteInternalMonitors",options)
- end
-
- def getMonitors(types=nil,tag=nil,tagRegExp=nil)
- options={:types=>types,:tag=>tag,:tagRegExp=>tagRegExp}
- get("internalMonitors",options)
- end
+class InternalMonitors < Base
+
+ def deleteMonitors(testIds, type)
+ options={:testIds=>testIds,:type=>type}
+ post("deleteInternalMonitors",options)
+ end
+ def getMonitors(types = nil, tag = nil, tagRegExp = nil)
+ options = {
+ :types => types,
+ :tag => tag,
+ :tagRegExp => tagRegExp
+ }
+ get("internalMonitors", options)
end
-
+
+end
View
51 lib/monitis-SDK/monitors/load_average_monitors.rb
@@ -1,32 +1,41 @@
-class LoadAverageMonitors
+class LoadAverageMonitors < Base
- def addMonitor(options={})
- post("addLoadAverageMonitor",options)
+ def addMonitor(options = {})
+ post("addLoadAverageMonitor", options)
end
- def editMonitor(options={})
- post("editLoadAverageMonitor",options)
+ def editMonitor(options = {})
+ post("editLoadAverageMonitor", options)
end
- def getMonitor(agentId)
- options={:agentId=>agentId}
- get("agentLoadAvg",options)
+ def getMonitor(agentId)
+ options= {:agentId => agentId}
+ get("agentLoadAvg", options)
end
-
- def getMonitorInfo(monitorId )
- options={:monitorId =>monitorId}
- get("loadAvgInfo",options)
+ def getMonitorInfo(monitorId )
+ options = {:monitorId => monitorId}
+ get("loadAvgInfo", options)
end
-def getResults(monitorId,day,month,year)
- options={:monitorId=>monitorId,:day=>day,:month=>month,:year=>year,:timezone=>Time.now.gmt_offset/60}
- get("loadAvgResult",options)
-end
-
- def getTopResults(limit=10,tag="Default")
- options={:limit=>limit,:tag=>tag,:timezone=>Time.now.gmt_offset/60}
- get("topload1",options)
+ def getResults(monitorId, day, month, year)
+ options = {
+ :monitorId => monitorId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("loadAvgResult", options)
+ end
+
+ def getTopResults(limit = 10, tag = "Default")
+ options = {
+ :limit => limit,
+ :tag => tag,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("topload1", options)
end
- end
+end
View
20 lib/monitis-SDK/monitors/memory_monitors.rb
@@ -1,14 +1,16 @@
-class MemoryMonitors
-
- def addMonitor(options={})
- options.merge!(@default_options)
- options[:action]="addMemoryMonitor"
- pp options
- res=HTTParty.post("http://www.monitis.com/api",:body=>options)
- Crack::JSON.parse(res)
+class MemoryMonitors < Base
+
+ # TODO: Rewrite to use post() from Base
+
+ def addMonitor(options = {})
+ options.merge!(@default_options)
+ options[:action] = "addMemoryMonitor"
+ pp options
+ res = HTTParty.post("http://www.monitis.com/api", :body =>options)
+ Crack::JSON.parse(res)
end
- def editMonitor(options={})
+ def editMonitor(options = {})
options.merge!(@default_options)
options[:action]="editMemoryMonitor"
pp options
View
37 lib/monitis-SDK/monitors/ping_monitors.rb
@@ -1,27 +1,32 @@
class PingMonitors
- def addMonitor(options={})
- post("addInternalPingMonitor",options)
+ def addMonitor(options = {})
+ post("addInternalPingMonitor", options)
end
- def editMonitor(options={})
- post("editInternalPingMonitor",options)
+ def editMonitor(options = {})
+ post("editInternalPingMonitor", options)
end
- def getMonitor(agentId)
- options={:agentId=>agentId}
- get("agentPingTests",options)
+ def getMonitor(agentId)
+ options = {:agentId => agentId}
+ get("agentPingTests", options)
end
-
- def getMonitorInfo(monitorId )
- options={:monitorId =>monitorId}
- get("internalPingInfo",options)
+ def getMonitorInfo(monitorId)
+ options = {:monitorId => monitorId}
+ get("internalPingInfo", options)
end
- def getResults(monitorId,day,month,year)
- options={:monitorId=>monitorId,:day=>day,:month=>month,:year=>year,:timezone=>Time.now.gmt_offset/60}
- get("internalPingResult",options)
- end
- end
+ def getResults(monitorId, day, month, year)
+ options = {
+ :monitorId => monitorId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("internalPingResult", options)
+ end
+end
View
41 lib/monitis-SDK/monitors/process_monitors.rb
@@ -1,27 +1,32 @@
-class ProcessMonitors
+class ProcessMonitors < Base
- def addMonitor(options={})
- post("addProcessMonitor",options)
+ def addMonitor(options = {})
+ post("addProcessMonitor", options)
end
- def editMonitor(options={})
- post("editProcessMonitor",options)
+ def editMonitor(options = {})
+ post("editProcessMonitor", options)
end
- def getMonitor(agentId)
- options={:agentId=>agentId}
- get("agentProcesses",options)
+ def getMonitor(agentId)
+ options = {:agentId => agentId}
+ get("agentProcesses", options)
end
-
- def getMonitorInfo(monitorId )
- options={:monitorId =>monitorId}
- get("processInfo",options)
+ def getMonitorInfo(monitorId)
+ options = {:monitorId => monitorId}
+ get("processInfo", options)
end
- def getResults(monitorId,day,month,year)
- options={:monitorId=>monitorId,:day=>day,:month=>month,:year=>year,:timezone=>Time.now.gmt_offset/60}
- get("processResult",options)
-end
- end
-
+ def getResults(monitorId, day, month, year)
+ options = {
+ :monitorId => monitorId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :timezone => Time.now.gmt_offset / 60
+ }
+ get("processResult", options)
+ end
+
+end
View
46 lib/monitis-SDK/monitors/transaction_monitors.rb
@@ -1,36 +1,44 @@
-class TransactionMonitors
- def suspendMonitors(tag)
- options={:tag=>tag}
- post("suspendTransactionMonitor",options)
- end
+class TransactionMonitors < Base
+
+ def suspendMonitors(tag)
+ options = {:tag => tag}
+ post("suspendTransactionMonitor", options)
+ end
- def suspendMonitors(monitorIds)
- options={:monitorIds=>monitorIds}
- post("suspendTransactionMonitor",options)
+ def suspendMonitors(monitorIds)
+ options = {:monitorIds => monitorIds}
+ post("suspendTransactionMonitor", options)
end
def activateMonitors(tag)
- options={:tag=>tag}
- post("suspendTransactionMonitor",options)
+ options = {:tag => tag}
+ post("suspendTransactionMonitor", options)
end
def activateMonitors(monitorIds)
- options={:monitorIds=>monitorIds}
- post("suspendTransactionMonitor",options)
+ options = {:monitorIds => monitorIds}
+ post("suspendTransactionMonitor", options)
end
def getMonitors
get("tests")
end
- def getMonitorResults(testIId,day,month,year,locationIds=nil,timezone=nil)
- options={:testId=>testId,:day=>day,:month=>month,:year=>year,:locationIds=>locationIds,:timezone=>timezone}
- get("testresult",options)
+ def getMonitorResults(testId, day, month, year, locationIds = nil, timezone = nil)
+ options = {
+ :testId => testId,
+ :day => day,
+ :month => month,
+ :year => year,
+ :locationIds => locationIds,
+ :timezone => timezone
+ }
+ get("testresult", options)
end
- def getMonitorInfo(testId)
- options={:testId=>testId}
- get("testinfo",options)
+ def getMonitorInfo(testId)
+ options = {:testId => testId}
+ get("testinfo", options)
end
- end
+end
View
18 lib/monitis-SDK/monitors/visitor_trackers.rb
@@ -1,12 +1,12 @@
-class TransactionMonitor
+class TransactionMonitor < Base
- def getVisitorTrackers
- get("visitorTrackingTests")
- end
+ def getVisitorTrackers
+ get("visitorTrackingTests")
+ end
- def getVisitorTrackerInfo(siteId)
- options={:siteId=>siteId}
- get("visitorTrackingInfo",options)
- end
+ def getVisitorTrackerInfo(siteId)
+ options = {:siteId => siteId}
+ get("visitorTrackingInfo", options)
+ end
- end
+end
View
21 lib/monitis-SDK/user.rb
@@ -1,14 +1,17 @@
class User < Base
- def initialize
- #@default_options= {:authToken=>getAuthToken}
- # puts @default_options
- end
-
-
- def getUserKey(username,password)
- query={:action=> "userkey" ,:userName=>username,:password=>pasword }
- res=get("userkey",query)
+ def initialize
+ #@default_options= {:authToken=>getAuthToken}
+ # puts @default_options
end
+
+ def getUserKey(username, password)
+ query = {
+ :action => "userkey",
+ :userName => username,
+ :password => pasword
+ }
+ res = get("userkey", query)
end
+end
View
7 test/sandbox_test.rb
@@ -0,0 +1,7 @@
+require 'helper'
+
+class TestMonitisSdk < Test::Unit::TestCase
+ should "probably rename this file and start testing for real" do
+ flunk "hey buddy, you should probably rename this file and start testing for real"
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.