Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for reading from stdin and dumping db to a file #25

Merged
merged 5 commits into from Apr 1, 2014

Conversation

mcortizo
Copy link
Contributor

If the only access you have to the log is via cat or tail from ssh connection, the script will need reading from stdin.
And maybe you want backup in a file the data you're printing.

@lebinh
Copy link
Owner

lebinh commented Mar 30, 2014

Thanks, reading from stdin is a really good idea but I don't think another parameter is needed. Maybe some thing like -l stdin is enough? I'd definitely merge that.
For db dump, the purpose of ngxtop is to enable a real-time understanding of what's happening with nginx, so I'm not sure a db dump would be needed here. Do you have any use case for that? Otherwise the changes to add that db dump functionality, which relied on a global variable and too tightly coupled with the SQLProcessor implementation, would make the code harder to change later on.

@mcortizo
Copy link
Contributor Author

First, I agree with you about db dump; I had the idea but no use cases, and perhaps it is not the best way to do it...
About reading from stdin, I tried with the option-l stdin but I got an error: IOError: [Errno 2] No such file or directory: 'stdin' after trying to locate the nginx pid and config. It seems that the script looks for a file named 'stdin' instead of reading from stdin.
Also, this way you don't need to install nginx to analyze remote or local logs.

@lebinh
Copy link
Owner

lebinh commented Mar 31, 2014

Yup, what I mentioned is that it'd be great if we can use -l stdin instead of another option, like -s in your pull request. So if you can modify your commit, I'd gladly merge it :)

@mcortizo
Copy link
Contributor Author

Thanks, I've removed the -s option and it is not necessary to specify an option, as the script detects the redirection as a non-tty input :)

@halcolm
Copy link

halcolm commented Mar 31, 2014

great addition! 👍

@lebinh lebinh merged commit 1c200d5 into lebinh:master Apr 1, 2014
@LaiJingli
Copy link

Hi,good job.
but when i try to analyze remote nginx access log,for example "ssh 192.168.0.110 tail -f /var/log/nginx/hog-access.log | ngxtop" ,i have also make ssh no password login works first,but it's report:"Error: access log file "stdin" does not exist",it's like the pipe done'nt work? my ngxtop is the newest.

@lebinh
Copy link
Owner

lebinh commented Apr 2, 2014

Silly me, pushed the fix for that. Can you try it again with latest commit?

@LaiJingli
Copy link

hei,lebinh
the remote analyze has fixed with your recommit,thks for your fast reponse! but when run a few seconds later ,it will stop to work and report an error as follow ( like this issue #23):
"Traceback (most recent call last):
File "/usr/local/bin/ngxtop", line 11, in
sys.exit(main())
File "build/bdist.linux-x86_64/egg/ngxtop/ngxtop.py", line 495, in main
File "build/bdist.linux-x86_64/egg/ngxtop/ngxtop.py", line 463, in process
File "build/bdist.linux-x86_64/egg/ngxtop/ngxtop.py", line 357, in process_log
File "build/bdist.linux-x86_64/egg/ngxtop/ngxtop.py", line 305, in process
sqlite3.ProgrammingError: library routine called out of sequence"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants