Skip to content

Commit 89a055d

Browse files
committed
HTTP, Mail URL collector: log downloaded sizes
To enable or ease troubleshooting, log the count of downloaded bytes Just observed a case of potentially incomplete downloads (but not HTTP errors) and it's hard to find out the actual sizes of past downloads. Enabling debug logging is not an option either, as that logs the complete responses (hundreds of MBs potentially).
1 parent 7f71e6a commit 89a055d

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
- `intelmq.bots.collectors.shadowserver.collector_reports_api.py`:
2424
- Fixed behaviour if parameter `types` value is empty string, behave the same way as not set, not like no type.
2525
- `intelmq.bots.collectors.misp`: Use `PyMISP` class instead of deprecated `ExpandedPyMISP` (PR#2532 by Radek Vyhnal)
26-
- `intelmq.bots.collectors.mail.collector_mail_url`: Fix import for Timeout exception preventing another exception (fixes #2555, PR#2556 by Sebastian Wagner).
26+
- `intelmq.bots.collectors.http.collector_http`: Log the downloaded size in bytes to ease troubleshooting (PR#2554 by Sebastian Wagner).
27+
- `intelmq.bots.collectors.mail.collector_mail_url`:
28+
- Log the downloaded size in bytes to ease troubleshooting (PR#2554 by Sebastian Wagner).
29+
- Fix import for Timeout exception preventing another exception (fixes #2555, PR#2556 by Sebastian Wagner).
2730

2831
#### Parsers
2932
- `intelmq.bots.parsers.shadowserver._config`:

intelmq/bots/collectors/http/collector_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def process(self):
9090
self.logger.debug('Response body: %r.', resp.text)
9191
raise ValueError('HTTP response status code was %i.' % resp.status_code)
9292

93-
self.logger.info("Report downloaded.")
93+
self.logger.info("Report downloaded (%sB).", len(resp.content))
9494

9595
# PGP verification
9696
if self.use_gpg:

intelmq/bots/collectors/mail/collector_mail_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def process_message(self, uid, message):
6767
if not resp.content:
6868
self.logger.warning('Got empty response from server.')
6969
else:
70-
self.logger.info("Report downloaded.")
70+
self.logger.info("Report downloaded (%sB).", len(resp.content))
7171

7272
template = self.new_report()
7373
template["feed.url"] = url

intelmq/tests/bots/collectors/http/test_collector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def test_gzip(self, mocker):
107107
output['feed.url'] = 'http://localhost/foobar.gz'
108108
del output['extra.file_name']
109109
self.assertMessageEqual(0, output)
110+
self.assertLogMatches('Report downloaded \(29B\).', 'INFO')
110111

111112
def test_zip_auto(self, mocker):
112113
"""

intelmq/tests/bots/collectors/mail/test_collector_url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ def test_fetch(self, mocker):
5656
with mock.patch('imbox.Imbox', new=MockedTxtImbox):
5757
self.run_bot()
5858
self.assertMessageEqual(0, REPORT_FOOBARTXT)
59+
self.assertLogMatches('Report downloaded \(9B\).', 'INFO')

0 commit comments

Comments
 (0)