Class: Zenoss::Model::Device
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Zenoss::Model::Device
- Includes:
- Zenoss::Model, DeviceResultInt, EventView, RRDView, ZenPropertyManager
- Defined in:
- lib/zenoss/model/devices/device.rb
Instance Method Summary collapse
-
#change_device_class(device_class) ⇒ Object
Move this Device to the given DeviceClass.
-
#get_data_for_json ⇒ Object
Returns data ready for serialization.
-
#get_device_components(monitored = nil, collector = nil, type = nil) ⇒ Object
Return list of all DeviceComponents on this device.
- #get_device_group_names ⇒ Object
- #get_event_history ⇒ Object
-
#get_events ⇒ Object
Get events for this device.
- #get_hw_product_name ⇒ Object
-
#get_id ⇒ Object
Instead of calling the /getId REST method, this method simply returns the @device value since it is the same anyway.
- #get_info(keys = nil) ⇒ Object
-
#get_last_change ⇒ Object
Returns a DateTime instance when this device was last modified.
-
#get_location_link ⇒ Object
Get the HTML formatted link to the Location that this devices exists at.
-
#get_location_name ⇒ Object
Returns a String value of the Location that this device exists at.
-
#get_manage_ip ⇒ Object
Return the management ip for this device.
-
#get_monitored_components(collector = nil, type = nil) ⇒ Object
Return list of monitored DeviceComponents on this device.
-
#get_performance_server_name ⇒ Object
Returns the name of the Zenoss Collector that this host currently belogs to.
-
#get_ping_status_string ⇒ Object
Return the pingStatus as a string.
- #get_pretty_link ⇒ Object
-
#get_priority ⇒ Object
Return the numeric device priority.
-
#get_priority_string ⇒ Object
Return the device priority as a string.
-
#get_production_state_string ⇒ Object
Return the prodstate as a string.
- #get_rrd_templates ⇒ Object
-
#get_snmp_last_collection ⇒ Object
Returns a DateTime instance when this device was last collected from.
-
#get_snmp_status_string ⇒ Object
Return the snmpStatus as a string.
-
#get_system_names ⇒ Object
Returns an Array of Zenoss /Systems that this device belogs to.
-
#get_system_names_string(sep = ',') ⇒ Object
Return the Zenoss /Systems that this device belogs to in a string separated by “sep”.
- #initialize(zenoss, zhash) ⇒ Device constructor
-
#monitor_device? ⇒ Boolean
Returns true if the device production state >= zProdStateThreshold.
-
#rename_device(new_name) ⇒ Object
Change name of the device.
-
#set_hw_tag(asset_tag) ⇒ Object
Update the devices hardware tag with the passed string.
- #set_info(opts = {}) ⇒ Object
-
#snmp_monitor_device? ⇒ Boolean
Returns true if the device is subject to SNMP monitoring.
- #sys_uptime ⇒ Object
-
#uptime_str ⇒ Object
Return the SNMP uptime.
Methods included from ZenPropertyManager
#cust_property_ids, #delete_cust_property, #delete_zen_property, #get_cust_property, #set_cust_property, #set_zen_property, #zen_property_ids, #zen_property_items
Methods included from DeviceResultInt
#device_class, #get_device_class_name, #get_device_class_path
Methods included from RRDView
#fetch_rrd_value, #get_rrd_data_points, #get_rrd_values, #parse_rrd_fetch
Methods included from Zenoss::Model
Methods included from Zenoss
connect, #parse_array, #pdatetime_to_datetime, #pdict_to_hash, #plist_to_array, #ptuples_to_hash, #sanitize_str
Methods included from EventView
#get_status, #get_status_css_class, #get_status_img_src
Constructor Details
#initialize(zenoss, zhash) ⇒ Device
32 33 34 35 36 |
# File 'lib/zenoss/model/devices/device.rb', line 32 def initialize(zenoss,zhash) @zenoss = zenoss super zhash self.ipAddress = IPAddr.new(IPAddr.inet_ntoa(self.ipAddress)) if self.ipAddress end |
Instance Method Details
#change_device_class(device_class) ⇒ Object
Move this Device to the given DeviceClass.
61 62 63 64 |
# File 'lib/zenoss/model/devices/device.rb', line 61 def change_device_class(device_class) reset_cache_vars rest("changeDeviceClass?deviceClassPath=#{device_class.organizer_name}") end |
#get_data_for_json ⇒ Object
Returns data ready for serialization
94 95 96 |
# File 'lib/zenoss/model/devices/device.rb', line 94 def get_data_for_json plist_to_array( rest('getDataForJSON') ) end |
#get_device_components(monitored = nil, collector = nil, type = nil) ⇒ Object
Return list of all DeviceComponents on this device
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/zenoss/model/devices/device.rb', line 193 def get_device_components(monitored=nil, collector=nil, type=nil) method = "getDeviceComponents" method << '?' unless(monitored.nil? && collector.nil? && type.nil?) method << "monitored=#{monitored}&" unless monitored.nil? method << "collector=#{collector}&" unless collector.nil? method << "type=#{type}" unless type.nil? components = rest(method) plist_to_array(components) end |
#get_device_group_names ⇒ Object
98 99 100 |
# File 'lib/zenoss/model/devices/device.rb', line 98 def get_device_group_names plist_to_array( rest('getDeviceGroupNames') ) end |
#get_event_history ⇒ Object
45 46 47 |
# File 'lib/zenoss/model/devices/device.rb', line 45 def get_event_history @zenoss.query_events(self.uid,{:history => true}) end |
#get_events ⇒ Object
Get events for this device
41 42 43 |
# File 'lib/zenoss/model/devices/device.rb', line 41 def get_events @zenoss.query_events(self.uid) end |
#get_hw_product_name ⇒ Object
77 78 79 |
# File 'lib/zenoss/model/devices/device.rb', line 77 def get_hw_product_name rest('getHWProductName') end |
#get_id ⇒ Object
Instead of calling the /getId REST method, this method simply returns the @device value since it is the same anyway.
69 70 71 |
# File 'lib/zenoss/model/devices/device.rb', line 69 def get_id() @device end |
#get_info(keys = nil) ⇒ Object
49 50 51 |
# File 'lib/zenoss/model/devices/device.rb', line 49 def get_info(keys = nil) @zenoss.get_info(self.uid, keys) end |
#get_last_change ⇒ Object
Returns a DateTime instance when this device was last modified.
103 104 105 |
# File 'lib/zenoss/model/devices/device.rb', line 103 def get_last_change pdatetime_to_datetime( rest('getLastChange') ) end |
#get_location_link ⇒ Object
Get the HTML formatted link to the Location that this devices exists at. If you are looking for just the name, use #get_location_name instead.
83 84 85 |
# File 'lib/zenoss/model/devices/device.rb', line 83 def get_location_link rest('getLocationLink') end |
#get_location_name ⇒ Object
Returns a String value of the Location that this device exists at. You can also issue #get_location_link if you want an HTML link to the location page.
89 90 91 |
# File 'lib/zenoss/model/devices/device.rb', line 89 def get_location_name rest('getLocationName') end |
#get_manage_ip ⇒ Object
Return the management ip for this device.
108 109 110 |
# File 'lib/zenoss/model/devices/device.rb', line 108 def get_manage_ip rest('getManageIp') end |
#get_monitored_components(collector = nil, type = nil) ⇒ Object
Return list of monitored DeviceComponents on this device
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/zenoss/model/devices/device.rb', line 181 def get_monitored_components(collector=nil, type=nil) method = "getMonitoredComponents" method << '?' unless(collector.nil? && type.nil?) method << "collector=#{collector}&" unless collector.nil? method << "type=#{type}" unless type.nil? components = rest(method) # Turn the return string into an array of components components.gsub(/[\[\]]/, '').split(/,\s+/) end |
#get_performance_server_name ⇒ Object
Returns the name of the Zenoss Collector that this host currently belogs to.
113 114 115 |
# File 'lib/zenoss/model/devices/device.rb', line 113 def get_performance_server_name rest('getPerformanceServerName') end |
#get_ping_status_string ⇒ Object
Return the pingStatus as a string
118 119 120 |
# File 'lib/zenoss/model/devices/device.rb', line 118 def get_ping_status_string rest('getPingStatusString') end |
#get_pretty_link ⇒ Object
122 123 124 |
# File 'lib/zenoss/model/devices/device.rb', line 122 def get_pretty_link rest('getPrettyLink') end |
#get_priority ⇒ Object
Return the numeric device priority.
127 128 129 |
# File 'lib/zenoss/model/devices/device.rb', line 127 def get_priority (rest('getPriority')).to_i end |
#get_priority_string ⇒ Object
Return the device priority as a string.
132 133 134 |
# File 'lib/zenoss/model/devices/device.rb', line 132 def get_priority_string rest('getPriorityString') end |
#get_production_state_string ⇒ Object
Return the prodstate as a string.
137 138 139 |
# File 'lib/zenoss/model/devices/device.rb', line 137 def get_production_state_string rest('getProductionStateString') end |
#get_rrd_templates ⇒ Object
141 142 |
# File 'lib/zenoss/model/devices/device.rb', line 141 def get_rrd_templates end |
#get_snmp_last_collection ⇒ Object
Returns a DateTime instance when this device was last collected from.
145 146 147 |
# File 'lib/zenoss/model/devices/device.rb', line 145 def get_snmp_last_collection pdatetime_to_datetime( rest('getSnmpLastCollection') ) end |
#get_snmp_status_string ⇒ Object
Return the snmpStatus as a string.
150 151 152 |
# File 'lib/zenoss/model/devices/device.rb', line 150 def get_snmp_status_string rest('getSnmpStatusString') end |
#get_system_names ⇒ Object
Returns an Array of Zenoss /Systems that this device belogs to.
155 156 157 |
# File 'lib/zenoss/model/devices/device.rb', line 155 def get_system_names plist_to_array( rest('getSystemNames') ) end |
#get_system_names_string(sep = ',') ⇒ Object
Return the Zenoss /Systems that this device belogs to in a string separated by “sep”.
206 207 208 |
# File 'lib/zenoss/model/devices/device.rb', line 206 def get_system_names_string(sep=',') rest("getSystemNamesString?sep=#{sep}") end |
#monitor_device? ⇒ Boolean
Returns true if the device production state >= zProdStateThreshold.
160 161 162 |
# File 'lib/zenoss/model/devices/device.rb', line 160 def monitor_device? (rest('monitorDevice')).eql?('True') ? true : false end |
#rename_device(new_name) ⇒ Object
Change name of the device
211 212 213 214 215 216 217 |
# File 'lib/zenoss/model/devices/device.rb', line 211 def rename_device(new_name) ret = rest("renameDevice?newId=#{new_name}") if ret self.name = new_name end return ret end |
#set_hw_tag(asset_tag) ⇒ Object
Update the devices hardware tag with the passed string
175 176 177 178 |
# File 'lib/zenoss/model/devices/device.rb', line 175 def set_hw_tag(asset_tag) puts "No REST implementation yet." #rest("setHWTag?assettag#{asset_tag}") end |
#set_info(opts = {}) ⇒ Object
53 54 55 56 |
# File 'lib/zenoss/model/devices/device.rb', line 53 def set_info(opts = {}) opts[:uid] = self.uid @zenoss.set_info(opts) end |
#snmp_monitor_device? ⇒ Boolean
Returns true if the device is subject to SNMP monitoring
165 166 167 |
# File 'lib/zenoss/model/devices/device.rb', line 165 def snmp_monitor_device? (rest('snmpMonitorDevice')).eql?('True') ? true : false end |
#sys_uptime ⇒ Object
73 74 75 |
# File 'lib/zenoss/model/devices/device.rb', line 73 def sys_uptime rest("sysUpTime") end |
#uptime_str ⇒ Object
Return the SNMP uptime
170 171 172 |
# File 'lib/zenoss/model/devices/device.rb', line 170 def uptime_str rest('uptimeStr') end |