Summary: | ASTERISK-00180: [patch] asterisk -rx "database show" produces short results | ||
Reporter: | John Todd (jtodd) | Labels: | |
Date Opened: | 2003-08-27 00:41:05 | Date Closed: | 2008-01-15 14:38:37.000-0600 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) netconsole.diff ( 1) netconsole1.patch ( 2) netconsole2.patch | |
Description: | Running a "database show" command from the command line execution syntax results in only partial results of what is in the database. ****** ADDITIONAL INFORMATION ****** I have several hundred lines in one of my Asterisk astdb's. I often wish to get a complete summary of the data in that database, and I was thinking that an easy way to do it would be typing: asterisk -rx "database show" >/tmp/somefile However, this results in random length sub-portions of the file being put into /tmp/somefile. Running without the redirection of output gives similar results. localhost*CLI> show version Asterisk CVS-08/11/03-18:21:29 built by root@localhost.localdomain on a i686 running Linux localhost*CLI> | ||
Comments: | By: Mark Spencer (markster) 2003-08-28 11:29:22 If the data is not read off the socket sufficiently quickly, then Asterisk will simply cut the writing short rather than stall the server. I could experiment with a slight delay but that could potentially introduce problems. By: John Todd (jtodd) 2003-08-28 12:58:34 I understand why the unexpected behavior is happening, but I also need to be able to get data out of the database on simple shell scripts. I don't know of anything faster than simple redirects from a shell, so some sort of padding or delay at the end of each line might be required. I'm open to any other way to access the data in the astdb from a shell script run out of cron without corrupting astdb. By: James Golovich (jamesgolovich) 2003-08-28 13:09:08 I've experienced the same problem in the past and when I was working on the code I could not find an acceptable way to handle it without causing worse problems. As an alternative, I know that using the Command action from the manager interface does not experience this problem. By: x martinp (martinp) 2003-09-11 15:42:13 Try to set 'hostname box' eg: less letters than 'localhost'. It's a bug related to the fact that in asterisk -r mode after you hit 'enter' the library first prints the CLI prompt and then prints the command output. However in the -c mode it's not done. I've been tracing it but can't find the source. By: John Todd (jtodd) 2003-09-11 16:48:38 Yes, changing the name to something short (like "box") does solve the symptoms. By: John Todd (jtodd) 2003-09-11 16:50:05 OK, I spoke too soon. It appears to solve it on the CLI, but asterisk -rx "database show" still fails with random length output, even with the short hostname. By: mman (mman) 2003-09-19 10:26:55 I have noticed that almost all asterisk -rx "a command" produce, some times, short results. I have solved (?) the problem with the following patch. Minor side effect: It prints two extra new lines after command completion to signal the end of command output. RCS file: /usr/cvsroot/asterisk/asterisk.c,v retrieving revision 1.22 diff -r1.22 asterisk.c 780c780 < if ((buf[res-1] == '\n') || (buf[res-2] == '\n')) { --- > if ((buf[res-1] == '\n') && (buf[res-2] == '\n')) { RCS file: /usr/cvsroot/asterisk/cli.c,v retrieving revision 1.9 diff -r1.9 cli.c 1010a1011 > ast_cli(fd, "\n\n"); By: John Todd (jtodd) 2003-09-19 14:54:32 Mic - this does in fact seem to solve the problem, sort-of. I was able to get a good output when running: asterisk -rx "database show" But, when I tried this command: asterisk -rx "datbase show" >/tmp/foo ...the process seemed to hang and I had to ctrl-c to exit. The data file had the content I expected, but for some reason the command just didn't seem to end correctly. Can you please take a look at that and see what you can do? Otherwise, this seems to be a good patch. Also: In the future, can you please use "diff -u" and attach your patches as files instead of in the notes? This makes it easier to track revisions and for the files to be moved around/managed. By: mman (mman) 2003-09-20 05:49:20 John, I 'll try it with commands that generate more output and see what I can do. May be Mark could advice if this is the right place (in asterisk.c, cli.c) to look for this problem. Sorry for the inline patch. I guess it was too small to redirect it into a file and attach it. By: mman (mman) 2003-09-24 13:55:28 The uploaded file (netconsole.patch) is the previously sent patch but with a timeout inside the select (waiting for activity on the fds). There are situations where the command has executed but the connection remains open (don't know why). I believe that the timeout in select should exist, even without this problem, just to ensure that the connection will be terminated after a certain amount of inactivity. By: Brian West (bkw918) 2003-12-02 20:41:06.000-0600 Fixed in CVS By: Brian West (bkw918) 2003-12-02 22:21:53.000-0600 This breaks tab completion.. and causes extra \n's By: Brian West (bkw918) 2003-12-02 22:22:38.000-0600 mic can you take a look at this again? By: mman (mman) 2003-12-03 06:46:17.000-0600 The problem is caused by the lack of a safe way to determine the end of the command's results. I added the two extra newlines for this reason but it doesn't work always. I 'll check it again. By: mman (mman) 2003-12-03 11:42:20.000-0600 OK, here is a working patch (netcosole1.patch). No extra newlines, working tab completion, "-rx" returns full results without hanging. I have done some limited testing and it seems to be OK. Please check it before merging it into CVS. Michael Manousos. By: jjanzer (jjanzer) 2003-12-08 12:58:50.000-0600 Hi, I added another patch, after downloading mic's patch. Basically it just fixes a very small compiler error/warning, in which you declared and set a variable after the functions variables had been declared and after using various code. Just makes it a little more c compliant. FILE: netconsole2.patch By: Brian West (bkw918) 2003-12-08 13:16:12.000-0600 netconsole.diff has both patches in it. By: Brian West (bkw918) 2003-12-08 13:17:54.000-0600 Still has a problem.. I shouldn't see that -- Remote UNIX connection message and have to press enter. Anyway to fix that? I'm so used to getting the prompt right off and now I have to press enter to get it. Asterisk CVS-12/08/03-13:06:29, Copyright (C) 1999-2001 Linux Support Services, Inc. Written by Mark Spencer <markster@linux-support.net> ========================================================================= Connected to Asterisk CVS-12/08/03-13:06:29 currently running on asterisk (pid = 6109) -- Remote UNIX connection asterisk*CLI> By: Brian West (bkw918) 2004-01-11 03:55:42.000-0600 Seems fixed in cvs By: jrollyson (jrollyson) 2004-01-11 03:56:01.000-0600 I get a full database from a -rx 'database show' By: Digium Subversion (svnbot) 2008-01-15 14:38:37.000-0600 Repository: asterisk Revision: 1817 U trunk/asterisk.c U trunk/cli.c ------------------------------------------------------------------------ r1817 | markster | 2008-01-15 14:38:36 -0600 (Tue, 15 Jan 2008) | 2 lines Minor patch for improving console response with asterisk -r (bug ASTERISK-180) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=1817 |