/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: Björn Påhlsson
  • Date: 2010-09-09 22:06:10 UTC
  • mto: (237.4.3 mandos-release)
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: belorn@fukt.bsnet.se-20100909220610-fcpkaykznlq22oaw
minor debug info for plugin-runner.
Commit before merge

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
 
                                                [u"LastCheckedOK"])
 
137
                                                ["last_checked_ok"])
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
146
 
                                         [u"Interval"]))
 
145
                                         self.properties["interval"]))
147
146
        if self.last_checker_failed:
148
147
            self._update_timer_callback_tag = (gobject.timeout_add
149
148
                                               (1000,
157
156
                self._update_timer_callback_tag = None
158
157
            self.logger(u'Checker for client %s (command "%s")'
159
158
                        u' was successful'
160
 
                        % (self.properties[u"Name"], command))
 
159
                        % (self.properties[u"name"], command))
161
160
            self.update()
162
161
            return
163
162
        # Checker failed
169
168
        if os.WIFEXITED(condition):
170
169
            self.logger(u'Checker for client %s (command "%s")'
171
170
                        u' failed with exit code %s'
172
 
                        % (self.properties[u"Name"], command,
 
171
                        % (self.properties[u"name"], command,
173
172
                           os.WEXITSTATUS(condition)))
174
173
        elif os.WIFSIGNALED(condition):
175
174
            self.logger(u'Checker for client %s (command "%s")'
176
175
                        u' was killed by signal %s'
177
 
                        % (self.properties[u"Name"], command,
 
176
                        % (self.properties[u"name"], command,
178
177
                           os.WTERMSIG(condition)))
179
178
        elif os.WCOREDUMP(condition):
180
179
            self.logger(u'Checker for client %s (command "%s")'
181
180
                        u' dumped core'
182
 
                        % (self.properties[u"Name"], command))
 
181
                        % (self.properties[u"name"], command))
183
182
        else:
184
 
            self.logger(u'Checker for client %s completed'
185
 
                        u' mysteriously')
 
183
            self.logger(u'Checker for client %s completed mysteriously')
186
184
        self.update()
187
185
    
188
186
    def checker_started(self, command):
189
187
        #self.logger(u'Client %s started checker "%s"'
190
 
        #            % (self.properties[u"Name"], unicode(command)))
 
188
        #            % (self.properties[u"name"], unicode(command)))
191
189
        pass
192
190
    
193
191
    def got_secret(self):
194
192
        self.last_checker_failed = False
195
193
        self.logger(u'Client %s received its secret'
196
 
                    % self.properties[u"Name"])
 
194
                    % self.properties[u"name"])
197
195
    
198
196
    def need_approval(self, timeout, default):
199
197
        if not default:
201
199
        else:
202
200
            message = u'Client %s will get its secret in %s seconds'
203
201
        self.logger(message
204
 
                    % (self.properties[u"Name"], timeout/1000))
 
202
                    % (self.properties[u"name"], timeout/1000))
205
203
    
206
204
    def rejected(self, reason):
207
205
        self.logger(u'Client %s was rejected; reason: %s'
208
 
                    % (self.properties[u"Name"], reason))
 
206
                    % (self.properties[u"name"], reason))
209
207
    
210
208
    def selectable(self):
211
209
        """Make this a "selectable" widget.
238
236
 
239
237
        # Base part of a client. Name!
240
238
        base = (u'%(name)s: '
241
 
                      % {u"name": self.properties[u"Name"]})
242
 
        if not self.properties[u"Enabled"]:
 
239
                      % {u"name": self.properties[u"name"]})
 
240
        if not self.properties[u"enabled"]:
243
241
            message = u"DISABLED"
244
 
        elif self.properties[u"ApprovalPending"]:
245
 
            if self.properties[u"ApprovedByDefault"]:
 
242
        elif self.properties[u"approved_pending"]:
 
243
            if self.properties[u"approved_by_default"]:
246
244
                message = u"Connection established to client. (d)eny?"
247
245
            else:
248
246
                message = u"Seeks approval to send secret. (a)pprove?"
249
247
        elif self.last_checker_failed:
250
248
            timeout = datetime.timedelta(milliseconds
251
 
                                         = self.properties
252
 
                                         [u"Timeout"])
 
249
                                         = self.properties[u"timeout"])
253
250
            last_ok = isoformat_to_datetime(
254
 
                max((self.properties[u"LastCheckedOK"]
255
 
                     or self.properties[u"Created"]),
256
 
                    self.properties[u"LastEnabled"]))
 
251
                max((self.properties["last_checked_ok"]
 
252
                     or self.properties["created"]),
 
253
                    self.properties[u"last_enabled"]))
257
254
            timer = timeout - (datetime.datetime.utcnow() - last_ok)
258
 
            message = (u'A checker has failed! Time until client'
259
 
                       u' gets diabled: %s'
 
255
            message = (u'A checker has failed! Time until client gets diabled: %s'
260
256
                           % unicode(timer).rsplit(".", 1)[0])
261
257
        else:
262
258
            message = u"enabled"
350
346
    use them as an excuse to shift focus away from this widget.
351
347
    """
352
348
    def keypress(self, (maxcol, maxrow), key):
353
 
        ret = super(ConstrainedListBox, self).keypress((maxcol,
354
 
                                                        maxrow), key)
 
349
        ret = super(ConstrainedListBox, self).keypress((maxcol, maxrow), key)
355
350
        if ret in (u"up", u"down"):
356
351
            return
357
352
        return ret
474
469
        Call this when the widget layout needs to change"""
475
470
        self.uilist = []
476
471
        #self.uilist.append(urwid.ListBox(self.clients))
477
 
        self.uilist.append(urwid.Frame(ConstrainedListBox(self.
478
 
                                                          clients),
 
472
        self.uilist.append(urwid.Frame(ConstrainedListBox(self.clients),
479
473
                                       #header=urwid.Divider(),
480
474
                                       header=None,
481
 
                                       footer=
482
 
                                       urwid.Divider(div_char=
483
 
                                                     self.divider)))
 
475
                                       footer=urwid.Divider(div_char=self.divider)))
484
476
        if self.log_visible:
485
477
            self.uilist.append(self.logbox)
486
478
            pass
549
541
        if path is None:
550
542
            path = client.proxy.object_path
551
543
        self.clients_dict[path] = client
552
 
        self.clients.sort(None, lambda c: c.properties[u"Name"])
 
544
        self.clients.sort(None, lambda c: c.properties[u"name"])
553
545
        self.refresh()
554
546
    
555
547
    def remove_client(self, client, path=None):