gnms 2.1.0.rc2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gnms might be problematic. Click here for more details.

@@ -121,23 +121,23 @@ def show_menu()
121
121
  @main_vbox.reorder_child(@main_bar,0)
122
122
  end
123
123
 
124
- def check_update()
124
+ def check_update()
125
125
  check_update_window()
126
- end
126
+ end
127
127
 
128
- def set_display_view_menu()
128
+ def set_display_view_menu()
129
129
  @ag.get_action("User defined").activate
130
- end
130
+ end
131
131
 
132
- def get_size_changed_from_menu()
132
+ def get_size_changed_from_menu()
133
133
  return @size_changed_from_menu
134
- end
134
+ end
135
135
 
136
- def set_size_changed_from_menu(b)
136
+ def set_size_changed_from_menu(b)
137
137
  @size_changed_from_menu=b
138
- end
138
+ end
139
139
 
140
- def initialize(title)
140
+ def initialize(title)
141
141
 
142
142
  super(title)
143
143
  @size_changed_from_menu=false
@@ -297,8 +297,9 @@ main_menu = %Q[
297
297
  <menuitem action='Add host range'/>
298
298
  <menuitem action='Add network'/>
299
299
  </menu>
300
- <separator/>
301
300
  <menuitem action='Del node'/>
301
+ <separator/>
302
+ <menuitem action='Unwanted node'/>
302
303
  </menu>
303
304
  <menu action='OptionMenu'>
304
305
  <menuitem action='Preference'/>
@@ -357,6 +358,7 @@ main_menu = %Q[
357
358
  ["Add host range", nil, "Host range", nil, "", proc { add_host_range }],
358
359
  ["Add network", nil, "Network", nil, "", proc { addnetworkwin }],
359
360
  ["Del node", Gtk::Stock::REMOVE, "Del node", nil, "", proc { delnodewin }],
361
+ ["Unwanted node", Gtk::Stock::PREFERENCES, "Unwanted node", nil, "", proc { unwantednodewin }],
360
362
  ["OptionMenu", nil, "Option"],
361
363
  ["Preference", Gtk::Stock::PREFERENCES, "Preference", nil, "", proc { create_config_option } ],
362
364
  ["EventConfMenu", nil, "Monitoring conf"],
@@ -61,7 +61,7 @@ def save_config_yaml()
61
61
  }
62
62
 
63
63
  scan = {
64
- 'broadcast_ping' => {
64
+ 'find_node' => {
65
65
  'state' => @button_bp.active?,
66
66
  'delay' => @entry_delay_bp.text.to_i,
67
67
  },
@@ -380,7 +380,7 @@ notebook.show
380
380
  @button_noshow_fqdn = Gtk::CheckButton.new "Display hostname instead of FQDN"
381
381
  @button_noshow_fqdn.set_size_request 10,-1
382
382
  @button_noshow_fqdn.set_active @config.noshow_fqdn && @button_show_label.active?
383
- @button_noshow_fqdn.set_sensitive @config.noshow_fqdn && @button_show_label.active?
383
+ @button_noshow_fqdn.set_sensitive @button_show_label.active?
384
384
  @button_noshow_fqdn.show
385
385
  table.attach(@button_noshow_fqdn,0,1,2,3)
386
386
 
@@ -1028,18 +1028,18 @@ end
1028
1028
  frame.add table
1029
1029
 
1030
1030
  #find hosts using broadcast ping, and if possible arp+lldp sniffing
1031
- @button_bp = Gtk::CheckButton.new "Find hosts in local segment delay (in s)"
1031
+ @button_bp = Gtk::CheckButton.new "Find new nodes delay (in s)"
1032
1032
  @button_bp.set_size_request 10,-1
1033
- @button_bp.set_active @config.broadcast_ping_state
1033
+ @button_bp.set_active @config.find_node_state
1034
1034
  @button_bp.show
1035
1035
 
1036
1036
  @entry_delay_bp = Gtk::Entry.new
1037
1037
  @entry_delay_bp.show
1038
1038
  @entry_delay_bp.set_size_request 5,-1
1039
- if @config.broadcast_ping_delay == "" || @config.broadcast_ping_delay == nil
1039
+ if @config.find_node_delay == "" || @config.find_node_delay == nil
1040
1040
  @entry_delay_bp.set_text "300"
1041
1041
  else
1042
- @entry_delay_bp.set_text @config.broadcast_ping_delay.to_s
1042
+ @entry_delay_bp.set_text @config.find_node_delay.to_s
1043
1043
  end
1044
1044
  @entry_delay_bp.set_sensitive @button_bp.active?
1045
1045
 
@@ -1151,14 +1151,6 @@ end
1151
1151
  end
1152
1152
  @entry_delay_pm.set_sensitive @button_pm.active?
1153
1153
 
1154
- if ENV["USER"] != "root"
1155
- @button_pm.set_active false
1156
- @button_pm.set_sensitive false
1157
- @entry_delay_pm.set_sensitive false
1158
- else
1159
- @entry_delay_pm.set_sensitive @button_pm.active?
1160
- end
1161
-
1162
1154
  @button_pm.signal_connect("toggled") {
1163
1155
  @entry_delay_pm.set_sensitive @button_pm.active?
1164
1156
  }
@@ -1842,7 +1834,7 @@ button.signal_connect("clicked") do
1842
1834
  old_wmi_mon=@config.wmi_mon
1843
1835
  old_jmx_mon=@config.jmx_mon
1844
1836
  old_custom_mon=@config.custom_mon
1845
- old_ping_state=@config.broadcast_ping_state
1837
+ old_ping_state=@config.find_node_state
1846
1838
  old_mac_state=@config.mac_state
1847
1839
  old_node_resolving=@config.node_resolving
1848
1840
  old_syslog_mon=@config.syslog_mon
@@ -1963,10 +1955,12 @@ button.signal_connect("clicked") do
1963
1955
  add_monitoring_thread("Resolve ip to name",tresolvip())
1964
1956
  add_monitoring_thread("Resolve ip to netbios",tresolvnetbiosname())
1965
1957
  add_monitoring_thread("Find os",tresolvos())
1958
+ add_monitoring_thread("Find snmp",tresolvsnmp())
1966
1959
  else
1967
1960
  del_monitoring_thread("Resolve ip to name")
1968
1961
  del_monitoring_thread("Resolve ip to netbios")
1969
1962
  del_monitoring_thread("Find os")
1963
+ del_monitoring_thread("Find snmp")
1970
1964
  end
1971
1965
  end
1972
1966
 
@@ -30,12 +30,12 @@ def help_window
30
30
  scrolled_window.add(text)
31
31
 
32
32
  text.grab_focus
33
-
34
- if FileTest.exist?"README"
35
- fic = File.new("README",'r')
33
+ readme_file = "#{GNMSLIB}/../README"
34
+ if FileTest.exist?(readme_file)
35
+ fic = File.new(readme_file,'r')
36
36
  tlign = fic.readlines
37
37
  fic.close
38
- text.buffer.insert_at_cursor(tlign.to_s)
38
+ text.buffer.insert_at_cursor(tlign.join)
39
39
  else
40
40
  text.buffer.insert_at_cursor("Error: Could not find README file")
41
41
  end
@@ -56,7 +56,7 @@ def netmask_calculator
56
56
  hbox = Gtk::HBox.new
57
57
  hbox.show
58
58
  entry_netmask = Gtk::Entry.new
59
- entry_netmask.set_text "255.255.255.0"
59
+ entry_netmask.set_text DEFAULT_CLASS_C_NETMASK
60
60
  entry_netmask.set_editable false
61
61
  entry_netmask.show
62
62
 
@@ -1359,9 +1359,9 @@ end
1359
1359
 
1360
1360
  def fill_port_list(node)
1361
1361
 
1362
- #we need to append all monitored ports of service hash
1363
- #@scanned_port_list is ordered as udp first and port number ...
1364
- if node.service != nil
1362
+ #we need to append all monitored ports of service hash
1363
+ #@scanned_port_list is ordered as udp first and port number ...
1364
+ if node.service != nil
1365
1365
  if @scanned_port_list == nil
1366
1366
  @scanned_port_list=[]
1367
1367
  node.service.sort{|s1,s2| s1[0].split('/')[1].to_i()<=>s2[0].split('/')[1].to_i()}.each {|w,serv|
@@ -2573,7 +2573,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
2573
2573
  iter[0] = fixed
2574
2574
  end
2575
2575
 
2576
- column1 = Gtk::TreeViewColumn.new("Selected",
2576
+ column1 = Gtk::TreeViewColumn.new("Enabled",
2577
2577
  renderer, {:active => 0})
2578
2578
  column1.set_clickable(true)
2579
2579
  column2 = Gtk::TreeViewColumn.new("Protocol",
@@ -2662,6 +2662,11 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
2662
2662
  item_edit_serv.set_sensitive(true)
2663
2663
  item_del_serv.set_sensitive(true)
2664
2664
  end
2665
+ if $config.nmap_vers.to_f() == 0.0
2666
+ scan_port_serv.set_sensitive(false)
2667
+ else
2668
+ scan_port_serv.set_sensitive(true)
2669
+ end
2665
2670
  menu_port.popup(nil, nil, event.button, event.time)
2666
2671
  elsif (@treeview.selection.selected!=nil) && (event.event_type == Gdk::Event::BUTTON2_PRESS)
2667
2672
  edit_monitored_service()
@@ -2717,7 +2722,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
2717
2722
  frame.set_label("No SNMP OID defined, go in Tools menu")
2718
2723
  end
2719
2724
 
2720
- column1 = Gtk::TreeViewColumn.new("Selected",
2725
+ column1 = Gtk::TreeViewColumn.new("Enabled",
2721
2726
  renderer_snmp, {:active => 0})
2722
2727
  column1.set_clickable(true)
2723
2728
  column2 = Gtk::TreeViewColumn.new("OID label",
@@ -2850,7 +2855,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
2850
2855
  frame.set_label("No WMI request defined, go in Tools menu")
2851
2856
  end
2852
2857
 
2853
- column1 = Gtk::TreeViewColumn.new("Selected",
2858
+ column1 = Gtk::TreeViewColumn.new("Enabled",
2854
2859
  renderer_wmi, {:active => 0})
2855
2860
  column1.set_clickable(true)
2856
2861
  column2 = Gtk::TreeViewColumn.new("WMI label",
@@ -2984,7 +2989,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
2984
2989
  frame.set_label("No jmx request defined, go in Tools menu")
2985
2990
  end
2986
2991
 
2987
- column1 = Gtk::TreeViewColumn.new("Selected",
2992
+ column1 = Gtk::TreeViewColumn.new("Enabled",
2988
2993
  renderer_jmx, {:active => 0})
2989
2994
  column1.set_clickable(true)
2990
2995
  column2 = Gtk::TreeViewColumn.new("Label",
@@ -3098,7 +3103,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
3098
3103
  frame.set_label("This monitoring is disabled")
3099
3104
  end
3100
3105
 
3101
- column1 = Gtk::TreeViewColumn.new("Selected",
3106
+ column1 = Gtk::TreeViewColumn.new("Enabled",
3102
3107
  renderer_snmp, {:active => 0})
3103
3108
  column1.set_clickable(true)
3104
3109
  column2 = Gtk::TreeViewColumn.new("Trap label",
@@ -3217,7 +3222,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
3217
3222
  frame.set_label("This monitoring is disabled")
3218
3223
  end
3219
3224
 
3220
- column1 = Gtk::TreeViewColumn.new("Selected",
3225
+ column1 = Gtk::TreeViewColumn.new("Enabled",
3221
3226
  renderer_syslog, {:active => 0})
3222
3227
  column1.set_clickable(true)
3223
3228
  column2 = Gtk::TreeViewColumn.new("Syslog label",
@@ -3349,7 +3354,7 @@ eval IO.read("#{GNMSLIB}"+'/gui/sub/account_frame.rb')
3349
3354
  iter[0] = fixed
3350
3355
  end
3351
3356
 
3352
- column1 = Gtk::TreeViewColumn.new("Selected",
3357
+ column1 = Gtk::TreeViewColumn.new("Enabled",
3353
3358
  renderer, {:active => 0})
3354
3359
  column1.set_clickable(true)
3355
3360
  column2 = Gtk::TreeViewColumn.new("Name",
@@ -39,7 +39,10 @@ def check_update_window
39
39
  vbox.show
40
40
  window.add vbox
41
41
 
42
- Net::HTTP.version_1_1
42
+ begin
43
+ Net::HTTP.version_1_1
44
+ rescue
45
+ end
43
46
  last_version=""
44
47
  text = Gtk::TextView.new
45
48
  combo_last_version = Gtk::ComboBox.new
@@ -88,6 +88,35 @@ end
88
88
  # Main Event Window
89
89
  ################################################################################
90
90
 
91
+ #
92
+ # add node definition to exception list
93
+ # it could be an ip or a regex
94
+ #
95
+ def add_node_def_exception_list(str)
96
+ if !$node_exception_list.include?(str)
97
+ $node_exception_list.push(str)
98
+ end
99
+ end
100
+
101
+ #
102
+ # del node definition from exception list
103
+ #
104
+ def del_node_def_exception_list(str)
105
+ $node_exception_list.delete(str)
106
+ end
107
+
108
+ #
109
+ # check if node definition is
110
+ # matched by an entry from in_exception_list
111
+ #
112
+ def in_exception_list(str)
113
+ $node_exception_list.each {|str_lign|
114
+ if str_lign.match(str)
115
+ return true
116
+ end
117
+ } unless $node_exception_list == nil
118
+ return false
119
+ end
91
120
 
92
121
  #
93
122
  # return a version 4 UUID
@@ -104,6 +133,9 @@ def create_uuid()
104
133
  end
105
134
  end
106
135
 
136
+ #
137
+ # encode the given str using blowfish crypto algo
138
+ #
107
139
  def blowfish_encode(str)
108
140
  begin
109
141
  blowfish = Crypt::Blowfish.new(GNMSPPH)
@@ -114,6 +146,9 @@ def blowfish_encode(str)
114
146
  return ""
115
147
  end
116
148
 
149
+ #
150
+ # decode the given str using blowfish crypto algo
151
+ #
117
152
  def blowfish_decode(str)
118
153
  begin
119
154
  blowfish = Crypt::Blowfish.new(GNMSPPH)
@@ -135,6 +170,9 @@ def get_snmp_version(str)
135
170
  end
136
171
  end
137
172
 
173
+ #
174
+ # return a color based on the node sev status
175
+ #
138
176
  def get_color_from_status(status)
139
177
  case status
140
178
  when "CRITICAL"
@@ -157,6 +195,7 @@ end
157
195
  #
158
196
  # convert status to level
159
197
  # can return a level or '' if not convert or "UNKNOWN", "UNMANAGED" if "UNMANAGED"
198
+ #
160
199
  def get_level_from_status(status)
161
200
  case status
162
201
  when "UNMANAGED"
@@ -176,6 +215,9 @@ def get_level_from_status(status)
176
215
  end
177
216
  end
178
217
 
218
+ #
219
+ # map syslog level to node status
220
+ #
179
221
  def get_status_from_level(level)
180
222
  case level
181
223
  when "UNMANAGED"
@@ -195,11 +237,16 @@ def get_status_from_level(level)
195
237
  end
196
238
  end
197
239
 
198
-
240
+ #
241
+ # check if corresponding str name exists as a thread
242
+ #
199
243
  def exist_monitoring_thread(str)
200
244
  return $thread_list[str] != nil
201
245
  end
202
246
 
247
+ #
248
+ # add a thread identified by a corresponding str name
249
+ #
203
250
  def add_monitoring_thread(str, thr)
204
251
  $log.debug("Starting thread #{str}")
205
252
  if thr
@@ -268,6 +315,9 @@ def fill_ip_str(ip)
268
315
  return ip_tmp
269
316
  end
270
317
 
318
+ #
319
+ # return window map width or default value
320
+ #
271
321
  def get_map_width()
272
322
  if $win and $win.window != nil
273
323
  return $win.window.geometry[2]
@@ -276,6 +326,9 @@ def get_map_width()
276
326
  end
277
327
  end
278
328
 
329
+ #
330
+ # return window map height or default value
331
+ #
279
332
  def get_map_height()
280
333
  if $win and $win.window != nil
281
334
  return $win.window.geometry[3]
@@ -284,6 +337,9 @@ def get_map_height()
284
337
  end
285
338
  end
286
339
 
340
+ #
341
+ # return screen width
342
+ #
287
343
  def get_default_map_width()
288
344
  if $config.default_width == nil || $config.default_width == ""
289
345
  return Gdk::screen_width/2
@@ -292,6 +348,9 @@ def get_default_map_width()
292
348
  end
293
349
  end
294
350
 
351
+ #
352
+ # return screen height
353
+ #
295
354
  def get_default_map_height()
296
355
  if $config.default_height == nil || $config.default_height == ""
297
356
  return Gdk::screen_height/2
@@ -300,6 +359,9 @@ def get_default_map_height()
300
359
  end
301
360
  end
302
361
 
362
+ #
363
+ # delete selected node(s)
364
+ #
303
365
  def del_selected_node()
304
366
  mapp=get_map()
305
367
  if $map != nil
@@ -719,7 +781,7 @@ def set_map(mp=nil)
719
781
 
720
782
  opts = OptionParser.new
721
783
  opts.on("-f=ARG", "--file filename",String,"Load xml node filename") {|val| file_to_load=val }
722
- opts.on("-d=ARG", "--debug level",Integer,"Set debug level to default output") {|val| debuglevel=val }
784
+ opts.on("-d=ARG", "--debug level",Integer,"Set debug output level (0 is the most verbose)") {|val| debuglevel=val }
723
785
  opts.on("-t=ARG", "--test scenario",String,"Load and execute scenario from test/ dir") {|val| testunitfile=val
724
786
  $testunit=true
725
787
  }
@@ -935,6 +997,9 @@ def set_map(mp=nil)
935
997
  $event_win.add_event(EventWindow::CORE_EVENT_TYPE,"INFO",$host["127.0.0.1"], "GNMS launch")
936
998
  end
937
999
 
1000
+ #node we don't want to see
1001
+ $node_exception_list = Array.new
1002
+
938
1003
  #rescue Exception => msg
939
1004
  # puts "-"*80
940
1005
  # $log.fatal("Please report this error: #{msg}\n#{msg.backtrace.join("\n")}")
@@ -966,7 +1031,7 @@ def set_map(mp=nil)
966
1031
  #thread to listen to monitored jmx cmd
967
1032
  add_monitoring_thread("JMX monitoring", tmonitorjmx())
968
1033
  end
969
- if $config.broadcast_ping_state
1034
+ if $config.find_node_state
970
1035
  #thread to find new host in local network with broacast ping
971
1036
  add_monitoring_thread("Local ping", t_find_local_segment_pinging())
972
1037
  #thread to find new host in local segment sniffing for arp/lldp/dhcp packets
@@ -985,6 +1050,8 @@ def set_map(mp=nil)
985
1050
  add_monitoring_thread("Resolve ip to netbios", tresolvnetbiosname())
986
1051
  #thread to find os with fingerprinting
987
1052
  add_monitoring_thread("Find os", tresolvos())
1053
+ #thread to find nodes with snmp
1054
+ add_monitoring_thread("Find snmp", tresolvesnmp())
988
1055
  end
989
1056
 
990
1057
  if $config.auto_save_map
@@ -22,13 +22,16 @@ def get_snmp_OID(node, oid)
22
22
  end
23
23
 
24
24
  begin
25
- print "get_snmp_OID: ", node.ip, " ", community_read, " ", community_write, " ", get_snmp_version(version), " ", port.to_i, " ", timeout.to_i, " ", retr.to_i,"\n"
25
+ #print "get_snmp_OID: ", node.ip, " ", community_read, " ", community_write, " ", get_snmp_version(version), " ", port.to_i, " ", timeout.to_i, " ", retr.to_i,"\n"
26
26
  SNMP::Manager.open(:Host => node.ip, :Community => community_read, :WriteCommunity => community_write, :Version => get_snmp_version(version), :Port => port.to_i, :Timeout => timeout.to_i, :Retries => retr.to_i) do |manager|
27
27
  response = manager.get(oid)
28
28
  response.each_varbind do |vb|
29
29
  return vb.value.to_s
30
30
  end
31
31
  end
32
+ rescue SNMP::RequestTimeout
33
+ $log.debug("Error in get_snmp_OID: #{node.ip} not responding")
34
+ return "Error"
32
35
  rescue Exception => msg
33
36
  $log.error("Error in get_snmp_OID: #{msg}")
34
37
  return "Error"
@@ -60,6 +63,9 @@ def walk_snmp_OID(node, oid)
60
63
  }
61
64
  return resultt
62
65
  end
66
+ rescue SNMP::RequestTimeout
67
+ $log.debug("Error in get_snmp_OID: #{node.ip} not responding")
68
+ return "Error"
63
69
  rescue Exception => msg
64
70
  $log.error("Error in get_snmp_OID: #{msg}")
65
71
  return "Error"