gnms 2.1.0.rc1
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.
- data/LICENSE +459 -0
- data/README +29 -0
- data/bin/gnms +11 -0
- data/gnms.gemspec +70 -0
- data/lib/cmd_parse.rb +747 -0
- data/lib/config_global.rb +414 -0
- data/lib/contact.rb +171 -0
- data/lib/external/crypt/blowfish-tables.rb +190 -0
- data/lib/external/crypt/blowfish.rb +110 -0
- data/lib/external/crypt/cbc.rb +123 -0
- data/lib/external/crypt/stringxor.rb +27 -0
- data/lib/external/fog.rb +41 -0
- data/lib/external/jjmx.rb +45 -0
- data/lib/external/sms.rb +282 -0
- data/lib/external/xmpp4r-simple.rb +497 -0
- data/lib/format.rb +85 -0
- data/lib/gnms.rb +329 -0
- data/lib/gui/about_window.rb +177 -0
- data/lib/gui/adddelnode.rb +799 -0
- data/lib/gui/base_window.rb +789 -0
- data/lib/gui/canvas_map.rb +498 -0
- data/lib/gui/charts/gruff.rb +51 -0
- data/lib/gui/color_macro.rb +145 -0
- data/lib/gui/config_window.rb +2151 -0
- data/lib/gui/custom_plugin_window.rb +90 -0
- data/lib/gui/debug_window.rb +46 -0
- data/lib/gui/event_window.rb +469 -0
- data/lib/gui/find_node_window.rb +438 -0
- data/lib/gui/help_window.rb +47 -0
- data/lib/gui/ipcalculator.rb +147 -0
- data/lib/gui/jmx_ref_window.rb +309 -0
- data/lib/gui/link_view.rb +46 -0
- data/lib/gui/mib_browser.rb +585 -0
- data/lib/gui/node_host_property.rb +3712 -0
- data/lib/gui/node_host_view.rb +270 -0
- data/lib/gui/node_network_property.rb +1059 -0
- data/lib/gui/node_network_view.rb +186 -0
- data/lib/gui/node_view.rb +672 -0
- data/lib/gui/oid_ref_window.rb +288 -0
- data/lib/gui/snmptrap_ref_window.rb +288 -0
- data/lib/gui/sub/account_frame.rb +196 -0
- data/lib/gui/sub/contact_frame.rb +519 -0
- data/lib/gui/syslog_ref_window.rb +288 -0
- data/lib/gui/treenode_window.rb +320 -0
- data/lib/gui/update_window.rb +124 -0
- data/lib/gui/widgets.rb +169 -0
- data/lib/gui/wmi_ref_window.rb +286 -0
- data/lib/interface.rb +16 -0
- data/lib/ipcalc.rb +266 -0
- data/lib/link.rb +45 -0
- data/lib/main.rb +1091 -0
- data/lib/monitor/client/custom/custom_monitoring.rb +40 -0
- data/lib/monitor/client/jmx/jmx_attr_monitoring.rb +36 -0
- data/lib/monitor/client/jmx/jmx_monitoring.rb +83 -0
- data/lib/monitor/client/jmx/jmx_ref.rb +114 -0
- data/lib/monitor/client/snmp/mibs/SNMPv2-MIB.txt +854 -0
- data/lib/monitor/client/snmp/mibs/SNMPv2-SMI.txt +344 -0
- data/lib/monitor/client/snmp/oid_ref.rb +141 -0
- data/lib/monitor/client/snmp/snmp.rb +178 -0
- data/lib/monitor/client/snmp/snmp_monitoring.rb +58 -0
- data/lib/monitor/client/wmi/wmi.rb +139 -0
- data/lib/monitor/client/wmi/wmi_monitoring.rb +60 -0
- data/lib/monitor/client/wmi/wmi_ref.rb +141 -0
- data/lib/monitor/custom_plugin.rb +50 -0
- data/lib/monitor/server/msg_buffer.rb +39 -0
- data/lib/monitor/server/snmp/snmptrap_analyzer.rb +81 -0
- data/lib/monitor/server/snmp/snmptrap_capture.rb +26 -0
- data/lib/monitor/server/snmp/snmptrap_monitoring.rb +32 -0
- data/lib/monitor/server/snmp/snmptrap_ref.rb +135 -0
- data/lib/monitor/server/snmp/snmptrap_server.rb +50 -0
- data/lib/monitor/server/syslog/syslog_analyzer.rb +141 -0
- data/lib/monitor/server/syslog/syslog_capture.rb +28 -0
- data/lib/monitor/server/syslog/syslog_monitoring.rb +32 -0
- data/lib/monitor/server/syslog/syslog_ref.rb +136 -0
- data/lib/monitor/server/syslog/syslog_server.rb +43 -0
- data/lib/node.rb +1020 -0
- data/lib/node_db.rb +2668 -0
- data/lib/node_host.rb +215 -0
- data/lib/node_listener.rb +639 -0
- data/lib/node_network.rb +269 -0
- data/lib/node_property.rb +39 -0
- data/lib/notify/alarm.rb +247 -0
- data/lib/notify/irc_bot.rb +167 -0
- data/lib/notify/xmpp_bot.rb +107 -0
- data/lib/service.rb +36 -0
- data/lib/version.rb +8 -0
- data/pixmap/bg/map_bg.jpg +0 -0
- data/pixmap/bg/map_bg2.jpg +0 -0
- data/pixmap/logo.jpg +0 -0
- data/pixmap/logo_icon.png +0 -0
- data/pixmap/os/3com.png +0 -0
- data/pixmap/os/aix.gif +0 -0
- data/pixmap/os/amiga.png +0 -0
- data/pixmap/os/beos.png +0 -0
- data/pixmap/os/cisco.png +0 -0
- data/pixmap/os/freebsd.png +0 -0
- data/pixmap/os/hp.png +0 -0
- data/pixmap/os/hurd.gif +0 -0
- data/pixmap/os/irix.gif +0 -0
- data/pixmap/os/linux.png +0 -0
- data/pixmap/os/mac.png +0 -0
- data/pixmap/os/netbsd.gif +0 -0
- data/pixmap/os/netware.png +0 -0
- data/pixmap/os/openbsd.png +0 -0
- data/pixmap/os/os2warp.gif +0 -0
- data/pixmap/os/qnx.gif +0 -0
- data/pixmap/os/sco.gif +0 -0
- data/pixmap/os/sgi.xpm +111 -0
- data/pixmap/os/solaris.gif +0 -0
- data/pixmap/os/unix.gif +0 -0
- data/pixmap/os/unknown.png +0 -0
- data/pixmap/os/vms.xpm +345 -0
- data/pixmap/os/windows.png +0 -0
- data/pixmap/type/cloud.png +0 -0
- data/pixmap/type/device.png +0 -0
- data/pixmap/type/firewall.png +0 -0
- data/pixmap/type/gateway.png +0 -0
- data/pixmap/type/home.png +0 -0
- data/pixmap/type/host.png +0 -0
- data/pixmap/type/network.png +0 -0
- data/pixmap/type/printer.png +0 -0
- data/pixmap/type/router.png +0 -0
- data/pixmap/type/server.png +0 -0
- data/pixmap/type/switch.png +0 -0
- data/pixmap/type/vm.png +0 -0
- data/plugins/Defaultme.rb +7 -0
- data/plugins/DnsCheck.rb +46 -0
- data/plugins/FooMonitor.rb +26 -0
- data/plugins/HttpVirtualHostMonitor.rb +43 -0
- data/plugins/MysqlShowStatusMonitor.rb +64 -0
- data/plugins/PgsqlPercentConnectionMonitor.rb +72 -0
- data/plugins/SshCpuLoadMonitor.rb +85 -0
- data/plugins/SshDiskMonitor.rb +69 -0
- data/plugins/SshFgtAvExpiredMonitor.rb +75 -0
- data/plugins/SshPercentUsedRamMonitor.rb +74 -0
- data/plugins/TelnetCpuLoadMonitor.rb +69 -0
- data/plugins/example1.rb +15 -0
- data/plugins/example2.rb +7 -0
- data/sound/beep.wav +0 -0
- metadata +378 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
class CustomPluginWindow
|
2
|
+
|
3
|
+
#populate listview with saved values
|
4
|
+
def populate_ls()
|
5
|
+
$custom_monitor.each do |name|
|
6
|
+
iter = @custom_ref_ls.append
|
7
|
+
iter[0] = name
|
8
|
+
descr = "No description available"
|
9
|
+
begin
|
10
|
+
descr = Object.const_get(name).name()
|
11
|
+
rescue
|
12
|
+
end
|
13
|
+
iter[1] = descr
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize()
|
18
|
+
window=Gtk::Window.new
|
19
|
+
window.set_title("Custom Plugin Configuration")
|
20
|
+
window.set_size_request(500, 300)
|
21
|
+
|
22
|
+
window.signal_connect("key_press_event") {|w,e|
|
23
|
+
if e.keyval == Gdk::Keyval::GDK_Escape
|
24
|
+
window.destroy
|
25
|
+
end
|
26
|
+
}
|
27
|
+
|
28
|
+
frame = Gtk::Frame::new
|
29
|
+
frame.border_width=5
|
30
|
+
frame.show
|
31
|
+
vbox_root=Gtk::VBox::new
|
32
|
+
vbox_root.show
|
33
|
+
window.add vbox_root
|
34
|
+
vbox_root.add frame
|
35
|
+
|
36
|
+
vbox = Gtk::VBox.new(false,0)
|
37
|
+
vbox.show
|
38
|
+
frame.add vbox
|
39
|
+
|
40
|
+
@custom_ref_ls = Gtk::ListStore.new(String, String)
|
41
|
+
@custom_ref_view = Gtk::TreeView.new(@custom_ref_ls)
|
42
|
+
@custom_ref_view.show
|
43
|
+
column1 = Gtk::TreeViewColumn.new("Name",
|
44
|
+
Gtk::CellRendererText.new, {:text => 0})
|
45
|
+
column1.set_sort_column_id(0)
|
46
|
+
column2 = Gtk::TreeViewColumn.new("Description",
|
47
|
+
Gtk::CellRendererText.new, {:text => 1})
|
48
|
+
column2.set_sort_column_id(1)
|
49
|
+
|
50
|
+
@custom_ref_view.append_column(column1)
|
51
|
+
@custom_ref_view.append_column(column2)
|
52
|
+
|
53
|
+
scroll = Gtk::ScrolledWindow.new(nil, nil)
|
54
|
+
scroll.border_width=2
|
55
|
+
scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC)
|
56
|
+
scroll.add @custom_ref_view
|
57
|
+
scroll.show
|
58
|
+
|
59
|
+
populate_ls()
|
60
|
+
vbox.add(scroll)
|
61
|
+
|
62
|
+
bbox = Gtk::HBox::new(FALSE, 10)
|
63
|
+
bbox.border_width=10
|
64
|
+
bbox.show
|
65
|
+
|
66
|
+
ok_button = Gtk::Button.new(Gtk::Stock::OK)
|
67
|
+
ok_button.show
|
68
|
+
ok_button.signal_connect("clicked") {
|
69
|
+
window.destroy
|
70
|
+
}
|
71
|
+
|
72
|
+
cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
|
73
|
+
cancel_button.show
|
74
|
+
cancel_button.signal_connect("clicked") {
|
75
|
+
window.destroy
|
76
|
+
}
|
77
|
+
ok_button.set_flags(Gtk::Widget::CAN_DEFAULT)
|
78
|
+
bbox.pack_start(ok_button, TRUE, TRUE, 0)
|
79
|
+
cancel_button.set_flags(Gtk::Widget::CAN_DEFAULT)
|
80
|
+
bbox.pack_start(cancel_button, TRUE, TRUE, 0)
|
81
|
+
|
82
|
+
separator = Gtk::HSeparator::new()
|
83
|
+
separator.show
|
84
|
+
vbox_root.pack_start(separator, FALSE, TRUE, 0)
|
85
|
+
vbox_root.pack_start(bbox, FALSE, TRUE, 0)
|
86
|
+
|
87
|
+
window.show
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# debug window class
|
3
|
+
#
|
4
|
+
|
5
|
+
class DebugWindow
|
6
|
+
|
7
|
+
def initialize()
|
8
|
+
if $debug_console_win != nil
|
9
|
+
return
|
10
|
+
end
|
11
|
+
$debug_console_win = Gtk::Window.new
|
12
|
+
$debug_console_win.set_size_request(350,200)
|
13
|
+
$debug_console_win.set_title "Debug console"
|
14
|
+
$debug_console_win.resizable=false
|
15
|
+
$debug_console_win.window_position=Gtk::Window::POS_CENTER
|
16
|
+
icon_name="./pixmap/logo_icon.png"
|
17
|
+
Gtk::Window.set_default_icon(icon_name)
|
18
|
+
|
19
|
+
$debug_console_win.signal_connect("destroy") {
|
20
|
+
$debug_console_win.destroy
|
21
|
+
$debug_console_win = nil
|
22
|
+
}
|
23
|
+
$debug_console_win.signal_connect("key_press_event") {|w,e|
|
24
|
+
if e.keyval == 65307 #Esc key press
|
25
|
+
$debug_console_win.destroy
|
26
|
+
$debug_console_win = nil
|
27
|
+
end
|
28
|
+
}
|
29
|
+
|
30
|
+
vboxb = Gtk::VBox.new
|
31
|
+
cpt = 0
|
32
|
+
$thread_list.each_key {|thread_name|
|
33
|
+
tn_label = Gtk::Label.new("#{thread_name} thread is running")
|
34
|
+
vboxb.add tn_label
|
35
|
+
cpt+=1
|
36
|
+
}
|
37
|
+
|
38
|
+
if cpt == 0
|
39
|
+
tn_label = Gtk::Label.new("No thread is running")
|
40
|
+
vboxb.add tn_label
|
41
|
+
end
|
42
|
+
$debug_console_win.add vboxb
|
43
|
+
$debug_console_win.show_all
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,469 @@
|
|
1
|
+
require "#{GNMSLIB}"+'/node_property'
|
2
|
+
require "#{GNMSLIB}"+'/node'
|
3
|
+
require "#{GNMSLIB}"+'/cmd_parse'
|
4
|
+
require "#{GNMSLIB}"+'/node_listener'
|
5
|
+
require "#{GNMSLIB}"+'/gui/adddelnode'
|
6
|
+
require "#{GNMSLIB}"+'/gui/base_window'
|
7
|
+
require "#{GNMSLIB}"+'/gui/widgets.rb'
|
8
|
+
require "#{GNMSLIB}"+'/notify/alarm'
|
9
|
+
|
10
|
+
class EventWindow
|
11
|
+
|
12
|
+
EVENT_WINDOW_TITLE="Event Browser"
|
13
|
+
|
14
|
+
#event type
|
15
|
+
CORE_EVENT_TYPE="core"
|
16
|
+
PORT_EVENT_TYPE="port"
|
17
|
+
AVAIL_EVENT_TYPE="interface"
|
18
|
+
TRAP_EVENT_TYPE="trap"
|
19
|
+
CUSTOM_EVENT_TYPE="custom"
|
20
|
+
SNMP_EVENT_TYPE="snmp"
|
21
|
+
WMI_EVENT_TYPE="wmi"
|
22
|
+
JMX_EVENT_TYPE="jmx"
|
23
|
+
SYSLOG_EVENT_TYPE="syslog"
|
24
|
+
HTTP_EVENT_TYPE="http"
|
25
|
+
|
26
|
+
#end event type
|
27
|
+
#
|
28
|
+
# return if window is visible
|
29
|
+
#
|
30
|
+
def visible?()
|
31
|
+
return @window.visible?()
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# show the window
|
36
|
+
#
|
37
|
+
def show()
|
38
|
+
if $canvas.fullscreen?()
|
39
|
+
@window.set_modal(true)
|
40
|
+
@window.set_transient_for($win)
|
41
|
+
end
|
42
|
+
@window.deiconify()
|
43
|
+
return @window.show()
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# hide the window
|
48
|
+
#
|
49
|
+
def hide()
|
50
|
+
if $canvas.fullscreen?()
|
51
|
+
@window.set_modal(false)
|
52
|
+
@window.set_transient_for(nil)
|
53
|
+
end
|
54
|
+
return @window.hide()
|
55
|
+
end
|
56
|
+
|
57
|
+
def filter_by_sev(sev)
|
58
|
+
$level_view = sev
|
59
|
+
if @filter_node
|
60
|
+
filter_by_node(@filter_node)
|
61
|
+
else
|
62
|
+
filter_by_node()
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# show logs for this specific node, node=nil to show all logs
|
68
|
+
#
|
69
|
+
def filter_by_node(node=nil)
|
70
|
+
@list.clear()
|
71
|
+
if node
|
72
|
+
@filter_active=true
|
73
|
+
@filter_node=node
|
74
|
+
@event_strings.each {|pos, category, src_module, time, ip, summary, state|
|
75
|
+
if state != "A"
|
76
|
+
if filter_on_node(ip) && ($LEVEL.index(category)>=$LEVEL.index($level_view))
|
77
|
+
text = []
|
78
|
+
text.push pos
|
79
|
+
text.push category
|
80
|
+
text.push src_module
|
81
|
+
text.push time
|
82
|
+
text.push ip
|
83
|
+
text.push summary
|
84
|
+
@list.prepend(text)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
}
|
88
|
+
@window.set_title(EVENT_WINDOW_TITLE + " filter #{$level_view} from #{node.ip}")
|
89
|
+
else
|
90
|
+
@filter_active=false
|
91
|
+
@filter_node=nil
|
92
|
+
@event_strings.each {|pos, category, src_module, time, ip, summary, state|
|
93
|
+
if state != "A"
|
94
|
+
if ($LEVEL.index(category)>=$LEVEL.index($level_view))
|
95
|
+
text = []
|
96
|
+
text.push pos
|
97
|
+
text.push category
|
98
|
+
text.push src_module
|
99
|
+
text.push time
|
100
|
+
text.push ip
|
101
|
+
text.push summary
|
102
|
+
@list.prepend(text)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
}
|
106
|
+
@window.set_title(EVENT_WINDOW_TITLE)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# define if ip is part of the filter tag
|
112
|
+
#
|
113
|
+
def filter_on_node(ip_str)
|
114
|
+
if @filter_node == nil
|
115
|
+
return false
|
116
|
+
end
|
117
|
+
if exist_network(@filter_node.ip)
|
118
|
+
#we want to retrieve events from all a network
|
119
|
+
return $network[@filter_node.ip].contain_host(ip_str)
|
120
|
+
end
|
121
|
+
return ip_str == @filter_node.ip
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# add event in list
|
126
|
+
# state can be normal N or acknowledge A
|
127
|
+
#
|
128
|
+
def add_event(src_module, category, node, summary, datetime=nil, state='N')
|
129
|
+
if node
|
130
|
+
ip_str = node.ip
|
131
|
+
#puts "in add_event #{ip_str} #{summary}"
|
132
|
+
text = []
|
133
|
+
index_pos=@event_strings.length()+1
|
134
|
+
text.push index_pos.to_s
|
135
|
+
text.push category
|
136
|
+
text.push src_module
|
137
|
+
if datetime == nil
|
138
|
+
datetime=Time.new.to_s
|
139
|
+
end
|
140
|
+
text.push datetime
|
141
|
+
text.push ip_str
|
142
|
+
text.push summary
|
143
|
+
|
144
|
+
if filter_on_node(ip_str) || @filter_active == false
|
145
|
+
if $LEVEL.index(category)>=$LEVEL.index($level_view)
|
146
|
+
@buff.put Marshal.load(Marshal.dump(text))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
text.push state
|
150
|
+
#in event_strings there is one more column: state
|
151
|
+
@event_strings.push(text)
|
152
|
+
|
153
|
+
alarm_handle(src_module, category, ip_str, summary, datetime)
|
154
|
+
update_node_notification(get_status_from_level(category), ip_str)
|
155
|
+
update_statusbar()
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def hide_event()
|
160
|
+
iter = @list.selection.selected
|
161
|
+
if iter != nil
|
162
|
+
#set state to aknowledge
|
163
|
+
list_id=@list.get_value(iter,1)
|
164
|
+
event_id=list_id.to_i()-1
|
165
|
+
if @event_strings[event_id] != nil
|
166
|
+
@event_strings[event_id][6]='A'
|
167
|
+
#real time events sev need to be caught
|
168
|
+
if @event_strings[event_id][2] != CORE_EVENT_TYPE
|
169
|
+
event_type=@event_strings[event_id][2]
|
170
|
+
max_lev=nil
|
171
|
+
@event_strings.each {|pos, category, src_module, time, ip, summary, state|
|
172
|
+
if (src_module == event_type) && (state != "A")
|
173
|
+
if (max_lev != nil)
|
174
|
+
if ($LEVEL.index(category) > $LEVEL.index(max_lev))
|
175
|
+
max_lev=category
|
176
|
+
end
|
177
|
+
else
|
178
|
+
max_lev=category
|
179
|
+
end
|
180
|
+
end
|
181
|
+
}
|
182
|
+
if max_lev != nil
|
183
|
+
max_lev_status=get_status_from_level(max_lev)
|
184
|
+
if $host[@event_strings[event_id][4]] != nil
|
185
|
+
$host[@event_strings[event_id][4]].set_severity(event_type, $status.index(max_lev_status))
|
186
|
+
end
|
187
|
+
else
|
188
|
+
if $host[@event_strings[event_id][4]] != nil
|
189
|
+
$host[@event_strings[event_id][4]].set_severity(event_type, $status.index("UNMANAGED"))
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
#update notification icon
|
194
|
+
print "in hide_event #{@event_strings[event_id][4]} #{$status_value[$status.index(get_status_from_level(@event_strings[event_id][1]))]}\n"
|
195
|
+
ip = @event_strings[event_id][4]
|
196
|
+
if $host[ip] and $host[ip].node_view
|
197
|
+
sev=$status_value[$status.index(get_status_from_level(@event_strings[event_id][1]))]
|
198
|
+
if sev > NORMAL
|
199
|
+
$host[ip].node_view.del_notification(sev)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
#remove from gui
|
203
|
+
@list.remove(iter) unless iter == nil
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def update_node_notification(sev, ip)
|
209
|
+
sev_value = $status_value[$status.index(sev)]
|
210
|
+
if sev_value > NORMAL
|
211
|
+
$host[ip].node_view.add_notification(sev_value)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def acknowledge_event()
|
216
|
+
hide_event()
|
217
|
+
end
|
218
|
+
|
219
|
+
def stop_analyzer()
|
220
|
+
if @event_analyzer_thread.alive?
|
221
|
+
@event_analyzer_thread_status = 0
|
222
|
+
Thread.kill(@event_analyzer_thread)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
def analyze_event()
|
228
|
+
while @buff.has_more?
|
229
|
+
event=@buff.get
|
230
|
+
#puts "in analyze_event: #{@buff.has_more?} #{event}"
|
231
|
+
@list.prepend(event)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def initialize()
|
236
|
+
|
237
|
+
@statusbar=nil
|
238
|
+
@in_statusbar = Mutex.new
|
239
|
+
@list=nil
|
240
|
+
@event_strings=[]
|
241
|
+
@filter_active=false
|
242
|
+
@filter_node=nil
|
243
|
+
|
244
|
+
#################################################
|
245
|
+
#create thread to handle new events
|
246
|
+
#
|
247
|
+
@buff=MsgBuffer.new(1)
|
248
|
+
@event_analyzer_thread_status = 1
|
249
|
+
@event_analyzer_thread = Thread.start do
|
250
|
+
while (@event_analyzer_thread_status)
|
251
|
+
analyze_event if @buff.full?
|
252
|
+
sleep(1)
|
253
|
+
Thread.pass
|
254
|
+
end
|
255
|
+
$log.debug("end of EventAnalyzer thread")
|
256
|
+
end
|
257
|
+
|
258
|
+
#################################################
|
259
|
+
#GUI part
|
260
|
+
#
|
261
|
+
@window=Gtk::Window.new
|
262
|
+
@window.signal_connect("delete_event") do
|
263
|
+
self.hide()
|
264
|
+
end
|
265
|
+
|
266
|
+
@window.signal_connect("key_press_event") {|w,e|
|
267
|
+
if e.keyval == Gdk::Keyval::GDK_Escape
|
268
|
+
self.hide()
|
269
|
+
end
|
270
|
+
}
|
271
|
+
|
272
|
+
@window.set_size_request(600, 100)
|
273
|
+
@window.set_title(EVENT_WINDOW_TITLE)
|
274
|
+
@window.set_icon("#{PIXMAP_PATH}/logo_icon.png")
|
275
|
+
|
276
|
+
box1 = Gtk::VBox.new(false, 0)
|
277
|
+
@window.add(box1)
|
278
|
+
|
279
|
+
box1.show
|
280
|
+
box11 = Gtk::VBox.new(false, 0)
|
281
|
+
box11.show
|
282
|
+
|
283
|
+
#------------begin scrolledbar--------------------------------------
|
284
|
+
scrolled_window = Gtk::ScrolledWindow.new(nil, nil)
|
285
|
+
scrolled_window.border_width=0
|
286
|
+
scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC,
|
287
|
+
Gtk::POLICY_AUTOMATIC)
|
288
|
+
# scrolled_window.vscrollbar.unset_flag(Gtk::CAN_FOCUS)
|
289
|
+
box1.pack_start(scrolled_window, true, true, 0)
|
290
|
+
|
291
|
+
scrolled_window.add_with_viewport(box11)
|
292
|
+
box11.set_focus_vadjustment(scrolled_window.vadjustment)
|
293
|
+
scrolled_window.show
|
294
|
+
#----------------end scrolledbar-----------------------------------
|
295
|
+
|
296
|
+
|
297
|
+
@list = Gtk::CList::new(["Event ID", "Level", "Module","Timestamp", "Node", "Summary" ])
|
298
|
+
@list.set_sort_column(1,4)
|
299
|
+
#@list.selection.set_mode(Gtk::SELECTION_MULTIPLE)
|
300
|
+
# Create a popup menu
|
301
|
+
menu = Gtk::Menu.new
|
302
|
+
|
303
|
+
item_ack = Gtk::MenuItem.new("Acknowledge event")
|
304
|
+
item_ack.signal_connect("activate") { acknowledge_event() }
|
305
|
+
menu.append(item_ack)
|
306
|
+
|
307
|
+
item_clear = Gtk::MenuItem.new("Clear display")
|
308
|
+
item_clear.signal_connect("activate") { @list.clear() }
|
309
|
+
menu.append(item_clear)
|
310
|
+
|
311
|
+
item_remove_filter = Gtk::MenuItem.new("Remove src filter")
|
312
|
+
item_remove_filter.signal_connect("activate") { filter_by_node() }
|
313
|
+
menu.append(item_remove_filter)
|
314
|
+
|
315
|
+
|
316
|
+
map_menu_severity=Gtk::MenuItem.new("Severity threshold")
|
317
|
+
map_menu_severity_list=Gtk::Menu.new
|
318
|
+
radio_menu_grp=nil
|
319
|
+
for level in $LEVEL
|
320
|
+
rmi=Gtk::RadioMenuItem.new(radio_menu_grp,"#{level}")
|
321
|
+
if level == $level_view
|
322
|
+
rmi.set_active(true)
|
323
|
+
end
|
324
|
+
rmi.signal_connect("activate") do |widget|
|
325
|
+
if widget.active?
|
326
|
+
filter_by_sev(widget.child.label)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
radio_menu_grp=rmi.group
|
330
|
+
map_menu_severity_list.append(rmi)
|
331
|
+
end
|
332
|
+
map_menu_severity.set_submenu(map_menu_severity_list)
|
333
|
+
menu.append(map_menu_severity)
|
334
|
+
|
335
|
+
menu.show_all
|
336
|
+
|
337
|
+
@list.signal_connect("cursor-changed") do |widget, event|
|
338
|
+
iter=widget.selection.selected
|
339
|
+
ip=widget.get_value(iter,5)
|
340
|
+
|
341
|
+
if ip != nil
|
342
|
+
if $network.has_key?(ip)
|
343
|
+
set_map($network[ip].map)
|
344
|
+
$network[ip].node_view.select()
|
345
|
+
else
|
346
|
+
#verify that node exist
|
347
|
+
if $host[ip] != nil
|
348
|
+
set_map($host[ip].map)
|
349
|
+
$host[ip].node_view.select()
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
@list.signal_connect("button_press_event") do |widget, event|
|
356
|
+
if event.kind_of? Gdk::EventButton and event.button == 3
|
357
|
+
if @list.nb_event > 0
|
358
|
+
item_clear.set_sensitive(true)
|
359
|
+
else
|
360
|
+
item_clear.set_sensitive(false)
|
361
|
+
end
|
362
|
+
if @filter_active
|
363
|
+
item_remove_filter.set_sensitive(true)
|
364
|
+
else
|
365
|
+
item_remove_filter.set_sensitive(false)
|
366
|
+
end
|
367
|
+
menu.popup(nil, nil, event.button, event.time)
|
368
|
+
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
@list.signal_connect("key_press_event") {|w, e|
|
373
|
+
if (e.keyval == Gdk::Keyval::GDK_Delete) || (e.keyval == Gdk::Keyval::GDK_d)
|
374
|
+
hide_event()
|
375
|
+
end
|
376
|
+
}
|
377
|
+
|
378
|
+
@list.show
|
379
|
+
box11.add @list
|
380
|
+
|
381
|
+
#---------------------begin statusbar---------
|
382
|
+
|
383
|
+
@statusbar = Gtk::Statusbar.new
|
384
|
+
|
385
|
+
vvbox = Gtk::VButtonBox.new
|
386
|
+
vvbox.border_width=0
|
387
|
+
vvbox.set_layout_style(Gtk::ButtonBox::END)
|
388
|
+
vvbox.set_spacing(0)
|
389
|
+
vvbox.set_size_request(200, 20)
|
390
|
+
vvbox.show
|
391
|
+
|
392
|
+
box1.pack_start(@statusbar,false,false,0)
|
393
|
+
|
394
|
+
@statusbar.show
|
395
|
+
@statusbar.signal_connect("text_popped") do |o, mid, text|
|
396
|
+
popped(mid,text)
|
397
|
+
end
|
398
|
+
@statusbar.signal_connect("text_pushed") do |o, mid, text|
|
399
|
+
pushed(mid,text)
|
400
|
+
end
|
401
|
+
|
402
|
+
#---------------------end status bar----------
|
403
|
+
|
404
|
+
end
|
405
|
+
|
406
|
+
#
|
407
|
+
# update status bar (active host) / (total host)
|
408
|
+
# also update the statusicon if exists
|
409
|
+
#
|
410
|
+
def update_statusbar()
|
411
|
+
@in_statusbar.synchronize {
|
412
|
+
hup=0
|
413
|
+
hdown=0
|
414
|
+
if @statusbar != nil
|
415
|
+
begin
|
416
|
+
$host.each_key {|ip|
|
417
|
+
if $host[ip] && ($host[ip].status == NORMAL)
|
418
|
+
hup=hup+1
|
419
|
+
else
|
420
|
+
hdown=hdown+1
|
421
|
+
end
|
422
|
+
}
|
423
|
+
rescue Exception => msg
|
424
|
+
$log.error(msg)
|
425
|
+
end
|
426
|
+
str="Active Host" + ($host.size<2?" ":"s ") + "#{hup}/#{$host.size}"
|
427
|
+
@statusbar.push(1, str)
|
428
|
+
if $icon && $icon.embedded?
|
429
|
+
$icon.set_tooltip(str)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
}
|
433
|
+
end
|
434
|
+
|
435
|
+
def updating_statusbar?()
|
436
|
+
@in_statusbar.locked?
|
437
|
+
end
|
438
|
+
|
439
|
+
def save_event()
|
440
|
+
iter_zero=@list.model.get_iter("0")
|
441
|
+
if iter_zero != nil
|
442
|
+
#we extract the timestamp of the first entry
|
443
|
+
bbeg= @list.get_value(iter_zero,4)
|
444
|
+
vall=@list.nb_event-1
|
445
|
+
#we extract the timestamp of the last entry
|
446
|
+
bend=@list.get_value(@list.model.get_iter("#{vall}"),4)
|
447
|
+
|
448
|
+
#filename is base on the timestamp of the first and last entry
|
449
|
+
begin
|
450
|
+
filepath="#{LOG_DIR}/#{bend}-#{bbeg}"
|
451
|
+
$log.info("Saving log to #{filepath}")
|
452
|
+
fic = File.new(filepath,'w')
|
453
|
+
for row in 0..@list.nb_event-1
|
454
|
+
fic.puts(@list.get_value(@list.model.get_iter("#{row}"),4)+"\t"+@list.get_value(@list.model.get_iter("#{row}"),3)+"\t"+@list.get_value(@list.model.get_iter("#{row}"),2)+"\t"+@list.get_value(@list.model.get_iter("#{row}"),5)+"\t"+@list.get_value(@list.model.get_iter("#{row}"),6))
|
455
|
+
end
|
456
|
+
fic.close
|
457
|
+
rescue
|
458
|
+
$log.error("Can't write log to #{LOG_DIR}")
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def pushed(mid,text)
|
464
|
+
end
|
465
|
+
|
466
|
+
def popped(mid,text)
|
467
|
+
end
|
468
|
+
|
469
|
+
end
|