Class: Host
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.
-
#dns_name ⇒ Object
Returns the value of attribute dns_name.
-
#mac ⇒ Object
Returns the value of attribute mac.
-
#name ⇒ Object
Returns the value of attribute name.
-
#netbios_domain ⇒ Object
Returns the value of attribute netbios_domain.
-
#netbios_name ⇒ Object
Returns the value of attribute netbios_name.
-
#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
-
#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 st is a $status_value.
- #change_type(typ) ⇒ Object
- #create_node ⇒ Object
-
#delete ⇒ Object
create_node.
- #dns_name? ⇒ Boolean
- #get_dns_name ⇒ Object
- #hostname? ⇒ Boolean
-
#initialize(ip = "", mask = 24, ipv6 = "", mask6 = 64, mp = nil, mac = "(noarp)", n = "(noname)", nn = "(noname)", p = nil, s = UNKNOWN, xd = 0, yd = 0, i = "", d = NODESCR_PROPERTY, t = "host", o = "unknown", uuid = create_uuid()) ⇒ Host
constructor
A new instance of Host.
- #mac? ⇒ Boolean
- #netbios_name? ⇒ Boolean
- #refresh_dns_name ⇒ Object
-
#reload ⇒ Object
reload pixmap icon to apply changes.
-
#set_severities(avail, snmp, custom, trap, serv, wmi, syslog, jmx) ⇒ Object
1 is avail 2 is snmp 3 is custom 4 is trap.
-
#to_t ⇒ Object
Return a table for the find tool.
- #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, mac = "(noarp)", n = "(noname)", nn = "(noname)", p = nil, s = UNKNOWN, xd = 0, yd = 0, i = "", d = NODESCR_PROPERTY, t = "host", o = "unknown", uuid = create_uuid()) ⇒ Host
Returns a new instance of Host.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/node_host.rb', line 4 def initialize (ip="", mask=24, ipv6="", mask6=64, mp=nil, mac="(noarp)",n="(noname)", nn="(noname)",p=nil, s=UNKNOWN, xd=0 ,yd=0, i="", d=NODESCR_PROPERTY, t="host", o="unknown", uuid=create_uuid()) super(ip, mask, ipv6, mask6, mp, p, s, xd, yd, i, d, t, o, uuid) @mac=mac @dns_name=n @netbios_name=nn @name=NONAME_PROPERTY @dns_domain=NONAME_PROPERTY @netbios_domain=NONAME_PROPERTY @node_view=nil if mp != nil if $network[mp].status == UNMANAGED self.status=UNMANAGED end end #create gui view create_node() #store node in db 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_host.rb', line 2 def dns_domain @dns_domain end |
#dns_name ⇒ Object
Returns the value of attribute dns_name.
2 3 4 |
# File 'lib/node_host.rb', line 2 def dns_name @dns_name end |
#mac ⇒ Object
Returns the value of attribute mac.
2 3 4 |
# File 'lib/node_host.rb', line 2 def mac @mac end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/node_host.rb', line 2 def name @name end |
#netbios_domain ⇒ Object
Returns the value of attribute netbios_domain.
2 3 4 |
# File 'lib/node_host.rb', line 2 def netbios_domain @netbios_domain end |
#netbios_name ⇒ Object
Returns the value of attribute netbios_name.
2 3 4 |
# File 'lib/node_host.rb', line 2 def netbios_name @netbios_name end |
#node_view ⇒ Object
Returns the value of attribute node_view.
2 3 4 |
# File 'lib/node_host.rb', line 2 def node_view @node_view end |
Instance Method Details
#change_label(lb = nil) ⇒ Object
method for changing label of the node lb is nil when we just want a node label refresh
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/node_host.rb', line 102 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 lb == "mac_manufacturer" && mac? if (@mac[0,1] >= '0' && @mac[0,1] <= '9') macplus=@mac.split(/:/) #0,1,2 are reserved for the manufacturer macbeg="" for i in 0..2 if macplus[i].size == 1 #one digit macbeg="#{macbeg}0#{macplus[i]}" else macbeg="#{macbeg}#{macplus[i]}" end end manufacturer=find_manufacturer(macbeg) if manufacturer != nil macplus="#{manufacturer}:#{macplus[3]}:#{macplus[4]}:#{macplus[5]}" node_view.set_text("#{macplus.to_s}") end else node_view.set_text(get_dns_name()) end else if ((lb == "mac")||(lb == "mac_manufacturer")) && !mac? node_view.set_text("#{@ip}") else if lb == "dns_name" node_view.set_text(get_dns_name()) else node_view.set_text("#{eval lb}") end end end end end end |
#change_status(st) ⇒ Object
method for changing status (color) of the node st is a $status_value
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/node_host.rb', line 68 def change_status(st) if @status != st #status has changed @status=st @node_view.icon_color($status_color[$status_value.index(st)]) unless @node_view==nil @links.each {|l| l.update_status() } if $treenode_win.visible? $treenode_win.update_row(self) end #update status bar stats if not locked if !$event_win.() $event_win.() end #update status of the network unless st is UNMANAGED or UNKNOWN if (st != UNMANAGED) && (st != UNKNOWN) $network[@map].update_status() end end end |
#change_type(typ) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/node_host.rb', line 91 def change_type(typ) if @type != typ @node_view.set_type(typ) end @type=typ end |
#create_node ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/node_host.rb', line 142 def create_node() @old_label="" #set default label label=get_dns_name() if !dns_name? && ip != "" label="#{ip}" end if @map != nil #print "host ", $network[@map].ip, "\n" @node_view=NodeHostView.new($network[@map].map_view, self, $status_color[$status_value.index(@status)], "#{PIXMAP_PATH}/#{@icon}", label) #@node_view.hide() change_label($config.host_label_view) if !$config.show_label @node_view.hide_text() end end end |
#delete ⇒ Object
create_node
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/node_host.rb', line 161 def delete() #destroy the links del_all_links() #destroy the tooltips @node_view.hide_tooltips() #destroy the view @node_view.destroy() if $treenode_win.visible? $treenode_win.del_row(self) end #remove from db db_delete_node(HOSTNODE, ip, netmask) del_host(@ip) end |
#dns_name? ⇒ Boolean
36 37 38 |
# File 'lib/node_host.rb', line 36 def dns_name?() return dns_name != NONAME_PROPERTY end |
#get_dns_name ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/node_host.rb', line 44 def get_dns_name() if dns_name?() or @name == "" if $config.noshow_fqdn dns_name_tab="#{@dns_name}".split(/\./) return dns_name_tab[0] else return @dns_name end else #if no fqdn set return the hostname return @name end end |
#hostname? ⇒ Boolean
32 33 34 |
# File 'lib/node_host.rb', line 32 def hostname?() return name != NONAME_PROPERTY end |
#mac? ⇒ Boolean
28 29 30 |
# File 'lib/node_host.rb', line 28 def mac?() return mac != NOARP_PROPERTY end |
#netbios_name? ⇒ Boolean
40 41 42 |
# File 'lib/node_host.rb', line 40 def netbios_name?() return netbios_name != NONAME_PROPERTY end |
#refresh_dns_name ⇒ Object
58 59 60 61 62 |
# File 'lib/node_host.rb', line 58 def refresh_dns_name() if $config.host_label_view == "dns_name" @node_view.set_text(get_dns_name()) end end |
#reload ⇒ Object
reload pixmap icon to apply changes
193 194 195 196 197 198 199 200 |
# File 'lib/node_host.rb', line 193 def reload() if ($config.host_icon_view=="os") @icon="#{find_extension("os/#{@os}")}" else @icon="#{find_extension("type/#{@type}")}" end @node_view.set_image(@icon) end |
#set_severities(avail, snmp, custom, trap, serv, wmi, syslog, jmx) ⇒ Object
1 is avail 2 is snmp 3 is custom 4 is trap
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/node_host.rb', line 180 def set_severities(avail, snmp, custom, trap, serv, wmi, syslog, jmx) @avail_sev=avail @snmp_sev=snmp @custom_sev=custom @trap_sev=trap @service_sev=serv @wmi_sev=wmi @syslog_sev=syslog @jmx_sev=jmx refresh_status() end |
#to_t ⇒ Object
Return a table for the find tool
205 206 207 208 209 |
# File 'lib/node_host.rb', line 205 def to_t tmp=[] tmp.push(@ip,$status[$status_value.index(@status)], @mac, @dns_name, @netbios_name, @description, @type, @os) return tmp end |
#write_db ⇒ Object
211 212 213 |
# File 'lib/node_host.rb', line 211 def write_db() return db_insert_node_prp(uuid,HOSTNODE,ip,netmask,ipv6,netmask6,mac,map,status,avail_sev,snmp_sev,custom_sev,trap_sev, service_sev, wmi_sev, syslog_sev, jmx_sev, x,y,icon,description, nil, nil, nil,nil,type,os,"",dns_name,"",netbios_name,"",nil,nil,nil) end |