diff options
author | Immae <ismael.bouya@normalesup.org> | 2014-06-29 23:34:44 +0200 |
---|---|---|
committer | Immae <ismael.bouya@normalesup.org> | 2014-06-29 23:34:44 +0200 |
commit | 31d11931d1dbde78afbdc67ba2405f3e8e78369d (patch) | |
tree | ab299c1a45828568fadc5fa6deef8cf0d603d2de | |
parent | 332497b1a92f4257eea0c9257d041c8898c91c31 (diff) | |
download | Monitor-master.tar.gz Monitor-master.tar.zst Monitor-master.zip |
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | ini_read.rb | 15 | ||||
-rw-r--r-- | monitor.rb | 20 | ||||
-rw-r--r-- | monitorrc | 3 | ||||
-rw-r--r-- | windows.rb | 4 |
6 files changed, 30 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1 @@ | |||
*.swp | |||
@@ -3,8 +3,6 @@ | |||
3 | - keep previous buffers for oneshot commands | 3 | - keep previous buffers for oneshot commands |
4 | - custom key bindings (and informations in the window) | 4 | - custom key bindings (and informations in the window) |
5 | - Man file | 5 | - Man file |
6 | - Check correctness of entries in config file (and capitalization) | ||
7 | - Customization of window size | ||
8 | - ~Internationalization | 6 | - ~Internationalization |
9 | - Respect colors from command? | 7 | - Respect colors from command? |
10 | 8 | ||
diff --git a/ini_read.rb b/ini_read.rb index 9ae3f1b..41259d8 100644 --- a/ini_read.rb +++ b/ini_read.rb | |||
@@ -32,6 +32,7 @@ class Ini_read | |||
32 | find_ini(options.inifile) | 32 | find_ini(options.inifile) |
33 | read_ini() | 33 | read_ini() |
34 | parse_config() | 34 | parse_config() |
35 | parse_global() | ||
35 | end | 36 | end |
36 | 37 | ||
37 | def find_ini(option_inifile) | 38 | def find_ini(option_inifile) |
@@ -47,7 +48,7 @@ class Ini_read | |||
47 | end | 48 | end |
48 | 49 | ||
49 | def read_ini() | 50 | def read_ini() |
50 | @config = IniFile.load(@inifile, :default=>'global') | 51 | @config = IniFile.load(@inifile, :default => 'global') |
51 | if(@config.nil?) | 52 | if(@config.nil?) |
52 | puts "Initialization file not found or not readable" | 53 | puts "Initialization file not found or not readable" |
53 | exit | 54 | exit |
@@ -65,6 +66,7 @@ class Ini_read | |||
65 | sec = @config[section] | 66 | sec = @config[section] |
66 | if(section == "global") | 67 | if(section == "global") |
67 | @global = sec | 68 | @global = sec |
69 | next | ||
68 | end | 70 | end |
69 | if(not sec.has_key?('Type')) | 71 | if(not sec.has_key?('Type')) |
70 | puts "Section incomplete, ignored: "+ section | 72 | puts "Section incomplete, ignored: "+ section |
@@ -87,5 +89,16 @@ class Ini_read | |||
87 | end | 89 | end |
88 | end | 90 | end |
89 | 91 | ||
92 | def parse_global() | ||
93 | if(@global.has_key?('list_size')) | ||
94 | @global['list_size'] = @global['list_size'].to_i | ||
95 | if(@global['list_size'] == 0) | ||
96 | @global['list_size'] = 25 | ||
97 | end | ||
98 | else | ||
99 | @global['list_size'] = 25 | ||
100 | end | ||
101 | end | ||
102 | |||
90 | end | 103 | end |
91 | 104 | ||
@@ -5,11 +5,11 @@ require_relative 'ini_read' | |||
5 | require_relative 'windows' | 5 | require_relative 'windows' |
6 | require_relative 'buffer' | 6 | require_relative 'buffer' |
7 | 7 | ||
8 | def make_bufwins(sections) | 8 | def make_bufwins(sections,size) |
9 | bufwins = [] | 9 | bufwins = [] |
10 | sections.each { |section_name,section| | 10 | sections.each { |section_name,section| |
11 | bufwin = Buff_Win.new(Ncurses.COLS()-Ncurses.COLS()/4, | 11 | bufwin = Buff_Win.new(Ncurses.COLS()-size*Ncurses.COLS()/100, |
12 | Ncurses.COLS()/4, | 12 | size*Ncurses.COLS()/100, |
13 | section) | 13 | section) |
14 | bufwins.push(bufwin) | 14 | bufwins.push(bufwin) |
15 | } | 15 | } |
@@ -22,11 +22,11 @@ def update_buffers(bufwins) | |||
22 | end | 22 | end |
23 | end | 23 | end |
24 | 24 | ||
25 | def redraw_all(list,bufwins,curr_bufwin) | 25 | def redraw_all(list,bufwins,curr_bufwin, size) |
26 | bufwins.each do |bufwin| | 26 | bufwins.each do |bufwin| |
27 | bufwin.move_resize(Ncurses.COLS()-Ncurses.COLS()/4,Ncurses.COLS()/4) | 27 | bufwin.move_resize(Ncurses.COLS()-size*Ncurses.COLS()/100,size*Ncurses.COLS()/100) |
28 | end | 28 | end |
29 | list.resize(Ncurses.LINES(), Ncurses.COLS()/4) | 29 | list.resize(Ncurses.LINES(), size*Ncurses.COLS()/100) |
30 | list.clear() | 30 | list.clear() |
31 | list.print_list() | 31 | list.print_list() |
32 | list.refresh() | 32 | list.refresh() |
@@ -48,8 +48,8 @@ begin | |||
48 | Ncurses.init_pair(10, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK) | 48 | Ncurses.init_pair(10, Ncurses::COLOR_WHITE, Ncurses::COLOR_BLACK) |
49 | 49 | ||
50 | 50 | ||
51 | list = List_Win.new(inistruct.sections) | 51 | list = List_Win.new(inistruct.sections, inistruct.global['list_size']) |
52 | bufwins = make_bufwins(inistruct.sections) | 52 | bufwins = make_bufwins(inistruct.sections, inistruct.global['list_size']) |
53 | entry = 0 | 53 | entry = 0 |
54 | cur_bufwin = bufwins[entry] | 54 | cur_bufwin = bufwins[entry] |
55 | cur_bufwin.show_win() | 55 | cur_bufwin.show_win() |
@@ -67,11 +67,11 @@ begin | |||
67 | cur_bufwin.show_win() | 67 | cur_bufwin.show_win() |
68 | list.print_list(entry=entry) | 68 | list.print_list(entry=entry) |
69 | when 12 #ctrl+L | 69 | when 12 #ctrl+L |
70 | redraw_all(list,bufwins,cur_bufwin) | 70 | redraw_all(list,bufwins,cur_bufwin, inistruct.global['list_size']) |
71 | when 18 #ctrl+R | 71 | when 18 #ctrl+R |
72 | cur_bufwin.update(force=true) | 72 | cur_bufwin.update(force=true) |
73 | when Ncurses::KEY_RESIZE | 73 | when Ncurses::KEY_RESIZE |
74 | redraw_all(list,bufwins,cur_bufwin) | 74 | redraw_all(list,bufwins,cur_bufwin, inistruct.global['list_size']) |
75 | when Ncurses::KEY_LEFT | 75 | when Ncurses::KEY_LEFT |
76 | cur_bufwin.hscroll(scroll=-1) | 76 | cur_bufwin.hscroll(scroll=-1) |
77 | when Ncurses::KEY_RIGHT | 77 | when Ncurses::KEY_RIGHT |
@@ -1,3 +1,6 @@ | |||
1 | [global] | ||
2 | list_size = 50 | ||
3 | |||
1 | [journalctl_err] | 4 | [journalctl_err] |
2 | Name = Journalctl errors | 5 | Name = Journalctl errors |
3 | Command = "journalctl --full -f -p4" | 6 | Command = "journalctl --full -f -p4" |
@@ -52,9 +52,9 @@ end | |||
52 | 52 | ||
53 | 53 | ||
54 | class List_Win | 54 | class List_Win |
55 | def initialize(sections) | 55 | def initialize(sections, size) |
56 | @params = sections | 56 | @params = sections |
57 | @win = Ncurses::WINDOW.new(0, Ncurses.COLS()/4, 0, 0) | 57 | @win = Ncurses::WINDOW.new(0, size*Ncurses.COLS()/100, 0, 0) |
58 | @win.border(*([0]*8)) | 58 | @win.border(*([0]*8)) |
59 | @win.keypad(true) | 59 | @win.keypad(true) |
60 | @win.timeout(1000) | 60 | @win.timeout(1000) |