Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/node.rb
Constant Summary collapse
- NONAME_PROPERTY =
"(noname)"
- NOARP_PROPERTY =
"(noarp)"
- NODESCR_PROPERTY =
"(nodesc)"
Instance Attribute Summary collapse
-
#alert_type_by_level ⇒ Object
Returns the value of attribute alert_type_by_level.
-
#avail_sev ⇒ Object
readonly
Returns the value of attribute avail_sev.
-
#custom_monitoring ⇒ Object
accessor for inner field.
-
#custom_sev ⇒ Object
readonly
Returns the value of attribute custom_sev.
-
#description ⇒ Object
accessor for inner field.
-
#http_monitoring ⇒ Object
accessor for inner field.
-
#icon ⇒ Object
accessor for inner field.
-
#im_dest_by_level ⇒ Object
accessor for alert specific reaction.
-
#inherit_from_global ⇒ Object
Returns the value of attribute inherit_from_global.
-
#interface ⇒ Object
accessor for inner field.
-
#ip ⇒ Object
(also: #ipv4)
accessor for inner field.
-
#ipv6 ⇒ Object
accessor for inner field.
-
#jmx_monitoring ⇒ Object
accessor for inner field.
-
#jmx_sev ⇒ Object
readonly
Returns the value of attribute jmx_sev.
-
#mail_by_level ⇒ Object
accessor for alert specific reaction.
-
#map ⇒ Object
accessor for inner field.
-
#netmask ⇒ Object
(also: #netmask4)
accessor for inner field.
-
#netmask6 ⇒ Object
accessor for inner field.
-
#node_view ⇒ Object
accessor for inner field.
-
#os ⇒ Object
accessor for inner field.
-
#script_name_by_level ⇒ Object
accessor for alert specific reaction.
-
#service ⇒ Object
accessor for inner field.
-
#service_sev ⇒ Object
readonly
Returns the value of attribute service_sev.
-
#sms_num_by_level ⇒ Object
accessor for alert specific reaction.
-
#snmp_monitoring ⇒ Object
accessor for inner field.
-
#snmp_port ⇒ Object
accessor for inner field.
-
#snmp_retry ⇒ Object
accessor for inner field.
-
#snmp_sev ⇒ Object
readonly
Returns the value of attribute snmp_sev.
-
#snmp_timeout ⇒ Object
accessor for inner field.
-
#snmp_version ⇒ Object
accessor for inner field.
-
#snmptrap_monitoring ⇒ Object
accessor for inner field.
-
#sound_file_path_by_level ⇒ Object
accessor for alert specific reaction.
-
#status ⇒ Object
accessor for inner field.
-
#syslog_monitoring ⇒ Object
accessor for inner field.
-
#syslog_sev ⇒ Object
readonly
Returns the value of attribute syslog_sev.
-
#trap_sev ⇒ Object
readonly
Returns the value of attribute trap_sev.
-
#type ⇒ Object
accessor for inner field.
-
#uuid ⇒ Object
accessor for inner field.
-
#wmi_monitoring ⇒ Object
accessor for inner field.
-
#wmi_sev ⇒ Object
readonly
Returns the value of attribute wmi_sev.
-
#x ⇒ Object
accessor for inner field.
-
#y ⇒ Object
accessor for inner field.
Instance Method Summary collapse
-
#account_exist?(id) ⇒ Boolean
check if a given account id already exist.
-
#account_exist_nr?(id) ⇒ Boolean
check if a given account id already exist for the host (non recursive).
-
#account_size ⇒ Object
check if a given account id already exist.
-
#add_account(id, login, passwd) ⇒ Object
add an account.
- #add_custom_monitoring(state, custom_mon_name, param, sev, status = nil) ⇒ Object
- #add_custom_monitoring_bulk(custom_mon_array) ⇒ Object
-
#add_db_account(accounts) ⇒ Object
add account in db.
- #add_interface(n, lstatus = nil, sp = nil, tp = nil) ⇒ Object
- #add_jmx_monitoring(state, jmxref_name, proto, port, auth, attribuesh) ⇒ Object
-
#add_link(lnk) ⇒ Object
add a link to links hash.
- #add_service(protocol, port, name = "?", monitor_flag = 1, sev = 0) ⇒ Object
- #add_snmp_monitoring(state, oidref_name, op, val, sev, status = nil) ⇒ Object
- #add_snmptrap_monitoring(state, snmptrap_ref_name, sev, status = nil) ⇒ Object
- #add_syslog_monitoring(state, syslog_ref_name, sev, status = nil) ⇒ Object
- #add_wmi_monitoring(state, wmiref_name, op, val, sev, status = nil) ⇒ Object
-
#clear_account ⇒ Object
clear all accounts from the hash.
-
#clear_custom_monitoring ⇒ Object
clear all custom monitoring.
-
#clear_db_accounts ⇒ Object
clear all accounts from db.
-
#clear_jmx_monitoring ⇒ Object
clear all jmx monitoring.
-
#clear_service ⇒ Object
clear all services.
-
#clear_snmp_monitoring ⇒ Object
clear all snmp monitoring.
-
#clear_snmptrap_monitoring ⇒ Object
clear all snmptrap monitoring.
-
#clear_syslog_monitoring ⇒ Object
clear all syslog monitoring.
-
#clear_wmi_monitoring ⇒ Object
clear all wmi monitoring.
-
#custom_parameter(name) ⇒ Object
return custom monitoring parameter.
-
#custom_severity(name) ⇒ Object
return custom monitoring severity.
-
#del_account(id) ⇒ Object
del an account.
-
#del_all_links ⇒ Object
remove all links between connected nodes.
- #del_custom_monitoring(custom_mon_name) ⇒ Object
- #del_interface(n) ⇒ Object
- #del_jmx_monitoring(oidref_name) ⇒ Object
-
#del_link(lnk) ⇒ Object
del link from links hash pass in 1st argument.
-
#del_node_link(node) ⇒ Object
del link from links hash between node pass as 1st argument.
- #del_service(protocol, port) ⇒ Object
- #del_snmp_monitoring(oidref_name) ⇒ Object
- #del_snmptrap_monitoring(snmptrap_ref_name) ⇒ Object
- #del_syslog_monitoring(syslog_ref_name) ⇒ Object
- #del_wmi_monitoring(oidref_name) ⇒ Object
-
#description? ⇒ Boolean
return description if different from default value.
-
#disable_alert_type(type, level) ⇒ Object
disable type of alert according to a level.
-
#enable_alert_type(type, level) ⇒ Object
enable type of alert according to a level.
-
#get_account_id(id) ⇒ Object
get the account idents.
-
#get_account_login(id) ⇒ Object
get the account login specify by id.
-
#get_account_password(id) ⇒ Object
get the account password specify by id.
-
#get_all_account ⇒ Object
get the accounts hash.
-
#get_default_inherit_snmp_port ⇒ Object
return either the overwritten snmp port or the inherit snmp port from network ancestor.
-
#get_default_inherit_snmp_retry ⇒ Object
return either the overwritten snmp retry or the inherit snmp retry from network ancestor.
-
#get_default_inherit_snmp_timeout ⇒ Object
return either the overwritten snmp timeout or the inherit snmp timeout from network ancestor.
-
#get_default_inherit_snmp_version ⇒ Object
return either the overwritten snmp version or the default general value.
-
#get_links ⇒ Object
return links hash.
- #get_node_type ⇒ Object
-
#get_service_sev(protocol, port) ⇒ Object
get severity associated to a given proto/port.
- #hide_label ⇒ Object
-
#init_account_from_db ⇒ Object
init account from db.
- #init_jmx_from_db ⇒ Object
-
#initialize(ip = "", mask = 24, ipv6 = "", mask6 = 64, mp = nil, serv = nil, s = UNKNOWN, xd = 0, yd = 0, i = "", d = NODESCR_PROPERTY, t = nil, o = "unknown", uuid = create_uuid()) ⇒ Node
constructor
A new instance of Node.
-
#is_service_monitor(protocol, port) ⇒ Object
check if a given port is monitored.
-
#linked(node) ⇒ Object
check if it exists a link between node pass in 1st argument return 1 if true or 0 if false.
- #nb_interface ⇒ Object
-
#nb_links ⇒ Object
return value corresponding to the links between other nodes.
-
#point_pos ⇒ Object
return a point corresponding to the position of the node.
-
#refresh_status ⇒ Object
update status based on the avail, snmp, custom severities.
-
#service_by_name(name) ⇒ Object
return service instance based on the service name as a key.
- #service_key(protocol, port) ⇒ Object
-
#set_account_login(id, value) ⇒ Object
set the account login specify by id.
-
#set_account_password(id, value) ⇒ Object
set the account password specify by id.
-
#set_all_account(haccount) ⇒ Object
set the accounts hash.
-
#set_all_interface(intf) ⇒ Object
set the interface hash.
- #set_all_severity(sev) ⇒ Object
- #set_avail_severity(sev) ⇒ Object
- #set_custom_severity(sev) ⇒ Object
- #set_inherit_conf(bool) ⇒ Object
- #set_jmx_severity(sev) ⇒ Object
- #set_label_visibility ⇒ Object
-
#set_map(map) ⇒ Object
set map for changing map of a node.
- #set_service_severity(sev) ⇒ Object
- #set_severity(event_type, sev) ⇒ Object
-
#set_snmp_conf(rcommunity, wcommunity, version, port, timeout, snmpretry, saveindb_flag = 0) ⇒ Object
each time global conf is changed we have to modify the root node config.
-
#set_snmp_severity(sev) ⇒ Object
sev is an index $status_value.
- #set_syslog_severity(sev) ⇒ Object
-
#set_trap_severity(sev) ⇒ Object
use for snmp trap and syslog msgs.
- #set_wmi_severity(sev) ⇒ Object
- #show_label ⇒ Object
Constructor Details
#initialize(ip = "", mask = 24, ipv6 = "", mask6 = 64, mp = nil, serv = nil, s = UNKNOWN, xd = 0, yd = 0, i = "", d = NODESCR_PROPERTY, t = nil, o = "unknown", uuid = create_uuid()) ⇒ Node
Returns a new instance of Node.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 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 227 228 229 230 231 232 |
# File 'lib/node.rb', line 126 def initialize (ip="", mask=24, ipv6="", mask6=64, mp=nil, serv=nil, s=UNKNOWN, xd=0 ,yd=0, i="", d=NODESCR_PROPERTY, t=nil, o="unknown", uuid=create_uuid()) @uuid = uuid @ip=ip if isInteger(mask) @netmask = mask elsif isValidIPv4(mask) @netmask = IPCalc.netmask_to_bits(mask) end @ipv6=ipv6 @netmask6=mask6 if serv #serv must be a hash of service class @service=serv.dup else @service=Hash.new end @snmp_monitoring=Hash.new @wmi_monitoring=Hash.new @custom_monitoring=Hash.new @syslog_monitoring=Hash.new @snmptrap_monitoring=Hash.new @jmx_monitoring=Hash.new @http_monitoring=Hash.new @status=s @avail_sev=UNKNOWN @snmp_sev=UNMANAGED @custom_sev=UNMANAGED @trap_sev=UNMANAGED @service_sev=UNMANAGED @wmi_sev=UNMANAGED @syslog_sev=UNMANAGED @jmx_sev=UNMANAGED @account=Hash.new @group=Array.new @interface=Hash.new @x=xd @y=yd @links=[] @type=t if i == "" || i == nil if $config.host_icon_view=="os" @icon = "os/unknown.png" else #type if (@type != nil) && (@type != "") @icon = "#{find_extension("type/#{@type}")}" end end else @icon=i end if d == "" || d == nil @description="" else @description=d end @os=o #ip and map could not be the same if mp != ip if mp == nil && ip != ROOTMAPADDR #we want the node on the root network @map=ROOTMAPADDR else if ip == ROOTMAPADDR @map=nil @snmp_version=$config.snmp_version @snmp_port=$config.snmp_port @snmp_timeout=$config.snmp_timeout @snmp_retry=$config.snmp_retry else @map=mp if $network[mp] @snmp_version=$network[mp].snmp_version @snmp_port=$network[mp].snmp_port @snmp_timeout=$network[mp].snmp_timeout @snmp_retry=$network[mp].snmp_retry end end end else @map=ROOTMAPADDR end @mail_by_level = Hash.new $config.init_hash_conf_by_level(@mail_by_level) @sound_file_path_by_level = Hash.new $config.init_hash_conf_by_level(@sound_file_path_by_level) @sms_num_by_level = Hash.new $config.init_hash_conf_by_level(@sms_num_by_level) @im_dest_by_level = Hash.new $config.init_hash_conf_by_level(@im_dest_by_level) @script_name_by_level = Hash.new $config.init_hash_conf_by_level(@script_name_by_level) @inherit_from_global=true @alert_type_by_level = Hash.new init_level_alert_type(@alert_type_by_level) end |
Instance Attribute Details
#alert_type_by_level ⇒ Object
Returns the value of attribute alert_type_by_level.
16 17 18 |
# File 'lib/node.rb', line 16 def alert_type_by_level @alert_type_by_level end |
#avail_sev ⇒ Object (readonly)
Returns the value of attribute avail_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def avail_sev @avail_sev end |
#custom_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def custom_monitoring @custom_monitoring end |
#custom_sev ⇒ Object (readonly)
Returns the value of attribute custom_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def custom_sev @custom_sev end |
#description ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def description @description end |
#http_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def http_monitoring @http_monitoring end |
#icon ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def icon @icon end |
#im_dest_by_level ⇒ Object
accessor for alert specific reaction
15 16 17 |
# File 'lib/node.rb', line 15 def im_dest_by_level @im_dest_by_level end |
#inherit_from_global ⇒ Object
Returns the value of attribute inherit_from_global.
16 17 18 |
# File 'lib/node.rb', line 16 def inherit_from_global @inherit_from_global end |
#interface ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def interface @interface end |
#ip ⇒ Object Also known as: ipv4
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def ip @ip end |
#ipv6 ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def ipv6 @ipv6 end |
#jmx_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def jmx_monitoring @jmx_monitoring end |
#jmx_sev ⇒ Object (readonly)
Returns the value of attribute jmx_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def jmx_sev @jmx_sev end |
#mail_by_level ⇒ Object
accessor for alert specific reaction
15 16 17 |
# File 'lib/node.rb', line 15 def mail_by_level @mail_by_level end |
#map ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def map @map end |
#netmask ⇒ Object Also known as: netmask4
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def netmask @netmask end |
#netmask6 ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def netmask6 @netmask6 end |
#node_view ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def node_view @node_view end |
#os ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def os @os end |
#script_name_by_level ⇒ Object
accessor for alert specific reaction
15 16 17 |
# File 'lib/node.rb', line 15 def script_name_by_level @script_name_by_level end |
#service ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def service @service end |
#service_sev ⇒ Object (readonly)
Returns the value of attribute service_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def service_sev @service_sev end |
#sms_num_by_level ⇒ Object
accessor for alert specific reaction
15 16 17 |
# File 'lib/node.rb', line 15 def sms_num_by_level @sms_num_by_level end |
#snmp_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def snmp_monitoring @snmp_monitoring end |
#snmp_port ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def snmp_port @snmp_port end |
#snmp_retry ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def snmp_retry @snmp_retry end |
#snmp_sev ⇒ Object (readonly)
Returns the value of attribute snmp_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def snmp_sev @snmp_sev end |
#snmp_timeout ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def snmp_timeout @snmp_timeout end |
#snmp_version ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def snmp_version @snmp_version end |
#snmptrap_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def snmptrap_monitoring @snmptrap_monitoring end |
#sound_file_path_by_level ⇒ Object
accessor for alert specific reaction
15 16 17 |
# File 'lib/node.rb', line 15 def sound_file_path_by_level @sound_file_path_by_level end |
#status ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def status @status end |
#syslog_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def syslog_monitoring @syslog_monitoring end |
#syslog_sev ⇒ Object (readonly)
Returns the value of attribute syslog_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def syslog_sev @syslog_sev end |
#trap_sev ⇒ Object (readonly)
Returns the value of attribute trap_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def trap_sev @trap_sev end |
#type ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def type @type end |
#uuid ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def uuid @uuid end |
#wmi_monitoring ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def wmi_monitoring @wmi_monitoring end |
#wmi_sev ⇒ Object (readonly)
Returns the value of attribute wmi_sev.
13 14 15 |
# File 'lib/node.rb', line 13 def wmi_sev @wmi_sev end |
#x ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def x @x end |
#y ⇒ Object
accessor for inner field
12 13 14 |
# File 'lib/node.rb', line 12 def y @y end |
Instance Method Details
#account_exist?(id) ⇒ Boolean
check if a given account id already exist
981 982 983 984 985 986 987 |
# File 'lib/node.rb', line 981 def account_exist?(id) if !@map return @account.has_key?(id) end #account can also be the account from the network return @account.has_key?(id) || $network[@map].get_all_account().has_key?(id) end |
#account_exist_nr?(id) ⇒ Boolean
check if a given account id already exist for the host (non recursive)
992 993 994 |
# File 'lib/node.rb', line 992 def account_exist_nr?(id) return @account.has_key?(id) end |
#account_size ⇒ Object
check if a given account id already exist
906 907 908 |
# File 'lib/node.rb', line 906 def account_size() return @account.size() end |
#add_account(id, login, passwd) ⇒ Object
add an account
999 1000 1001 1002 1003 1004 1005 |
# File 'lib/node.rb', line 999 def add_account(id, login, passwd) if !account_exist_nr?(id) @account[id] = Array.new(2) @account[id][0] = login @account[id][1] = passwd end end |
#add_custom_monitoring(state, custom_mon_name, param, sev, status = nil) ⇒ Object
678 679 680 681 682 683 |
# File 'lib/node.rb', line 678 def add_custom_monitoring(state, custom_mon_name, param, sev, status=nil) if $custom_monitor and ($custom_monitor.index(custom_mon_name) != nil) and (@custom_monitoring[custom_mon_name] == nil) @custom_monitoring[custom_mon_name] = CustomMonitoring.new(state.to_i, custom_mon_name, param, sev.to_i) db_add_custom_monitoring(ip, get_node_type(), [state, custom_mon_name, param, sev]) unless status end end |
#add_custom_monitoring_bulk(custom_mon_array) ⇒ Object
685 686 687 688 689 690 |
# File 'lib/node.rb', line 685 def add_custom_monitoring_bulk(custom_mon_array) custom_mon_array.each {|state, custom_mon_name, param, sev| add_custom_monitoring(state.to_i, custom_mon_name, param, sev.to_i, "init") } db_add_custom_monitoring(ip, get_node_type(), custom_mon_array) end |
#add_db_account(accounts) ⇒ Object
add account in db
797 798 799 |
# File 'lib/node.rb', line 797 def add_db_account(accounts) db_add_account(ip, get_node_type(), accounts) end |
#add_interface(n, lstatus = nil, sp = nil, tp = nil) ⇒ Object
642 643 644 645 646 647 648 649 |
# File 'lib/node.rb', line 642 def add_interface(n, lstatus=nil, sp=nil, tp=nil) if @interface[n] == nil @interface[n] = Interface.new(n, lstatus, sp, tp) #we are adding it in db at save time else $log.error("Interface #{n} already exists") end end |
#add_jmx_monitoring(state, jmxref_name, proto, port, auth, attribuesh) ⇒ Object
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/node.rb', line 605 def add_jmx_monitoring(state, jmxref_name, proto, port, auth, attribuesh) if @jmx_monitoring[jmxref_name] == nil if JMXRef::jmx_ref_exist?(jmxref_name) @jmx_monitoring[jmxref_name]=JmxMonitoring.new(state, jmxref_name, proto, port, auth) attribuesh.each_value {|attr| if attr.class == JmxAttributeMonitoring @jmx_monitoring[jmxref_name].add_attribute(attr.attributeName, attr.operator, attr.value, attr.severity) end } $jmx_refs[jmxref_name].add_use() else $log.error("JMX entry #{jmxref_name} is unknown") end end end |
#add_link(lnk) ⇒ Object
add a link to links hash
283 284 285 286 287 |
# File 'lib/node.rb', line 283 def add_link(lnk) if @links.index(lnk) == nil @links.push(lnk) end end |
#add_service(protocol, port, name = "?", monitor_flag = 1, sev = 0) ⇒ Object
554 555 556 557 558 559 560 |
# File 'lib/node.rb', line 554 def add_service(protocol, port, name="?", monitor_flag=1, sev=0) if @service[service_key(protocol, port)] == nil @service[service_key(protocol, port)] = Service.new(protocol,port,name,monitor_flag,$status.index(sev)) end #store in db db_add_service(ip, get_node_type(), protocol, port, name, monitor_flag, $status.index(sev)) end |
#add_snmp_monitoring(state, oidref_name, op, val, sev, status = nil) ⇒ Object
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
# File 'lib/node.rb', line 621 def add_snmp_monitoring(state, oidref_name, op, val, sev, status=nil) if @snmp_monitoring[oidref_name] == nil if OIDRef::oid_ref_exist?(oidref_name) if sev.class != Fixnum @snmp_monitoring[oidref_name]=SnmpMonitoring.new(state, oidref_name, SnmpMonitoring::TESTOP.index(op), val, $status.index(sev)) db_add_snmp_monitoring(ip, get_node_type(), state, oidref_name, SnmpMonitoring::TESTOP.index(op), val, $status.index(sev)) unless status else @snmp_monitoring[oidref_name]=SnmpMonitoring.new(state, oidref_name, op, val, sev) db_add_snmp_monitoring(ip, get_node_type(), state, oidref_name, op, val, sev) unless status end $oid_refs[oidref_name].add_use() else $log.error("SNMP OID #{oidref_name} is unknown") end end end |
#add_snmptrap_monitoring(state, snmptrap_ref_name, sev, status = nil) ⇒ Object
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/node.rb', line 729 def add_snmptrap_monitoring(state, snmptrap_ref_name, sev, status=nil) if @snmptrap_monitoring[snmptrap_ref_name] == nil if SnmpTrapRef::snmptrap_ref_exist?(snmptrap_ref_name) if sev.class != Fixnum sev_tmp=$status.index(sev) if sev_tmp == nil sev_tmp=0 else sev_tmp+=1 end @snmptrap_monitoring[snmptrap_ref_name]=SnmpTrapMonitoring.new(state, snmptrap_ref_name, sev_tmp) db_add_snmptrap_monitoring(ip, get_node_type(), state, snmptrap_ref_name, sev_tmp) unless status else @snmptrap_monitoring[snmptrap_ref_name]=SnmpTrapMonitoring.new(state, snmptrap_ref_name, sev) db_add_snmptrap_monitoring(ip, get_node_type(), state, snmptrap_ref_name, sev) unless status end $snmptrap_refs[snmptrap_ref_name].add_use() end end end |
#add_syslog_monitoring(state, syslog_ref_name, sev, status = nil) ⇒ Object
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/node.rb', line 698 def add_syslog_monitoring(state, syslog_ref_name, sev, status=nil) if @syslog_monitoring[syslog_ref_name] == nil if SyslogRef::syslog_ref_exist?(syslog_ref_name) if sev.class != Fixnum #puts "add_syslog_monitoring ", syslog_ref_name, sev, $status.index(sev) #here 0 sev corresponds to map syslog default severity sev_tmp=$status.index(sev) if sev_tmp == nil sev_tmp=0 else sev_tmp+=1 end @syslog_monitoring[syslog_ref_name]=SyslogMonitoring.new(state, syslog_ref_name, sev_tmp) db_add_syslog_monitoring(ip, get_node_type(), state, syslog_ref_name , sev_tmp) unless status else #puts "add_syslog_monitoring ", syslog_ref_name, sev @syslog_monitoring[syslog_ref_name]=SyslogMonitoring.new(state, syslog_ref_name, sev) db_add_syslog_monitoring(ip, get_node_type(), state, syslog_ref_name , sev) unless status end $syslog_refs[syslog_ref_name].add_use() end end end |
#add_wmi_monitoring(state, wmiref_name, op, val, sev, status = nil) ⇒ Object
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/node.rb', line 588 def add_wmi_monitoring(state, wmiref_name, op, val, sev, status=nil) if @wmi_monitoring[wmiref_name] == nil if WMIRef::wmi_ref_exist?(wmiref_name) if sev.class != Fixnum @wmi_monitoring[wmiref_name]=WmiMonitoring.new(state, wmiref_name, WmiMonitoring::TESTOP.index(op), val, $status.index(sev)) db_add_wmi_monitoring(ip, get_node_type(), state, wmiref_name, WmiMonitoring::TESTOP.index(op), val, $status.index(sev)) unless status else @wmi_monitoring[wmiref_name]=WmiMonitoring.new(state, wmiref_name, op, val, sev) db_add_wmi_monitoring(ip, get_node_type(), state, wmiref_name, op, val, sev) unless status end $wmi_refs[wmiref_name].add_use() else $log.error("WMI entry #{wmiref_name} is unknown") end end end |
#clear_account ⇒ Object
clear all accounts from the hash
783 784 785 |
# File 'lib/node.rb', line 783 def clear_account() @account=Hash.new end |
#clear_custom_monitoring ⇒ Object
clear all custom monitoring
861 862 863 864 |
# File 'lib/node.rb', line 861 def clear_custom_monitoring() @custom_monitoring=Hash.new db_del_custom_monitoring(ip, get_node_type()) end |
#clear_db_accounts ⇒ Object
clear all accounts from db
790 791 792 |
# File 'lib/node.rb', line 790 def clear_db_accounts() db_del_accounts(ip, get_node_type()) end |
#clear_jmx_monitoring ⇒ Object
clear all jmx monitoring
823 824 825 826 827 828 829 |
# File 'lib/node.rb', line 823 def clear_jmx_monitoring() @jmx_monitoring.each_value do |jmx_mon| $jmx_refs[jmx_mon.get_ref()].del_use() end @jmx_monitoring=Hash.new db_del_jmx_monitoring(ip, get_node_type()) end |
#clear_service ⇒ Object
clear all services
804 805 806 807 |
# File 'lib/node.rb', line 804 def clear_service() @service=Hash.new db_del_services(ip, get_node_type()) end |
#clear_snmp_monitoring ⇒ Object
clear all snmp monitoring
850 851 852 853 854 855 856 |
# File 'lib/node.rb', line 850 def clear_snmp_monitoring() @snmp_monitoring.each_value do |snmp_mon| $oid_refs[snmp_mon.oidref].del_use() end @snmp_monitoring=Hash.new db_del_snmp_monitoring(ip, get_node_type()) end |
#clear_snmptrap_monitoring ⇒ Object
clear all snmptrap monitoring
869 870 871 872 873 874 875 |
# File 'lib/node.rb', line 869 def clear_snmptrap_monitoring() @snmptrap_monitoring.each_value do |snmptrap_mon| $snmptrap_refs[snmptrap_mon.get_snmptrap_ref()].del_use() end @snmptrap_monitoring=Hash.new db_del_snmptrap_monitoring(ip, get_node_type()) end |
#clear_syslog_monitoring ⇒ Object
clear all syslog monitoring
880 881 882 883 884 885 886 |
# File 'lib/node.rb', line 880 def clear_syslog_monitoring() @syslog_monitoring.each_value do |syslog_mon| $syslog_refs[syslog_mon.get_syslog_ref()].del_use() end @syslog_monitoring=Hash.new db_del_syslog_monitoring(ip, get_node_type()) end |
#clear_wmi_monitoring ⇒ Object
clear all wmi monitoring
812 813 814 815 816 817 818 |
# File 'lib/node.rb', line 812 def clear_wmi_monitoring() @wmi_monitoring.each_value do |wmi_mon| $wmi_refs[wmi_mon.wmiref].del_use() end @wmi_monitoring=Hash.new db_del_wmi_monitoring(ip, get_node_type()) end |
#custom_parameter(name) ⇒ Object
return custom monitoring parameter
532 533 534 535 536 537 538 |
# File 'lib/node.rb', line 532 def custom_parameter(name) cust = @custom_monitoring[name] if cust return cust.param end return nil end |
#custom_severity(name) ⇒ Object
return custom monitoring severity
523 524 525 526 527 528 529 |
# File 'lib/node.rb', line 523 def custom_severity(name) cust = @custom_monitoring[name] if cust return cust.severity end return nil end |
#del_account(id) ⇒ Object
del an account
1010 1011 1012 |
# File 'lib/node.rb', line 1010 def del_account(id) return @account.delete(id) end |
#del_all_links ⇒ Object
remove all links between connected nodes
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/node.rb', line 236 def del_all_links() if nb_links() > 0 nb_link=nb_links() cpt=0 links_t=@links.dup while cpt < nb_link do lnk=links_t[cpt] lnk.node1.del_link(lnk) lnk.node2.del_link(lnk) $links.delete(lnk) lnk.remove_link() cpt+=1 end @links.clear end end |
#del_custom_monitoring(custom_mon_name) ⇒ Object
692 693 694 695 696 |
# File 'lib/node.rb', line 692 def del_custom_monitoring(custom_mon_name) if @custom_monitoring[custom_mon_name] != nil @custom_monitoring[custom_mon_name].delete() end end |
#del_interface(n) ⇒ Object
651 652 653 654 655 |
# File 'lib/node.rb', line 651 def del_interface(n) if @interface[n] != nil @interface[n].delete() end end |
#del_jmx_monitoring(oidref_name) ⇒ Object
664 665 666 667 668 669 |
# File 'lib/node.rb', line 664 def del_jmx_monitoring(oidref_name) if @jmx_monitoring[oidref_name] != nil $jmx_refs[oidref_name].del_use() @jmx_monitoring[oidref_name].delete() end end |
#del_link(lnk) ⇒ Object
del link from links hash pass in 1st argument
308 309 310 |
# File 'lib/node.rb', line 308 def del_link(lnk) @links.delete(lnk) end |
#del_node_link(node) ⇒ Object
del link from links hash between node pass as 1st argument
292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/node.rb', line 292 def del_node_link(node) @links.each {|lnk| if lnk.point?(node) lnk.node1.del_link(lnk) lnk.node2.del_link(lnk) $links.delete(lnk) lnk.remove_link() return 1 end } return 0 end |
#del_service(protocol, port) ⇒ Object
562 563 564 565 566 567 568 |
# File 'lib/node.rb', line 562 def del_service(protocol, port) if @service[service_key(protocol, port)] != nil @service[service_key(protocol, port)].delete() end #del in db db_del_service(protocol, port) end |
#del_snmp_monitoring(oidref_name) ⇒ Object
671 672 673 674 675 676 |
# File 'lib/node.rb', line 671 def del_snmp_monitoring(oidref_name) if @snmp_monitoring[oidref_name] != nil $oid_refs[oidref_name].del_use() @snmp_monitoring[oidref_name].delete() end end |
#del_snmptrap_monitoring(snmptrap_ref_name) ⇒ Object
750 751 752 753 754 755 |
# File 'lib/node.rb', line 750 def del_snmptrap_monitoring(snmptrap_ref_name) if @snmptrap_monitoring[snmptrap_ref_name] != nil $snmptrap_refs[snmptrap_ref_name].del_use() @snmptrap_monitoring[snmptrap_ref_name].delete() end end |
#del_syslog_monitoring(syslog_ref_name) ⇒ Object
722 723 724 725 726 727 |
# File 'lib/node.rb', line 722 def del_syslog_monitoring(syslog_ref_name) if @syslog_monitoring[syslog_ref_name] != nil $syslog_refs[syslog_ref_name].del_use() @syslog_monitoring[syslog_ref_name].delete() end end |
#del_wmi_monitoring(oidref_name) ⇒ Object
657 658 659 660 661 662 |
# File 'lib/node.rb', line 657 def del_wmi_monitoring(oidref_name) if @wmi_monitoring[oidref_name] != nil $wmi_refs[oidref_name].del_use() @wmi_monitoring[oidref_name].delete() end end |
#description? ⇒ Boolean
return description if different from default value
892 893 894 |
# File 'lib/node.rb', line 892 def description?() return description != "(nodesc)" end |
#disable_alert_type(type, level) ⇒ Object
disable type of alert according to a level
55 56 57 58 59 60 61 62 63 |
# File 'lib/node.rb', line 55 def disable_alert_type(type, level) ind=$talert_type.index(type) if ind > -1 set_alert_type(type, level, false) return 0 end return 1 end |
#enable_alert_type(type, level) ⇒ Object
enable type of alert according to a level
43 44 45 46 47 48 49 50 |
# File 'lib/node.rb', line 43 def enable_alert_type(type, level) ind=$talert_type.index(type) if ind > -1 set_alert_type(type, level, true) return 0 end return 1 end |
#get_account_id(id) ⇒ Object
get the account idents
943 944 945 946 947 948 |
# File 'lib/node.rb', line 943 def get_account_id(id) if account_exist_nr?(id) return @account[id] end return $network[@map].get_all_account()[id] end |
#get_account_login(id) ⇒ Object
get the account login specify by id
953 954 955 |
# File 'lib/node.rb', line 953 def get_account_login(id) return @account[id][0] end |
#get_account_password(id) ⇒ Object
get the account password specify by id
967 968 969 |
# File 'lib/node.rb', line 967 def get_account_password(id) return @account[id][1] end |
#get_all_account ⇒ Object
get the accounts hash
913 914 915 |
# File 'lib/node.rb', line 913 def get_all_account() return @account end |
#get_default_inherit_snmp_port ⇒ Object
return either the overwritten snmp port or the inherit snmp port from network ancestor
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/node.rb', line 68 def get_default_inherit_snmp_port() if (self.class == Network) && (@snmp_port != nil) return @snmp_port else if @map == ROOTMAPADDR return $config.snmp_port else return $network[@map].get_default_inherit_snmp_port() end end end |
#get_default_inherit_snmp_retry ⇒ Object
return either the overwritten snmp retry or the inherit snmp retry from network ancestor
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/node.rb', line 113 def get_default_inherit_snmp_retry() if (self.class == Network) && (@snmp_retry != nil) return @snmp_retry else if @map == ROOTMAPADDR return $config.snmp_retry else return $network[@map].get_default_inherit_snmp_retry() end end end |
#get_default_inherit_snmp_timeout ⇒ Object
return either the overwritten snmp timeout or the inherit snmp timeout from network ancestor
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/node.rb', line 98 def get_default_inherit_snmp_timeout() if (self.class == Network) && (@snmp_timeout != nil) return @snmp_timeout else if @map == ROOTMAPADDR return $config.snmp_timeout else return $network[@map].get_default_inherit_snmp_timeout() end end end |
#get_default_inherit_snmp_version ⇒ Object
return either the overwritten snmp version or the default general value
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/node.rb', line 83 def get_default_inherit_snmp_version() if (self.class == Network) && (@snmp_version != nil) return @snmp_version else if @map == ROOTMAPADDR return $config.snmp_version else return $network[@map].get_default_inherit_snmp_version() end end end |
#get_links ⇒ Object
return links hash
256 257 258 |
# File 'lib/node.rb', line 256 def get_links() return @links end |
#get_node_type ⇒ Object
839 840 841 842 843 844 845 |
# File 'lib/node.rb', line 839 def get_node_type() nodetype=HOSTNODE if self.class == Network nodetype=NETWORKNODE end return nodetype end |
#get_service_sev(protocol, port) ⇒ Object
get severity associated to a given proto/port
580 581 582 583 584 585 586 |
# File 'lib/node.rb', line 580 def get_service_sev(protocol, port) serv = @service[service_key(protocol, port)] if serv.nil? or !isInteger(serv.severity) return 0 end return serv.severity end |
#hide_label ⇒ Object
425 426 427 |
# File 'lib/node.rb', line 425 def hide_label() @node_view.hide_text() end |
#init_account_from_db ⇒ Object
init account from db
935 936 937 938 |
# File 'lib/node.rb', line 935 def init_account_from_db() clear_account() @account=db_get_accounts(ip, get_node_type()) end |
#init_jmx_from_db ⇒ Object
831 832 833 834 835 836 837 |
# File 'lib/node.rb', line 831 def init_jmx_from_db() @jmx_monitoring.each_value do |jmx_mon| $jmx_refs[jmx_mon.get_ref()].del_use() end @jmx_monitoring=Hash.new db_get_jmx_monitoring(ip, get_node_type()) end |
#is_service_monitor(protocol, port) ⇒ Object
check if a given port is monitored
573 574 575 |
# File 'lib/node.rb', line 573 def is_service_monitor(protocol, port) return (@service[service_key(protocol, port)] != nil) && (@service[service_key(protocol, port)].monitored?()) end |
#linked(node) ⇒ Object
check if it exists a link between node pass in 1st argument return 1 if true or 0 if false
271 272 273 274 275 276 277 278 |
# File 'lib/node.rb', line 271 def linked(node) @links.each {|lnk| if lnk.point?(node) return 1 end } return 0 end |
#nb_interface ⇒ Object
638 639 640 |
# File 'lib/node.rb', line 638 def nb_interface() return @interface.size end |
#nb_links ⇒ Object
return value corresponding to the links between other nodes
263 264 265 |
# File 'lib/node.rb', line 263 def nb_links() return @links.size end |
#point_pos ⇒ Object
return a point corresponding to the position of the node
899 900 901 |
# File 'lib/node.rb', line 899 def point_pos() return [@x, @y] end |
#refresh_status ⇒ Object
update status based on the avail, snmp, custom severities
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/node.rb', line 315 def refresh_status() $log.debug("refresh_status: #{ip} status=#{@status}") #if all sev are identical, set general sev as sev if @avail_sev == @snmp_sev and @snmp_sev == @custom_sev and @custom_sev == @trap_sev and @trap_sev == @service_sev and @service_sev == @wmi_sev and @wmi_sev == @syslog_sev and @syslog_sev == @jmx_sev change_status(@snmp_sev) if @snmp_sev == UNMANAGED and self.node_view self.node_view.reset_notification() self.node_view.update_notification_icon() end return end #reinit specific sev if needed if !$config.port_mon and (@service_sev != UNMANAGED) @service_sev = UNMANAGED end if !$config.snmp_mon and (@snmp_sev != UNMANAGED) @snmp_sev = UNMANAGED end if !$config.custom_mon and (@custom_sev != UNMANAGED) @custom_sev = UNMANAGED end if !$config.snmptrap_mon and (@trap_sev != UNMANAGED) @trap_sev = UNMANAGED end if !$config.syslog_mon and (@syslog_sev != UNMANAGED) @syslog_sev = UNMANAGED end if !$config.wmi_mon and (@wmi_sev != UNMANAGED) @wmi_sev = UNMANAGED end if !$config.jmx_mon and (@jmx_sev != UNMANAGED) @jmx_sev = UNMANAGED end if $config.port_mon and (@service_sev == UNMANAGED) @service_sev = UNKNOWN end if $config.snmp_mon and (@snmp_sev == UNMANAGED) @snmp_sev = UNKNOWN end if $config.custom_mon and (@custom_sev == UNMANAGED) @custom_sev = UNKNOWN end if $config.snmptrap_mon and (@trap_sev == UNMANAGED) @trap_sev = UNKNOWN end if $config.syslog_mon and (@syslog_sev == UNMANAGED) @syslog_sev = UNKNOWN end if $config.wmi_mon and (@wmi_sev == UNMANAGED) @wmi_sev = UNKNOWN end if $config.jmx_mon and (@jmx_sev == UNMANAGED) @jmx_sev = UNKNOWN end #if at least one is critical set global sev to critical if ((@avail_sev == CRITICAL) and (@snmp_sev <= UNMANAGED) and (@custom_sev <= UNMANAGED) and (@trap_sev <= UNMANAGED) and (@service_sev <= UNMANAGED) and (@wmi_sev <= UNMANAGED) and (@syslog_sev <= UNMANAGED) and (@jmx_sev <= UNMANAGED)) || (@snmp_sev == CRITICAL) || (@custom_sev == CRITICAL) || (@trap_sev == CRITICAL) || (@service_sev == CRITICAL) || (@jmx_sev == CRITICAL) || (@syslog_sev == CRITICAL) || (@wmi_sev == CRITICAL) change_status(CRITICAL) else if ((@avail_sev > UNMANAGED) and (@snmp_sev <= UNMANAGED) and (@custom_sev <= UNMANAGED) and (@trap_sev <= UNMANAGED) and (@service_sev <= UNMANAGED) and (@wmi_sev <= UNMANAGED) and (@syslog_sev <= UNMANAGED) and (@jmx_sev <= UNMANAGED)) change_status(@avail_sev) else #we have to dont care about UNMANAGED and UNKNOWN value cpt=0 if @snmp_sev > UNMANAGED cpt+=1 end if @custom_sev > UNMANAGED cpt+=1 end if @trap_sev > UNMANAGED cpt+=1 end if @service_sev > UNMANAGED cpt+=1 end if @wmi_sev > UNMANAGED cpt+=1 end if @syslog_sev > UNMANAGED cpt+=1 end if @jmx_sev > UNMANAGED cpt+=1 end if cpt > 0 val=( (((@service_sev>UNMANAGED) and $config.port_mon)?@service_sev:UNMANAGED) + (((@snmp_sev>UNMANAGED) and $config.snmp_mon)?@snmp_sev:UNMANAGED) + (((@wmi_sev>UNMANAGED) and $config.wmi_mon)?@wmi_sev:UNMANAGED) + (((@jmx_sev>UNMANAGED) and $config.jmx_mon)?@jmx_sev:UNMANAGED) + (((@custom_sev>UNMANAGED) and $config.custom_mon)?@custom_sev:UNMANAGED) + (((@trap_sev>UNMANAGED) and $config.snmptrap_mon)?@trap_sev:UNMANAGED) + (((@syslog_sev>UNMANAGED) and $config.syslog_mon)?@syslog_sev:UNMANAGED) )/cpt #print "cpt: ",cpt, " val ",val.floor(),"\n" if val.floor() <= UNMANAGED $log.fatal("refresh_status: fail to compute status") else change_status(val.floor()) end end end end end |
#service_by_name(name) ⇒ Object
return service instance based on the service name as a key
545 546 547 548 549 550 551 552 |
# File 'lib/node.rb', line 545 def service_by_name(name) @service.each_value {|serv| if serv.name == name return serv end } return nil end |
#service_key(protocol, port) ⇒ Object
540 541 542 |
# File 'lib/node.rb', line 540 def service_key(protocol, port) return "#{protocol}/#{port}" end |
#set_account_login(id, value) ⇒ Object
set the account login specify by id
960 961 962 |
# File 'lib/node.rb', line 960 def set_account_login(id, value) @account[id][0]=value end |
#set_account_password(id, value) ⇒ Object
set the account password specify by id
974 975 976 |
# File 'lib/node.rb', line 974 def set_account_password(id, value) @account[id][1]=value end |
#set_all_account(haccount) ⇒ Object
set the accounts hash
920 921 922 |
# File 'lib/node.rb', line 920 def set_all_account(haccount) @account=haccount.dup end |
#set_all_interface(intf) ⇒ Object
set the interface hash
927 928 929 |
# File 'lib/node.rb', line 927 def set_all_interface(intf) @interface=intf.dup end |
#set_all_severity(sev) ⇒ Object
510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/node.rb', line 510 def set_all_severity(sev) @avail_sev=sev @snmp_sev=sev @custom_sev=sev @trap_sev=sev @service_sev=sev @wmi_sev=sev @syslog_sev=sev @jmx_sev=sev refresh_status() end |
#set_avail_severity(sev) ⇒ Object
467 468 469 470 |
# File 'lib/node.rb', line 467 def set_avail_severity(sev) @avail_sev=sev refresh_status() end |
#set_custom_severity(sev) ⇒ Object
499 500 501 502 |
# File 'lib/node.rb', line 499 def set_custom_severity(sev) @custom_sev=sev refresh_status() end |
#set_inherit_conf(bool) ⇒ Object
18 19 20 |
# File 'lib/node.rb', line 18 def set_inherit_conf(bool) @inherit_from_global=bool end |
#set_jmx_severity(sev) ⇒ Object
482 483 484 485 |
# File 'lib/node.rb', line 482 def set_jmx_severity(sev) @jmx_sev=sev refresh_status() end |
#set_label_visibility ⇒ Object
433 434 435 436 437 438 439 440 441 |
# File 'lib/node.rb', line 433 def set_label_visibility() if !$config.show_label hide_label() return false else show_label() return true end end |
#set_map(map) ⇒ Object
set map for changing map of a node
760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/node.rb', line 760 def set_map(map) if map != @map if self.class == Host $network[@map].del_host(ip) $network[@map].update_status() @map=map $network[@map].add_host(self) $network[@map].update_status() @node_view.reparent($network[@map].map_view) else $network[@map].del_net(ip) $network[@map].update_status() @map=map $network[@map].add_network(self) $network[@map].update_status() @node_view.reparent($network[@map].map_view) end end end |
#set_service_severity(sev) ⇒ Object
472 473 474 475 |
# File 'lib/node.rb', line 472 def set_service_severity(sev) @service_sev=sev refresh_status() end |
#set_severity(event_type, sev) ⇒ Object
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/node.rb', line 443 def set_severity(event_type, sev) case event_type when EventWindow::PORT_EVENT_TYPE set_service_severity(sev) when EventWindow::TRAP_EVENT_TYPE set_trap_severity(sev) when EventWindow::CUSTOM_EVENT_TYPE set_custom_severity(sev) when EventWindow::SNMP_EVENT_TYPE set_snmp_severity(sev) when EventWindow::WMI_EVENT_TYPE set_wmi_severity(sev) when EventWindow::SYSLOG_EVENT_TYPE set_syslog_severity(sev) when EventWindow::JMX_EVENT_TYPE set_jmx_severity(sev) when EventWindow::AVAIL_EVENT_TYPE set_avail_severity(sev) when EventWindow::CORE_EVENT_TYPE else $log.error("unknown event type: #{event_type}") end end |
#set_snmp_conf(rcommunity, wcommunity, version, port, timeout, snmpretry, saveindb_flag = 0) ⇒ Object
each time global conf is changed we have to modify the root node config
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/node.rb', line 25 def set_snmp_conf(rcommunity, wcommunity, version, port, timeout, snmpretry, saveindb_flag=0) if account_exist_nr?("snmp") self.set_account_login("snmp", rcommunity) self.set_account_password("snmp", wcommunity) end @snmp_version=version @snmp_port=port @snmp_timeout=timeout @snmp_retry=snmpretry if saveindb_flag nodeid=db_get_node_id(@ip,NETWORKNODE) db_set_snmp_parameter(nodeid, version, port, timeout, snmpretry) end end |
#set_snmp_severity(sev) ⇒ Object
sev is an index $status_value
494 495 496 497 |
# File 'lib/node.rb', line 494 def set_snmp_severity(sev) @snmp_sev=sev refresh_status() end |
#set_syslog_severity(sev) ⇒ Object
487 488 489 490 |
# File 'lib/node.rb', line 487 def set_syslog_severity(sev) @syslog_sev=sev refresh_status() end |
#set_trap_severity(sev) ⇒ Object
use for snmp trap and syslog msgs
505 506 507 508 |
# File 'lib/node.rb', line 505 def set_trap_severity(sev) @trap_sev=sev refresh_status() end |
#set_wmi_severity(sev) ⇒ Object
477 478 479 480 |
# File 'lib/node.rb', line 477 def set_wmi_severity(sev) @wmi_sev=sev refresh_status() end |
#show_label ⇒ Object
429 430 431 |
# File 'lib/node.rb', line 429 def show_label() @node_view.show_text() unless !@node_view end |