Class: Sappy::Monitor
- Inherits:
-
Object
- Object
- Sappy::Monitor
- Defined in:
- lib/sappy/monitor.rb
Constant Summary collapse
- SERVICES =
Name (required)
Service name.
Service (required)
Service type. Available values are: http, smtp, ftp, pop3, https, ping, dns
%w(http smtp ftp pop3 https ping dns)
- LOCATIONS =
Location (required)
Check location. Available values are: sf, ny, ch, ln (i.e. San Francisco, New York, Chicago, London).
{'sf' => 'San Francisco', 'ny' => 'New York', 'ch' => 'Chicago', 'ln' => 'London'}.sort
- CHECK_PERIODS =
HostName (required)
Monitored Host name, IP or Page URL.
CheckPeriod (required)
Monitoring check period. Available values are: 2, 5, 15, 30, 60
[2, 5, 15, 30, 60]
- SEND_ALERT_AFTER =
PortNumber (optional)
Custom port number. Default service port using by default.
Login (optional)
HTTP Authentication login. Used for 'http' and https services only.
Password (optional)
HTTP Authentication password. Used for 'http' and https services only.
Content (optional)
Monitored page content. Used for 'http' and 'https' services only.
Domain (optional)
Lookup domain. Used for 'dns' services only.
IP (optional)
Lookup domain. Used for 'dns' services only. Required if 'Domain' is not empty.
SendSms (optional)
0 or 1. Send SMS alerts on failures. Default value is '0'.
SendUrlAlert (optional)
0 or 1. Send Url (JSON) alerts on failures to Url specified on My Profile section. Default value is '0'.
SendJabberAlert (optional)
0 or 1. Send XMPP/Jabber alerts on failures to Jabber ID specified on My Profile section. Default value is '0'.
AltEmailAlerts (optional)
Alternative Email alerts addresses separated with comma.
DontSendUpAlert (optional)
0 or 1. Set to 1 if you do not what to receive Up alerts for a monitor. Default value is '0'.
SendAllDownAlerts (optional)
0 or 1. Set to 1 if you what to receive Down alert on each failure check. Default value is '0'.
Enabled (optional)
0 or 1. Monitor is enabled on not. Default value is '1'.
SendAlertAfter (optional)
Send alerts after specified number of failures. Available values are: 1, 2, 3, 4, 5. Default value is 1.
[1, 2, 3, 4, 5]
- TIMEOUTS =
DownSubject (optional)
Email subject value for Down alerts. Default subject will be used if empty.
UpSubject (optional)
Email subject value for Up alerts. Default subject will be used if empty.
EnablePublicStatistics (optional)
0 or 1. Allow/Deny visitor to see public statistics report. Default value is '1' (allow).
AddToStatusPage (optional)
0 or 1. Add/remove monitor to/from your public summary status report. Default value is '1' (add).
Timeout (optional)
Monitor socket connection timeout value in seconds. Available values are: 15, 20, 25, 30, 35. Default value is 25.
[15, 20, 25, 30, 35]
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#altemailalerts ⇒ Object
Returns the value of attribute altemailalerts.
-
#content ⇒ Object
Returns the value of attribute content.
-
#current_status ⇒ Object
Returns the value of attribute current_status.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#downsubject ⇒ Object
Returns the value of attribute downsubject.
-
#host ⇒ Object
Returns the value of attribute host.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#location ⇒ Object
Returns the value of attribute location.
-
#login ⇒ Object
Returns the value of attribute login.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#period ⇒ Object
Returns the value of attribute period.
-
#port ⇒ Object
Returns the value of attribute port.
-
#service ⇒ Object
Returns the value of attribute service.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#upsubject ⇒ Object
Returns the value of attribute upsubject.
Class Method Summary collapse
Instance Method Summary collapse
- #annual_statistics(year = "") ⇒ Object
- #attributes ⇒ Object
- #attributes=(attrs) ⇒ Object
- #create ⇒ Object
- #daily_statistics(year, month, day) ⇒ Object
- #destroy ⇒ Object
- #disable! ⇒ Object
- #disabled? ⇒ Boolean
- #enable! ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(account, attrs) ⇒ Monitor
constructor
A new instance of Monitor.
- #monthly_statistics(year, month) ⇒ Object
- #new_record? ⇒ Boolean
- #save ⇒ Object
- #update ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(account, attrs) ⇒ Monitor
Returns a new instance of Monitor.
64 65 66 67 |
# File 'lib/sappy/monitor.rb', line 64 def initialize(account, attrs) @account = account self.attributes = attrs end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
62 63 64 |
# File 'lib/sappy/monitor.rb', line 62 def account @account end |
#altemailalerts ⇒ Object
Returns the value of attribute altemailalerts.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def altemailalerts @altemailalerts end |
#content ⇒ Object
Returns the value of attribute content.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def content @content end |
#current_status ⇒ Object
Returns the value of attribute current_status.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def current_status @current_status end |
#domain ⇒ Object
Returns the value of attribute domain.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def domain @domain end |
#downsubject ⇒ Object
Returns the value of attribute downsubject.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def downsubject @downsubject end |
#host ⇒ Object
Returns the value of attribute host.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def host @host end |
#id ⇒ Object
Returns the value of attribute id.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def id @id end |
#ip ⇒ Object
Returns the value of attribute ip.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def ip @ip end |
#location ⇒ Object
Returns the value of attribute location.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def location @location end |
#login ⇒ Object
Returns the value of attribute login.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def login @login end |
#name ⇒ Object
Returns the value of attribute name.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def password @password end |
#period ⇒ Object
Returns the value of attribute period.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def period @period end |
#port ⇒ Object
Returns the value of attribute port.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def port @port end |
#service ⇒ Object
Returns the value of attribute service.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def service @service end |
#timeout ⇒ Object
Returns the value of attribute timeout.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def timeout @timeout end |
#upsubject ⇒ Object
Returns the value of attribute upsubject.
57 58 59 |
# File 'lib/sappy/monitor.rb', line 57 def upsubject @upsubject end |
Class Method Details
.create(account, attrs) ⇒ Object
75 76 77 78 79 |
# File 'lib/sappy/monitor.rb', line 75 def self.create(account, attrs) monitor = new(account, attrs) monitor.save monitor end |
.parse(account, attrs) ⇒ Object
69 70 71 72 73 |
# File 'lib/sappy/monitor.rb', line 69 def self.parse(account, attrs) a = new(account, attrs) a.current_status = attrs["current_status"] a end |
Instance Method Details
#annual_statistics(year = "") ⇒ Object
151 152 153 |
# File 'lib/sappy/monitor.rb', line 151 def annual_statistics(year = "") Statistics::Annual.new(@account.request('annualstatistics', "MonitorId" => id, "Year" => year).statistics) end |
#attributes ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/sappy/monitor.rb', line 81 def attributes { "Name" => name, "Service" => service, "Location" => location, "HostName" => host, "CheckPeriod" => period, "PortNumber" => port, "Login" => login, "Password" => password, "Content" => content, "Domain" => domain, "IP" => ip, "SendSms" => sendsms, "SendUrlAlert" => sendurlalert, "SendJabberAlert" => sendjabberalert, "AltEmailAlerts" => altemailalerts, "DontSendUpAlert" => dontsendupalert, "SendAllDownAlerts" => sendalldownalerts, "Enabled" => active, "SendAlertAfter" => sendalertafter, "DownSubject" => downsubject, "UpSubject" => upsubject, "EnablePublicStatistics" => enablepublicstatistics, "AddToStatusPage" => addtostatuspage, "Timeout" => timeout } end |
#attributes=(attrs) ⇒ Object
91 92 93 94 95 |
# File 'lib/sappy/monitor.rb', line 91 def attributes=(attrs) attrs.each do |attribute,value| send("#{attribute.to_s}=", value) if respond_to? "#{attribute.to_s}=" end end |
#create ⇒ Object
131 132 133 |
# File 'lib/sappy/monitor.rb', line 131 def create self.id = @account.request("addmonitor", attributes).id end |
#daily_statistics(year, month, day) ⇒ Object
143 144 145 |
# File 'lib/sappy/monitor.rb', line 143 def daily_statistics(year, month, day) Statistics::Daily.new(@account.request('dailystatistics', "MonitorId" => id, "Year" => year, "Month" => month, "Day" => day).statistics) end |
#destroy ⇒ Object
139 140 141 |
# File 'lib/sappy/monitor.rb', line 139 def destroy @account.request('removemonitor', "MonitorId" => id) end |
#disable! ⇒ Object
105 106 107 108 |
# File 'lib/sappy/monitor.rb', line 105 def disable! @account.request('disablemonitor', "MonitorId" => id) @active = 0 end |
#disabled? ⇒ Boolean
110 111 112 |
# File 'lib/sappy/monitor.rb', line 110 def disabled? @active != 1 end |
#enable! ⇒ Object
114 115 116 117 |
# File 'lib/sappy/monitor.rb', line 114 def enable! @account.request('enablemonitor', "MonitorId" => id) @active = 1 end |
#enabled? ⇒ Boolean
119 120 121 |
# File 'lib/sappy/monitor.rb', line 119 def enabled? @active == 1 end |
#monthly_statistics(year, month) ⇒ Object
147 148 149 |
# File 'lib/sappy/monitor.rb', line 147 def monthly_statistics(year, month) Statistics::Monthly.new(@account.request('monthlystatistics', "MonitorId" => id, "Year" => year, "Month" => month).statistics) end |
#new_record? ⇒ Boolean
123 124 125 |
# File 'lib/sappy/monitor.rb', line 123 def new_record? id.nil? end |
#save ⇒ Object
127 128 129 |
# File 'lib/sappy/monitor.rb', line 127 def save new_record? ? create : update end |
#update ⇒ Object
135 136 137 |
# File 'lib/sappy/monitor.rb', line 135 def update @account.request("editmonitor", attributes.merge({ "MonitorId" => id })) end |
#url ⇒ Object
101 102 103 |
# File 'lib/sappy/monitor.rb', line 101 def url "#{service}://#{host}" end |