- msg = {
- 'timestamp': current_time,
- 'data': self.homedir_sizes,
- 'host': platform.node(),
- }
- conn = Connection(conf=mq_conf)
- conn.topic_send(config.topic,
- msg,
- exchange_name=config.exchange,
- timeout=5)
+ data = {}
+ for user in set(self.homedir_sizes.keys()) | \
+ set(self.lastlog_times.keys()):
+ data[user] = {
+ 'homedir': self.homedir_sizes.get(user, 0),
+ 'lastlog': self.lastlog_times.get(user, 0),
+ }
+
+ if mq_config is not None:
+ msg = {
+ 'timestamp': current_time,
+ 'data': data,
+ 'host': platform.node(),
+ }
+ conn = Connection(conf=mq_conf)
+ conn.topic_send(mq_config.topic,
+ msg,
+ exchange_name=mq_config.exchange,
+ timeout=5)