/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: teddy at bsnet
  • Date: 2010-09-14 18:22:03 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100914182203-w26c64tdthto4jg2
* mandos-monitor.xml: New.
* Makefile (PROGS): Add "mandos-monitor".
  (DOCS): Add "mandos-monitor.xml".
  (mandos-monitor.8, mandos-monitor.8.xhtml, mandos-monitor): New.
  (install-server): Install "mandos-ctl" and "mandos-monitor" too.
  (uninstall-server): Remove "mandos-ctl" and "mandos-monitor" too.
* mandos-monitor: Don't log uninteresting messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
                                     client_interface,
135
135
                                     byte_arrays=True)
136
136
        last_checked_ok = isoformat_to_datetime(self.properties
137
 
                                                ["last_checked_ok"])
 
137
                                                [u"LastCheckedOK"])
138
138
        if last_checked_ok is None:
139
139
            self.last_checker_failed = True
140
140
        else:
142
142
                                         - last_checked_ok)
143
143
                                        > datetime.timedelta
144
144
                                        (milliseconds=
145
 
                                         self.properties["interval"]))
 
145
                                         self.properties
 
146
                                         [u"Interval"]))
146
147
        if self.last_checker_failed:
147
148
            self._update_timer_callback_tag = (gobject.timeout_add
148
149
                                               (1000,
154
155
                self.last_checker_failed = False
155
156
                gobject.source_remove(self._update_timer_callback_tag)
156
157
                self._update_timer_callback_tag = None
157
 
            self.logger(u'Checker for client %s (command "%s")'
158
 
                        u' was successful'
159
 
                        % (self.properties[u"name"], command))
 
158
            #self.logger(u'Checker for client %s (command "%s")'
 
159
            #            u' was successful'
 
160
            #            % (self.properties[u"Name"], command))
160
161
            self.update()
161
162
            return
162
163
        # Checker failed
168
169
        if os.WIFEXITED(condition):
169
170
            self.logger(u'Checker for client %s (command "%s")'
170
171
                        u' failed with exit code %s'
171
 
                        % (self.properties[u"name"], command,
 
172
                        % (self.properties[u"Name"], command,
172
173
                           os.WEXITSTATUS(condition)))
173
174
        elif os.WIFSIGNALED(condition):
174
175
            self.logger(u'Checker for client %s (command "%s")'
175
176
                        u' was killed by signal %s'
176
 
                        % (self.properties[u"name"], command,
 
177
                        % (self.properties[u"Name"], command,
177
178
                           os.WTERMSIG(condition)))
178
179
        elif os.WCOREDUMP(condition):
179
180
            self.logger(u'Checker for client %s (command "%s")'
180
181
                        u' dumped core'
181
 
                        % (self.properties[u"name"], command))
 
182
                        % (self.properties[u"Name"], command))
182
183
        else:
183
 
            self.logger(u'Checker for client %s completed mysteriously')
 
184
            self.logger(u'Checker for client %s completed'
 
185
                        u' mysteriously')
184
186
        self.update()
185
187
    
186
188
    def checker_started(self, command):
187
189
        #self.logger(u'Client %s started checker "%s"'
188
 
        #            % (self.properties[u"name"], unicode(command)))
 
190
        #            % (self.properties[u"Name"], unicode(command)))
189
191
        pass
190
192
    
191
193
    def got_secret(self):
192
194
        self.last_checker_failed = False
193
195
        self.logger(u'Client %s received its secret'
194
 
                    % self.properties[u"name"])
 
196
                    % self.properties[u"Name"])
195
197
    
196
198
    def need_approval(self, timeout, default):
197
199
        if not default:
199
201
        else:
200
202
            message = u'Client %s will get its secret in %s seconds'
201
203
        self.logger(message
202
 
                    % (self.properties[u"name"], timeout/1000))
 
204
                    % (self.properties[u"Name"], timeout/1000))
203
205
    
204
206
    def rejected(self, reason):
205
207
        self.logger(u'Client %s was rejected; reason: %s'
206
 
                    % (self.properties[u"name"], reason))
 
208
                    % (self.properties[u"Name"], reason))
207
209
    
208
210
    def selectable(self):
209
211
        """Make this a "selectable" widget.
236
238
 
237
239
        # Base part of a client. Name!
238
240
        base = (u'%(name)s: '
239
 
                      % {u"name": self.properties[u"name"]})
240
 
        if not self.properties[u"enabled"]:
 
241
                      % {u"name": self.properties[u"Name"]})
 
242
        if not self.properties[u"Enabled"]:
241
243
            message = u"DISABLED"
242
 
        elif self.properties[u"approved_pending"]:
243
 
            if self.properties[u"approved_by_default"]:
 
244
        elif self.properties[u"ApprovalPending"]:
 
245
            if self.properties[u"ApprovedByDefault"]:
244
246
                message = u"Connection established to client. (d)eny?"
245
247
            else:
246
248
                message = u"Seeks approval to send secret. (a)pprove?"
247
249
        elif self.last_checker_failed:
248
250
            timeout = datetime.timedelta(milliseconds
249
 
                                         = self.properties[u"timeout"])
 
251
                                         = self.properties
 
252
                                         [u"Timeout"])
250
253
            last_ok = isoformat_to_datetime(
251
 
                max((self.properties["last_checked_ok"]
252
 
                     or self.properties["created"]),
253
 
                    self.properties[u"last_enabled"]))
 
254
                max((self.properties[u"LastCheckedOK"]
 
255
                     or self.properties[u"Created"]),
 
256
                    self.properties[u"LastEnabled"]))
254
257
            timer = timeout - (datetime.datetime.utcnow() - last_ok)
255
 
            message = (u'A checker has failed! Time until client gets diabled: %s'
 
258
            message = (u'A checker has failed! Time until client'
 
259
                       u' gets diabled: %s'
256
260
                           % unicode(timer).rsplit(".", 1)[0])
257
261
        else:
258
262
            message = u"enabled"
321
325
#             self.proxy.unpause()
322
326
#         elif key == u"RET":
323
327
#             self.open()
324
 
#        elif key == u"+":
325
 
#            self.proxy.Approve(True)
326
 
#        elif key == u"-":
327
 
#            self.proxy.Approve(False)
328
328
        else:
329
329
            return key
330
330
    
346
346
    use them as an excuse to shift focus away from this widget.
347
347
    """
348
348
    def keypress(self, (maxcol, maxrow), key):
349
 
        ret = super(ConstrainedListBox, self).keypress((maxcol, maxrow), key)
 
349
        ret = super(ConstrainedListBox, self).keypress((maxcol,
 
350
                                                        maxrow), key)
350
351
        if ret in (u"up", u"down"):
351
352
            return
352
353
        return ret
469
470
        Call this when the widget layout needs to change"""
470
471
        self.uilist = []
471
472
        #self.uilist.append(urwid.ListBox(self.clients))
472
 
        self.uilist.append(urwid.Frame(ConstrainedListBox(self.clients),
 
473
        self.uilist.append(urwid.Frame(ConstrainedListBox(self.
 
474
                                                          clients),
473
475
                                       #header=urwid.Divider(),
474
476
                                       header=None,
475
 
                                       footer=urwid.Divider(div_char=self.divider)))
 
477
                                       footer=
 
478
                                       urwid.Divider(div_char=
 
479
                                                     self.divider)))
476
480
        if self.log_visible:
477
481
            self.uilist.append(self.logbox)
478
482
            pass
496
500
        """Toggle visibility of the log buffer."""
497
501
        self.log_visible = not self.log_visible
498
502
        self.rebuild()
499
 
        self.log_message(u"Log visibility changed to: "
500
 
                         + unicode(self.log_visible))
 
503
        #self.log_message(u"Log visibility changed to: "
 
504
        #                 + unicode(self.log_visible))
501
505
    
502
506
    def change_log_display(self):
503
507
        """Change type of log display.
508
512
            self.log_wrap = u"clip"
509
513
        for textwidget in self.log:
510
514
            textwidget.set_wrap_mode(self.log_wrap)
511
 
        self.log_message(u"Wrap mode: " + self.log_wrap)
 
515
        #self.log_message(u"Wrap mode: " + self.log_wrap)
512
516
    
513
517
    def find_and_remove_client(self, path, name):
514
518
        """Find an client from its object path and remove it.
541
545
        if path is None:
542
546
            path = client.proxy.object_path
543
547
        self.clients_dict[path] = client
544
 
        self.clients.sort(None, lambda c: c.properties[u"name"])
 
548
        self.clients.sort(None, lambda c: c.properties[u"Name"])
545
549
        self.refresh()
546
550
    
547
551
    def remove_client(self, client, path=None):