Class: Network
Constant Summary
Constants inherited from Node
Node::NOARP_PROPERTY, Node::NODESCR_PROPERTY, Node::NONAME_PROPERTY
Instance Attribute Summary collapse
-
#dns_domain ⇒ Object
Returns the value of attribute dns_domain.
-
#host ⇒ Object
Returns the value of attribute host.
-
#map_bg_data ⇒ Object
Returns the value of attribute map_bg_data.
-
#map_bg_type ⇒ Object
Returns the value of attribute map_bg_type.
-
#map_view ⇒ Object
Returns the value of attribute map_view.
-
#name ⇒ Object
Returns the value of attribute name.
-
#netbios_domain ⇒ Object
Returns the value of attribute netbios_domain.
-
#network ⇒ Object
Returns the value of attribute network.
-
#node_size ⇒ Object
Returns the value of attribute node_size.
-
#node_view ⇒ Object
Returns the value of attribute node_view.
Attributes inherited from Node
#alert_type_by_level, #avail_sev, #custom_monitoring, #custom_sev, #description, #http_monitoring, #icon, #im_dest_by_level, #inherit_from_global, #interface, #ip, #ipv6, #jmx_monitoring, #jmx_sev, #mail_by_level, #map, #netmask, #netmask6, #os, #script_name_by_level, #service, #service_sev, #sms_num_by_level, #snmp_monitoring, #snmp_port, #snmp_retry, #snmp_sev, #snmp_timeout, #snmp_version, #snmptrap_monitoring, #sound_file_path_by_level, #status, #syslog_monitoring, #syslog_sev, #trap_sev, #type, #uuid, #wmi_monitoring, #wmi_sev, #x, #y
Instance Method Summary collapse
-
#add_host(h) ⇒ Object
h is a node.
- #add_network(h) ⇒ Object
-
#change_label(lb = nil) ⇒ Object
method for changing label of the node lb is nil when we just want a node label refresh.
-
#change_status(st) ⇒ Object
method for changing status (color) of the node.
- #contain_host(hip) ⇒ Object
- #contain_network(hip) ⇒ Object
- #create_node ⇒ Object
- #del_host(hip) ⇒ Object
- #del_net(hip) ⇒ Object
-
#delete ⇒ Object
create_node.
- #dns_domain? ⇒ Boolean
- #get_node ⇒ Object
-
#initialize(ip = "", mask = 24, ipv6 = "", mask6 = 64, mp = nil, p = nil, s = UNKNOWN, xd = 0, yd = 0, i = "", d = NODESCR_PROPERTY, t = "network", o = "unknown", n = NONAME_PROPERTY, dns_domain = NONAME_PROPERTY, netbios_domain = NONAME_PROPERTY, uuid = create_uuid()) ⇒ Network
constructor
A new instance of Network.
- #name? ⇒ Boolean
- #nb_host ⇒ Object
- #nb_network ⇒ Object
- #nb_node ⇒ Object
- #netbios_domain? ⇒ Boolean
-
#reload ⇒ Object
reload pixmap icon to apply changes.
-
#to_t ⇒ Object
Return a table for the find tool.
-
#update_status ⇒ Object
update status depending on node host.
- #write_db ⇒ Object
Methods inherited from Node
#account_exist?, #account_exist_nr?, #account_size, #add_account, #add_custom_monitoring, #add_custom_monitoring_bulk, #add_db_account, #add_interface, #add_jmx_monitoring, #add_link, #add_service, #add_snmp_monitoring, #add_snmptrap_monitoring, #add_syslog_monitoring, #add_wmi_monitoring, #clear_account, #clear_custom_monitoring, #clear_db_accounts, #clear_jmx_monitoring, #clear_service, #clear_snmp_monitoring, #clear_snmptrap_monitoring, #clear_syslog_monitoring, #clear_wmi_monitoring, #custom_parameter, #custom_severity, #del_account, #del_all_links, #del_custom_monitoring, #del_interface, #del_jmx_monitoring, #del_link, #del_node_link, #del_service, #del_snmp_monitoring, #del_snmptrap_monitoring, #del_syslog_monitoring, #del_wmi_monitoring, #description?, #disable_alert_type, #enable_alert_type, #get_account_id, #get_account_login, #get_account_password, #get_all_account, #get_default_inherit_snmp_port, #get_default_inherit_snmp_retry, #get_default_inherit_snmp_timeout, #get_default_inherit_snmp_version, #get_links, #get_node_type, #get_service_sev, #hide_label, #init_account_from_db, #init_jmx_from_db, #is_service_monitor, #linked, #nb_interface, #nb_links, #point_pos, #refresh_status, #service_by_name, #service_key, #set_account_login, #set_account_password, #set_all_account, #set_all_interface, #set_all_severity, #set_avail_severity, #set_custom_severity, #set_inherit_conf, #set_jmx_severity, #set_label_visibility, #set_map, #set_service_severity, #set_severity, #set_snmp_conf, #set_snmp_severity, #set_syslog_severity, #set_trap_severity, #set_wmi_severity, #show_label
Constructor Details
#initialize(ip = "", mask = 24, ipv6 = "", mask6 = 64, mp = nil, p = nil, s = UNKNOWN, xd = 0, yd = 0, i = "", d = NODESCR_PROPERTY, t = "network", o = "unknown", n = NONAME_PROPERTY, dns_domain = NONAME_PROPERTY, netbios_domain = NONAME_PROPERTY, uuid = create_uuid()) ⇒ Network
Returns a new instance of Network.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/node_network.rb', line 4 def initialize (ip="", mask=24, ipv6="", mask6=64, mp=nil, p=nil, s=UNKNOWN, xd=0 ,yd=0, i="", d=NODESCR_PROPERTY, t="network", o="unknown", n=NONAME_PROPERTY, dns_domain=NONAME_PROPERTY, netbios_domain=NONAME_PROPERTY, uuid=create_uuid()) super(ip, mask, ipv6, mask6, mp, p, s, xd, yd, i, d, t, o, uuid) @name=n @dns_domain=NONAME_PROPERTY @netbios_domain=NONAME_PROPERTY @host=Hash.new @network=Hash.new @node_view=nil @node_size=nil @map_bg_type=nil @map_bg_data=nil if mp != nil and $network[mp] if $network[mp].status == UNMANAGED self.status=UNMANAGED end end #create gui view create_node() #store node in db #check from which the call is coming, if it's from db load fct we do nothing caller_func = caller[1][/`.*'/][1..-2] write_db() unless caller_func == "db_read_node" end |
Instance Attribute Details
#dns_domain ⇒ Object
Returns the value of attribute dns_domain.
2 3 4 |
# File 'lib/node_network.rb', line 2 def dns_domain @dns_domain end |
#host ⇒ Object
Returns the value of attribute host.
2 3 4 |
# File 'lib/node_network.rb', line 2 def host @host end |
#map_bg_data ⇒ Object
Returns the value of attribute map_bg_data.
2 3 4 |
# File 'lib/node_network.rb', line 2 def map_bg_data @map_bg_data end |
#map_bg_type ⇒ Object
Returns the value of attribute map_bg_type.
2 3 4 |
# File 'lib/node_network.rb', line 2 def map_bg_type @map_bg_type end |
#map_view ⇒ Object
Returns the value of attribute map_view.
2 3 4 |
# File 'lib/node_network.rb', line 2 def map_view @map_view end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/node_network.rb', line 2 def name @name end |
#netbios_domain ⇒ Object
Returns the value of attribute netbios_domain.
2 3 4 |
# File 'lib/node_network.rb', line 2 def netbios_domain @netbios_domain end |
#network ⇒ Object
Returns the value of attribute network.
2 3 4 |
# File 'lib/node_network.rb', line 2 def network @network end |
#node_size ⇒ Object
Returns the value of attribute node_size.
2 3 4 |
# File 'lib/node_network.rb', line 2 def node_size @node_size end |
#node_view ⇒ Object
Returns the value of attribute node_view.
2 3 4 |
# File 'lib/node_network.rb', line 2 def node_view @node_view end |
Instance Method Details
#add_host(h) ⇒ Object
h is a node
33 34 35 36 37 38 |
# File 'lib/node_network.rb', line 33 def add_host(h) if $treenode_win.visible? $treenode_win.add_row(h) end @host[h.ip]=h end |
#add_network(h) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/node_network.rb', line 40 def add_network(h) if $treenode_win.visible? $treenode_win.add_row(h) end @network[h.ip]=h end |
#change_label(lb = nil) ⇒ Object
method for changing label of the node lb is nil when we just want a node label refresh
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/node_network.rb', line 184 def change_label(lb=nil) if $config.show_label if (@old_label != lb) or lb==nil @old_label=lb unless lb==nil lb=@old_label unless lb!=nil if node_view node_view.set_text("#{eval lb}") unless ("#{eval lb}" == NODESCR_PROPERTY) || ("#{eval lb}" == NONAME_PROPERTY) end end end end |
#change_status(st) ⇒ Object
method for changing status (color) of the node
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/node_network.rb', line 117 def change_status(st) if @status != st #status has changed @status=st @node_view.icon_color($status_color[$status_value.index(st)]) @links.each {|l| l.update_status() } if $treenode_win.visible? $treenode_win.update_row(self) end #propagate status UNMANAGED or UNKNOWN to all nodes includes in this network if (st == UNMANAGED) || (st == UNKNOWN) get_node().each_value {|node| node.change_status(st) } end end end |
#contain_host(hip) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/node_network.rb', line 65 def contain_host(hip) @host.each_value {|node| if node.ip == hip return true end } return false end |
#contain_network(hip) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/node_network.rb', line 74 def contain_network(hip) #should be recursive @network.each_value {|node| if node.ip == hip return true else return node.contain_network(hip) end } return false end |
#create_node ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/node_network.rb', line 196 def create_node() @old_label="" #set default label label="#{dns_domain}" if !dns_domain? && ip != "" label="#{ip}" if name? label="#{@name}" end end @map_view=Goo::CanvasGroup.new($canvas_root,{:x => 0.0,:y => 0.0}) @map_view.visibility = Goo::CanvasItem::HIDDEN @node_view=nil if @map == nil #its the root network @node_view=NodeNetworkView.new($canvas_root, self, $status_color[$status_value.index(status)], "#{PIXMAP_PATH}/#{icon}", label) else #puts "create_node #{$network[@map]}" if $network[@map] @node_view=NodeNetworkView.new($network[@map].map_view, self, $status_color[$status_value.index(status)], "#{PIXMAP_PATH}/#{icon}", label) end end change_label($config.network_label_view) if @node_view if ($config.show_label &&((@map==nil)||(get_map()==@map))) @node_view.show_text() else @node_view.hide_text() unless !@node_view end end end |
#del_host(hip) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/node_network.rb', line 47 def del_host(hip) if $treenode_win.visible? $treenode_win.del_row(@host[hip]) end @host.delete hip end |
#del_net(hip) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/node_network.rb', line 54 def del_net(hip) if hip == @ip $log.error("Can't delete itself ip=#{ip}") return end if $treenode_win.visible? $treenode_win.del_row(@network[hip]) end @network.delete hip end |
#delete ⇒ Object
create_node
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/node_network.rb', line 228 def delete() #first need to destroy the links del_all_links() if @node_view #destroy the tooltips @node_view.hide_tooltips() #destroy the view @node_view.unselect() @node_view.destroy() end @node_view=nil #remove from db db_delete_node(NETWORKNODE, ip, netmask) del_network(@ip) end |
#dns_domain? ⇒ Boolean
103 104 105 |
# File 'lib/node_network.rb', line 103 def dns_domain?() return dns_domain != NONAME_PROPERTY end |
#get_node ⇒ Object
86 87 88 |
# File 'lib/node_network.rb', line 86 def get_node() return @host.merge(@network) end |
#name? ⇒ Boolean
111 112 113 |
# File 'lib/node_network.rb', line 111 def name?() return (@name != nil) && (@name != NONAME_PROPERTY) && (@name != "") end |
#nb_host ⇒ Object
94 95 96 |
# File 'lib/node_network.rb', line 94 def nb_host() return @host.size end |
#nb_network ⇒ Object
98 99 100 |
# File 'lib/node_network.rb', line 98 def nb_network() return @network.size end |
#nb_node ⇒ Object
90 91 92 |
# File 'lib/node_network.rb', line 90 def nb_node() return nb_network() + nb_host() end |
#netbios_domain? ⇒ Boolean
107 108 109 |
# File 'lib/node_network.rb', line 107 def netbios_domain?() return netbios_domain != NONAME_PROPERTY end |
#reload ⇒ Object
reload pixmap icon to apply changes
247 248 249 250 251 252 253 254 |
# File 'lib/node_network.rb', line 247 def reload() if ($config.network_icon_view=="os") @icon="#{find_extension("os/#{@os}")}" else @icon="#{find_extension("type/#{@type}")}" end @node_view.set_image(@icon) unless !@node_view end |
#to_t ⇒ Object
Return a table for the find tool
259 260 261 262 263 |
# File 'lib/node_network.rb', line 259 def to_t tmp=[] tmp.push(@ip,$status[$status_value.index(@status)], @name, @dns_domain, @netbios_domain, @description, @type, @os) return tmp end |
#update_status ⇒ Object
update status depending on node host
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/node_network.rb', line 142 def update_status() if @node_view != nil total_up=0 total_other=0 get_node().each_value{|n| if n.status == NORMAL total_up+=1 elsif n.status != UNMANAGED total_other+=1 end } total_host=total_up+total_other if total_host > 0 percent_status_not_up=(total_other*100)/total_host if percent_status_not_up >= 50 @status=CRITICAL @node_view.icon_color($status_color[$status_value.index(CRITICAL)]) elsif percent_status_not_up == 0 @status=NORMAL @node_view.icon_color($status_color[$status_value.index(NORMAL)]) elsif percent_status_not_up >= 25 @status=MAJOR @node_view.icon_color($status_color[$status_value.index(MAJOR)]) else @status=MINOR @node_view.icon_color($status_color[$status_value.index(MINOR)]) end if $treenode_win.visible? $treenode_win.update_row(self) end #need to propagate to the network upstair $network[@map].update_status() unless @map == nil else @status=UNKNOWN @node_view.icon_color($status_color[$status_value.index(UNKNOWN)]) end end end |
#write_db ⇒ Object
265 266 267 |
# File 'lib/node_network.rb', line 265 def write_db() return db_insert_node_prp(uuid,NETWORKNODE,ip,netmask,ipv6,netmask6,nil,map,status,avail_sev,snmp_sev,custom_sev,trap_sev, service_sev, wmi_sev, syslog_sev, jmx_sev, x,y,icon,description, snmp_version, snmp_port, snmp_timeout, snmp_retry,type,os,"",nil,dns_domain,nil,netbios_domain,nil,nil,nil) end |