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.

@@ -33,8 +33,8 @@ end
33
33
 
34
34
  Gem::Specification.new do |s|
35
35
  s.name = "gnms"
36
- #s.version = GNMSVERSION
37
- s.version = "#{GNMSVERSION}.rc2"
36
+ s.version = GNMSVERSION
37
+ #s.version = "#{GNMSVERSION}.rc2"
38
38
  s.platform = Gem::Platform::RUBY
39
39
  s.required_ruby_version = '>= 1.8.6'
40
40
  s.authors = ["David Maciejak"]
@@ -54,14 +54,14 @@ Gem::Specification.new do |s|
54
54
 
55
55
  s.add_dependency("facter")
56
56
  s.add_dependency("goocanvas")
57
- s.add_dependency("gdk_pixbuf2", "~> 1.1.7")
58
- s.add_dependency("glib2", "~> 1.1.7")
59
- s.add_dependency("gtk2", "~> 1.1.7")
57
+ s.add_dependency("gdk_pixbuf2", ">= 1.1.7")
58
+ s.add_dependency("glib2", ">= 1.1.7")
59
+ s.add_dependency("gtk2", ">= 1.1.7")
60
60
  s.add_dependency("net-ssh")
61
61
  s.add_dependency("snmp")
62
62
  s.add_dependency("xmpp4r")
63
63
  s.add_dependency("sqlite3")
64
- s.add_dependency("pcaprub", "~>0.11.3")
64
+ s.add_dependency("pcaprub", ">= 0.11.3")
65
65
  s.add_dependency("packetfu")
66
66
  s.add_dependency("gruff")
67
67
  # s.add_dependency("ruby-ldap")
@@ -148,14 +148,12 @@ def listport(ip)
148
148
  if nmap_version >= 6.0
149
149
  lp=`#{$config.nmap_path} -sU -sT #{ip} --host_timeout 60 2>/dev/null| grep open | grep "^[0-9]"`
150
150
  else
151
- lp=`#{$config.nmap_path} -sU -sT #{ip} --host_timeout 60000 2>/dev/null| grep open | grep "^[0-9]"`
151
+ if nmap_version > 0.0
152
+ lp=`#{$config.nmap_path} -sU -sT #{ip} --host_timeout 60000 2>/dev/null| grep open | grep "^[0-9]"`
153
+ end
152
154
  end
153
- $_=lp
154
- gsub("/"," ")
155
- gsub("open","")
156
- gsub("|filtered","")
157
- gsub("\ +"," ")
158
- return $_
155
+ result = lp.gsub("/"," ").gsub("open","").gsub("|filtered","").gsub("\ +"," ")
156
+ return result
159
157
  end
160
158
 
161
159
  #
@@ -282,68 +280,66 @@ end
282
280
  # verify if oid ref threshold value is ok
283
281
  #
284
282
  def test_monitored_snmp(ip)
285
- $log.info "cmd_parse test_monitored_snmp #{ip}"
286
- if $host[ip] && ($host[ip].snmp_monitoring.size() > 0)
287
- max_severity=UNKNOWN
288
-
289
- if $host[ip].get_account_id("snmp")
290
- community_pub, community_priv = $host[ip].get_account_id("snmp")
291
- begin
283
+ if $host[ip] && ($host[ip].snmp_monitoring.size() > 0)
284
+ max_severity = UNKNOWN
292
285
 
293
- SNMP::Manager.open(:Host => ip, :Community => community_pub, :Version => get_snmp_version($host[ip].get_default_inherit_snmp_version()), :Port => $host[ip].get_default_inherit_snmp_port().to_i, :Timeout => $host[ip].get_default_inherit_snmp_timeout().to_i, :Retries => $host[ip].get_default_inherit_snmp_retry().to_i) do |manager|
294
- $host[ip].snmp_monitoring.each_value {|snmp_mon|
295
- if snmp_mon.active?()
296
- snmp_oper="#{snmp_mon.oper()}"
297
- if "#{snmp_mon.oper()}" == "="
298
- snmp_oper="=="
299
- end
300
- begin
301
-
302
- snmp_direct_value="#{snmp_mon.value(manager,$host[ip])}"
303
- #here snmp_direct_value can be a string and not an operation
304
- #check if a OID value in not known by the agent
305
- if !snmp_direct_value.include?("Null")
306
- expr_test=""
307
- if snmp_direct_value.match('^[\d.+*/ -]+$')
308
- expr_test="#{snmp_direct_value} #{snmp_oper} #{snmp_mon.threshold}"
309
- else
310
- expr_test="'#{snmp_direct_value}' #{snmp_oper} '#{snmp_mon.threshold}'"
311
- end
312
- if eval(expr_test)
313
- if $status_value[snmp_mon.raw_severity] > max_severity
314
- max_severity=$status_value[snmp_mon.raw_severity]
315
- end
316
- $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, get_level_from_status($status[$status_value.index(max_severity)]), $host[ip], "Monitoring #{snmp_mon.oidref} matched")
317
- end
318
- else
319
- $log.error("Problem in SNMP request on #{ip}, seems OID used is unknown on remote agent")
320
- $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, "ERR", $host[ip], "OID #{snmp_mon.oidref} used is unknown on remote agent")
321
- end
322
- rescue
323
- $log.error("Problem in SNMP request on #{ip}, validate #{snmp_mon.oidref} OID Reference")
324
- $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, "ERR", $host[ip], "Problem validate #{snmp_mon.oidref} OID Reference")
325
- return
326
- end
327
- end
328
- }
329
- #set the snmp severity to max find for this host
330
- if max_severity > $host[ip].snmp_sev
331
- $host[ip].set_snmp_severity(max_severity)
332
- end
333
-
334
- end #manager
335
- rescue Exception => msg
336
- $log.error("Exception in test_monitored_snmp for #{ip}: #{msg}")
337
- end
338
- else
339
- $log.error("snmp account not set for host #{ip}")
340
- $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, "ERR", $host[ip], "snmp account not set")
341
- end
342
- else
343
- if $host[ip]
344
- $host[ip].set_snmp_severity(UNMANAGED)
345
- end
346
- end
286
+ community_pub = $config.read_community
287
+ community_priv = $config.write_community
288
+ if $host[ip].get_account_id("snmp")
289
+ community_pub, community_priv = $host[ip].get_account_id("snmp")
290
+ end
291
+ begin
292
+ SNMP::Manager.open(:Host => ip, :Community => community_pub, :Version => get_snmp_version($host[ip].get_default_inherit_snmp_version()), :Port => $host[ip].get_default_inherit_snmp_port().to_i, :Timeout => $host[ip].get_default_inherit_snmp_timeout().to_i, :Retries => $host[ip].get_default_inherit_snmp_retry().to_i) do |manager|
293
+ $host[ip].snmp_monitoring.each_value {|snmp_mon|
294
+ if snmp_mon.active?()
295
+ snmp_oper="#{snmp_mon.oper()}"
296
+ if "#{snmp_mon.oper()}" == "="
297
+ snmp_oper="=="
298
+ end
299
+ begin
300
+
301
+ snmp_direct_value="#{snmp_mon.value(manager,$host[ip])}"
302
+ #here snmp_direct_value can be a string and not an operation
303
+ #check if a OID value in not known by the agent
304
+ if !snmp_direct_value.include?("Null")
305
+ expr_test=""
306
+ if snmp_direct_value.match('^[\d.+*/ -]+$')
307
+ expr_test="#{snmp_direct_value} #{snmp_oper} #{snmp_mon.threshold}"
308
+ else
309
+ expr_test="'#{snmp_direct_value}' #{snmp_oper} '#{snmp_mon.threshold}'"
310
+ end
311
+ if eval(expr_test)
312
+ if $status_value[snmp_mon.raw_severity] > max_severity
313
+ max_severity=$status_value[snmp_mon.raw_severity]
314
+ end
315
+ $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, get_level_from_status($status[$status_value.index(max_severity)]), $host[ip], "Monitoring #{snmp_mon.oidref} matched")
316
+ end
317
+ else
318
+ $log.error("Problem in SNMP request on #{ip}, seems OID used is unknown on remote agent")
319
+ $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, "ERR", $host[ip], "OID #{snmp_mon.oidref} used is unknown on remote agent")
320
+ end
321
+ rescue
322
+ $log.error("Problem in SNMP request on #{ip}, validate #{snmp_mon.oidref} OID Reference")
323
+ $event_win.add_event(EventWindow::SNMP_EVENT_TYPE, "ERR", $host[ip], "Problem validate #{snmp_mon.oidref} OID Reference")
324
+ return
325
+ end
326
+ end
327
+ }
328
+ #set the snmp severity to max find for this host
329
+ if max_severity > $host[ip].snmp_sev
330
+ $host[ip].set_snmp_severity(max_severity)
331
+ end
332
+ end #manager
333
+ rescue SNMP::RequestTimeout
334
+ $log.debug("test_monitored_snmp: request timeout to #{ip} port: #{$host[ip].get_default_inherit_snmp_port().to_i} community: #{community_pub} snmp_version: #{get_snmp_version(node.get_default_inherit_snmp_version())}")
335
+ rescue Exception => msg
336
+ $log.error("Exception in test_monitored_snmp for #{ip}: #{msg}")
337
+ end
338
+ else
339
+ if $host[ip]
340
+ $host[ip].set_snmp_severity(UNMANAGED)
341
+ end
342
+ end
347
343
  end
348
344
 
349
345
  #
@@ -27,7 +27,7 @@ DEFAULT_SOUND_FILE = "Just beep"
27
27
  attr_reader :default_width, :default_height, :default_map, :show_label, :noshow_fqdn, :show_tooltips, :confirm_delete, :confirm_quit, :log_level
28
28
  attr_reader :read_community, :write_community, :snmp_version, :snmp_port, :snmp_timeout, :snmp_retry, :mail_server_addr, :mail_server_port, :sms_device, :im_login, :im_password, :irc_server, :irc_port, :irc_channel
29
29
  attr_accessor :level
30
- attr_reader :broadcast_ping_state, :broadcast_ping_delay, :mac_state, :mac_delay, :mac_lock, :mac_manufacturer, :syslog_mon, :syslog_port, :snmptrap_mon, :snmptrap_port, :snmptrap_community
30
+ attr_reader :find_node_state, :find_node_delay, :mac_state, :mac_delay, :mac_lock, :mac_manufacturer, :syslog_mon, :syslog_port, :snmptrap_mon, :snmptrap_port, :snmptrap_community
31
31
  attr_reader :node_resolving, :node_resolving_delay
32
32
  attr_reader :port_mon, :port_mon_delay, :snmp_mon, :snmp_mon_delay, :wmi_mon, :wmi_mon_delay, :custom_mon, :custom_mon_delay, :jmx_mon, :jmx_mon_delay
33
33
  attr_reader :ping_path, :nmap_path, :ssh_path, :telnet_path, :browser_path, :vncviewer_path, :rdesktop_path, :xterm_path, :nmblookup_path, :xprobe_path, :wmic_path
@@ -130,8 +130,8 @@ def read_config_yaml()
130
130
  @sms_num_by_level = db["notification"]["sms_num"]
131
131
  @im_dest_by_level = db["notification"]["im_dest"]
132
132
 
133
- @broadcast_ping_state = db["scan"]["broadcast_ping"]["state"]
134
- @broadcast_ping_delay = db["scan"]["broadcast_ping"]["delay"]
133
+ @find_node_state = db["scan"]["find_node"]["state"]
134
+ @find_node_delay = db["scan"]["find_node"]["delay"]
135
135
  @mac_state = db["scan"]["mac"]["state"]
136
136
  @mac_delay = db["scan"]["mac"]["delay"]
137
137
  @mac_lock = db["scan"]["mac"]["lock"]
@@ -233,9 +233,9 @@ notification = {
233
233
  }
234
234
 
235
235
  scan = {
236
- 'broadcast_ping' => {
237
- 'state' => @broadcast_ping_state,
238
- 'delay' => @broadcast_ping_delay.to_i,
236
+ 'find_node' => {
237
+ 'state' => @find_node_state,
238
+ 'delay' => @find_node_delay.to_i,
239
239
  },
240
240
  'mac' => {
241
241
  'state' => @mac_state,
@@ -385,7 +385,7 @@ def initialize ()
385
385
  @wmi_mon_delay = "60"
386
386
  @custom_mon_delay = "60"
387
387
  @jmx_mon_delay = "60"
388
- @broadcast_ping_delay = "300"
388
+ @find_node_delay = "300"
389
389
  @node_resolving = true
390
390
  @node_resolving_delay = "120"
391
391
  @mac_delay = "60"
@@ -60,6 +60,23 @@ def isValidPort(port)
60
60
  return false
61
61
  end
62
62
 
63
+ def isValidMac(mac)
64
+ if mac.nil?
65
+ return false
66
+ end
67
+ lmac = mac.split(/:/)
68
+ if lmac.size != 6
69
+ return false
70
+ end
71
+ lmac.each do |val|
72
+ val_dec = val.to_i(16)
73
+ if (val.length != 2) || (val_dec > 255 || val_dec < 0)
74
+ return false
75
+ end
76
+ end
77
+ return true
78
+ end
79
+
63
80
  #
64
81
  # return true if arg is an integer
65
82
  # need: an arg
@@ -38,6 +38,9 @@ PLUGIN_DIR = "#{GNMSLIB}/../plugins"
38
38
  ROOTMAPADDR="0.0.0.0"
39
39
  ROOTMAPNAME="ROOT"
40
40
 
41
+ NILMAC = "00:00:00:00:00:00"
42
+ DEFAULT_CLASS_C_NETMASK = "255.255.255.0"
43
+
41
44
  GNMS_PROJECT_SERVER="gnms.rubyforge.org"
42
45
  GNMS_PROJECT_URL=""
43
46
 
@@ -197,7 +200,7 @@ def verify_system_conf()
197
200
  $log.error("This tool needs at least GTK version 2.4")
198
201
  end
199
202
  else
200
- $log.error("This tool needs Ruby 1.8 or Ruby 1.9")
203
+ $log.error("This tool needs at least Ruby 1.8")
201
204
  end
202
205
  return 1
203
206
  end
@@ -223,9 +226,11 @@ end
223
226
 
224
227
  ####################################################################################
225
228
  #
226
- # go!
229
+ # let's rock!
227
230
  #
228
231
 
232
+ require "#{GNMSLIB}"+'/version'
233
+ require "#{GNMSLIB}"+'/main'
229
234
 
230
235
  #verify ruby/gtk/gnome conf
231
236
  unless verify_system_conf == 0
@@ -234,13 +239,7 @@ unless verify_system_conf == 0
234
239
  else
235
240
  $log.info("System configuration is ok")
236
241
 
237
-
238
- ##############################################################################
239
- #load other files
240
- require "#{GNMSLIB}"+'/version'
241
- require "#{GNMSLIB}"+'/main'
242
- ##############################################################################
243
-
242
+ $log.info("Running GNMS version #{GNMSVERSION}")
244
243
 
245
244
  Gtk::RC.parse_string <<EOS
246
245
 
@@ -2,7 +2,6 @@
2
2
  # here we can find Gtk::Window for add or del an host
3
3
  #
4
4
 
5
-
6
5
  #
7
6
  # window to ask in which map to add a node,
8
7
  # list networks in combobox
@@ -30,7 +29,8 @@ def choose_network_map(node_ip, default_map=nil)
30
29
  get_network().each { |n|
31
30
  entry_map.append_text(n)
32
31
  }
33
- entry_map.set_active(0)
32
+ entry_map.prepend_text("Exception list")
33
+ entry_map.set_active(1)
34
34
  if !default_map.nil? and !default_map.empty?
35
35
  ind = get_network().index(default_map)
36
36
  entry_map.set_active(ind) if ind
@@ -40,7 +40,7 @@ def choose_network_map(node_ip, default_map=nil)
40
40
  ok_button.signal_connect("clicked") {
41
41
  result = entry_map.active_text
42
42
  choosemap_win.destroy
43
- $network_map_result = result
43
+ $network_map_result = result
44
44
  }
45
45
  cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
46
46
  cancel_button.signal_connect("clicked") {
@@ -55,14 +55,15 @@ def choose_network_map(node_ip, default_map=nil)
55
55
  end
56
56
  }
57
57
 
58
- check_map = Gtk::CheckButton.new("Always use this network")
58
+ check_map = Gtk::CheckButton.new("Always map to this network")
59
59
  if $network_map_always == 1
60
60
  check_map.set_active true
61
61
  else
62
62
  check_map.set_active false
63
63
  end
64
64
  check_map.signal_connect("toggled") {
65
- $network_map_always = check_map.active? ? 1 : 0
65
+ # we don't care of the box is checked when the map is set to exception
66
+ $network_map_always = check_map.active? ? 1 : 0
66
67
  }
67
68
 
68
69
  bbox.add ok_button
@@ -157,7 +158,7 @@ def addnodewin()
157
158
  hbox = Gtk::HBox.new
158
159
  hbox.show
159
160
  entry_netmask = Gtk::Entry.new
160
- entry_netmask.set_text "255.255.255.0"
161
+ entry_netmask.set_text DEFAULT_CLASS_C_NETMASK
161
162
  entry_netmask.set_editable false
162
163
  entry_netmask.show
163
164
 
@@ -528,7 +529,7 @@ def addnetworkwin()
528
529
  hbox = Gtk::HBox.new
529
530
  hbox.show
530
531
  entry_netmask = Gtk::Entry.new
531
- entry_netmask.set_text "255.255.255.0"
532
+ entry_netmask.set_text DEFAULT_CLASS_C_NETMASK
532
533
  entry_netmask.set_editable false
533
534
  entry_netmask.show
534
535
 
@@ -662,7 +663,7 @@ def addnetworkwin()
662
663
  end
663
664
 
664
665
  #
665
- # delete node
666
+ # delete node window
666
667
  #
667
668
  def delnodewin()
668
669
  if $win == nil
@@ -795,5 +796,103 @@ def delnodewin()
795
796
  vbox_root.pack_start(separator, FALSE, TRUE, 0)
796
797
  vbox_root.pack_start(bbox, FALSE, TRUE, 0)
797
798
 
798
- delwin.show
799
+ delwin.show
800
+ end
801
+
802
+ #
803
+ # unwanted node window
804
+ #
805
+ def unwantednodewin()
806
+ if $win == nil
807
+ return
808
+ end
809
+
810
+ unwtdwin=Gtk::Window.new
811
+ unwtdwin.set_transient_for($win)
812
+ unwtdwin.set_title("Unwanted node")
813
+ unwtdwin.set_size_request(250, 160)
814
+ unwtdwin.set_modal(true)
815
+
816
+ unwtdwin.signal_connect("key_press_event") {|w,e|
817
+ if e.keyval == Gdk::Keyval::GDK_Escape
818
+ unwtdwin.destroy
819
+ end
820
+ }
821
+
822
+ frame = Gtk::Frame::new("Del exception")
823
+ frame.border_width=10
824
+ frame.show
825
+ vbox_root=Gtk::VBox::new
826
+ vbox_root.show
827
+ unwtdwin.add vbox_root
828
+ vbox_root.add frame
829
+ vbox = Gtk::VBox.new
830
+ vbox.show
831
+ frame.add vbox
832
+
833
+ table = Gtk::Table.new(2,2,false)
834
+ table.set_row_spacings(5)
835
+ table.set_size_request(-1,15)
836
+ table.show
837
+
838
+ label_value = Gtk::Label.new "Value"
839
+ label_value.show
840
+ combo_value=Gtk::ComboBox.new
841
+ $node_exception_list.sort.each do |str|
842
+ combo_value.append_text(str)
843
+ end
844
+ combo_value.set_active(0)
845
+ combo_value.show
846
+
847
+ table.attach(label_value,0,1,0,1)
848
+ table.attach(combo_value,1,2,0,1)
849
+
850
+ label_map_exception = Gtk::Label.new "Always map new node"
851
+ label_map_exception.show
852
+ check_map = Gtk::CheckButton.new
853
+ if $network_map_always == 1
854
+ check_map.set_active true
855
+ else
856
+ check_map.set_active false
857
+ end
858
+ check_map.show
859
+ check_map.signal_connect("toggled") {
860
+ $network_map_always = check_map.active? ? 1 : 0
861
+ }
862
+
863
+ table.attach(check_map,0,1,1,2)
864
+ table.attach(label_map_exception,1,2,1,2)
865
+
866
+ del_button = Gtk::Button.new(Gtk::Stock::REMOVE)
867
+ del_button.show
868
+ del_button.signal_connect("clicked") {
869
+ if combo_value.active >= 0
870
+ del_node_def_exception_list(combo_value.active_text)
871
+ combo_value.remove_text(combo_value.active)
872
+ combo_value.set_active(0)
873
+ end
874
+ }
875
+
876
+ close_button = Gtk::Button.new(Gtk::Stock::CLOSE)
877
+ close_button.show
878
+ close_button.signal_connect("clicked") {
879
+ unwtdwin.destroy
880
+ }
881
+
882
+ bbox =Gtk::HBox::new(FALSE, 10)
883
+ bbox.border_width=10
884
+ bbox.show
885
+
886
+ del_button.set_flags(Gtk::Widget::CAN_DEFAULT)
887
+ bbox.pack_start(del_button, TRUE, TRUE, 0)
888
+ close_button.set_flags(Gtk::Widget::CAN_DEFAULT)
889
+ bbox.pack_start(close_button, TRUE, TRUE, 0)
890
+
891
+ vbox.pack_start(table, FALSE, TRUE)
892
+ separator = Gtk::HSeparator::new()
893
+ separator.show
894
+ vbox_root.pack_start(separator, FALSE, TRUE, 0)
895
+ vbox_root.pack_start(bbox, FALSE, TRUE, 0)
896
+
897
+ unwtdwin.show
799
898
  end