lebinh / ngxtop

Real-time metrics for nginx server
MIT License
6.48k stars 473 forks source link

Improper field splitting for a record #24

Open pfigue opened 10 years ago

pfigue commented 10 years ago

Invocation like: $ ngnxtop -l path_to/my_access.log

The acces.log has a normal format, like in nginx.conf: "access_log path_to/my_access.log;"

running for 10 seconds, 0 records processed: 0.00 req/sec

Summary: | count | avg_bytes_sent | 2xx | 3xx | 4xx | 5xx | |---------+------------------+-------+-------+-------+-------| | 0 | | 0 | 0 | 0 | 0 |

Detailed:

Traceback (most recent call last): File "/usr/local/bin/ngxtop", line 9, in load_entry_point('ngxtop==0.0.1', 'console_scripts', 'ngxtop')() File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 446, in main process(args) File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 429, in process total = process_log(source, pattern, processor, arguments) File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 334, in process_log total = processor.process(records) File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 281, in process for r in records: File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 215, in add_field for item in dict_sequence: File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 205, in map_field for item in dict_sequence: File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 205, in map_field for item in dict_sequence: File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 215, in add_field for item in dict_sequence: File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 215, in add_field for item in dict_sequence: File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 206, in map_field item[field] = func(item.get(field, None)) File "/usr/local/lib/python2.7/dist-packages/ngxtop/ngxtop.py", line 245, in to_int return int(value) if value and value != '-' else 0 ValueError: invalid literal for int() with base 10: '"Mozilla/5.0 (X11; Ubuntu;'

lebinh commented 10 years ago

This seems to be the case when you have some records with different format in your access log file. Also could be ngxtop wrongly detect your log format. Can you give me the output of ngxtop info?

pfigue commented 10 years ago

configuration file: /etc/nginx/nginx.conf access log file: /var/log/foobar/nginx/generic-access-time.log access log format: $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_time $upstream_response_time $upstream_cache_status $upstream_addr available variables: body_bytes_sent, remote_addr, remote_user, request, request_time, status, time_local, upstream_addr, upstream_cache_status, upstream_response_time