virendra bhati
2011-Aug-24 13:16 UTC
[asterisk-users] How to know how many user is connected
Hi List, I want to know how many manager is connected into asterisk server. I have made simple file but I don't have any idea how to get information back from Asterisk CLI <?php $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30); if (!$socket) { $done=0; } else { fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: root\r\n"); fputs($socket, "Secret: energy\r\n\r\n"); fputs($socket, "Action: Command\r\n"); fputs($socket, "Command: manager show connected\r\n"); $done=1; } ?> Now how to get information into this PHP file.... ----- Thanks and regards Virendra Bhati +91-9172341457 Software Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110824/59bc2a9a/attachment.htm>
I'm not a php expert, but seems your php script is incomplete/ you are sending to socket (fputs) but note receiving anything(fgets) : See this page <http://www.voip-info.org/wiki/view/Asterisk+manager+Example:+PHP> will help you. From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of virendra bhati Sent: Wednesday, August 24, 2011 6:16 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] How to know how many user is connected Hi List, I want to know how many manager is connected into asterisk server. I have made simple file but I don't have any idea how to get information back from Asterisk CLI <?php $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30); if (!$socket) { $done=0; } else { fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: root\r\n"); fputs($socket, "Secret: energy\r\n\r\n"); fputs($socket, "Action: Command\r\n"); fputs($socket, "Command: manager show connected\r\n"); $done=1; } ?> Now how to get information into this PHP file.... ----- Thanks and regards Virendra Bhati +91-9172341457 Software Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110825/dce98043/attachment.htm>
virendra bhati
2011-Aug-25 13:02 UTC
[asterisk-users] How to know how many user is connected
Hi Ahmed, Just realized that maybe you?re talking about disconnecting any other AMI/manger connected user from another manager connection?hhmmm? I don?t think so. Check AMI commands from asterisk wiki. If not, you may need system command in your AMI connection to close some other socket * Yes I was looking for this :) *Please tell me how to close other socket from current sockets. one more thing in my case it may be possible that root 127.0.0.1 may be more then one then how to close them individually? * * On Thu, Aug 25, 2011 at 5:09 PM, Gohar Ahmed <gohar.ahmed at vopium.com> wrote:> Just realized that maybe you?re talking about disconnecting any other > AMI/manger connected user from another manager connection?hhmmm? I don?t > think so. Check AMI commands from asterisk wiki. If not, you may need system > command in your AMI connection to close some other socket. **** > > ** ** > > ** ** > > *From:* asterisk-users-bounces at lists.digium.com [mailto: > asterisk-users-bounces at lists.digium.com] *On Behalf Of *Gohar Ahmed > *Sent:* Thursday, August 25, 2011 4:25 PM > > *To:* 'Asterisk Users Mailing List - Non-Commercial Discussion' > *Subject:* Re: [asterisk-users] How to know how many user is connected**** > > ** ** > > What I understood: you need to disconnect the AMI socket.**** > > 1) I want to disconnect *connected manager* into Asterisk. Is it possible > ? ? Close the $socket after you get the response. **** > > ** ** > > What I understood: you need to maintain the socket until some button is > pressed to stop AMI > 2) I want to maintain this socket connection until we disconnect it from > web page. ? Close the $socket on particular action from web-page. This > one?s tricky btw maintain a while loop and break loop on a condition toggled > by web-page)**** > > See php section for other examples.**** > > http://www.voip-info.org/wiki/view/Asterisk+manager+Examples **** > > ** ** > > ** ** > > *From:* asterisk-users-bounces at lists.digium.com [mailto: > asterisk-users-bounces at lists.digium.com] *On Behalf Of *virendra bhati > *Sent:* Thursday, August 25, 2011 4:02 PM > > *To:* Asterisk Users Mailing List - Non-Commercial Discussion > *Subject:* Re: [asterisk-users] How to know how many user is connected**** > > ** ** > > Hi List, > > Thanks now I am able to get all values from asterisk CLI but I want 2 more > things . > > 1) I want to disconnect *connected manager* into Asterisk. Is it possible > ? > 2) I want to maintain this socket connection until we disconnect it from > web page.**** > > On Thu, Aug 25, 2011 at 1:57 PM, virendra bhati <virbhati at gmail.com> > wrote:**** > > Hi List, > > Thanks for guide me. Yes I know that CLI command , My motive is to get > information into Php that's why I am finding the solution. > > Ahmad Sir, You are right I forget to get information back from CLI to Php > file. Thanks for provide the help link.I will revert back after testing my > code with your guidance > **** > > On Thu, Aug 25, 2011 at 12:21 PM, DHAVAL INDRODIYA < > dhaval.it01034 at gmail.com> wrote:**** > > Hi > You can use simple cli command > Manager show connected**** > > > > On Thursday, August 25, 2011, James zhu <zhulizhong at live.com> wrote: > > hi: > > please refer this: > > http://www.voip-info.org/wiki/view/Asterisk+manager+Example:+PHP > > and check the manager.conf, make sure the accounts in managers.conf > matchs the managers displayed. > > > > Best regards, > > James.zhu > > Doing asterisk/PRI/ss7/dahdi, linux, asterisk cards, > gateway(fxs/fxo/pri<->SIP). > > website: www.voipviews.com > > > > > > ________________________________ > > From: gohar.ahmed at vopium.com > > To: asterisk-users at lists.digium.com > > Date: Thu, 25 Aug 2011 11:26:53 +0500 > > Subject: Re: [asterisk-users] How to know how many user is connected > > > > I?m not a php expert, but seems your php script is incomplete/ you are > sending to socket (fputs) but note receiving anything(fgets) : > >**** > > > See this page < > http://www.voip-info.org/wiki/view/Asterisk+manager+Example:+PHP> will > help you.**** > > > > > > > > > > > > > > From: asterisk-users-bounces at lists.digium.com [mailto: > asterisk-users-bounces at lists.digium.com] On Behalf Of virendra bhati > > Sent: Wednesday, August 24, 2011 6:16 PM > > To: Asterisk Users Mailing List - Non-Commercial Discussion > > Subject: [asterisk-users] How to know how many user is connected > > > > > > > > Hi List, > > > > I want to know how many manager is connected into asterisk server. I have > made simple file but I don't have any idea how to get information back from > Asterisk CLI > > > > <?php > > > > $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 30); > > if (!$socket) > > { > > $done=0; > > } else { > > fputs($socket, "Action: Login\r\n"); > > fputs($socket, "UserName: root\r\n"); > > fputs($socket, "Secret: energy\r\n\r\n"); > > fputs($socket, "Action: Command\r\n"); > > fputs($socket, "Command: manager show connected\r\n"); > > $done=1; > > } > > > > ?> > > > > Now how to get information into this PHP file.... > > > > ----- > > Thanks and regards > > > > Virendra Bhati > > +91-9172341457 > > Software Engineer > > > > > > > > -- _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New > to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE > or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users **** > > ** ** > > -- > _____________________________________________________________________**** > > > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users**** > > > > > -- **** > > > > > ----- > Thanks and regards > > Virendra Bhati > +91-9172341457 > Software Engineer**** > > ** ** > > > > > -- **** > > > > > ----- > Thanks and regards > > Virendra Bhati > +91-9172341457 > Software Engineer**** > > ** ** > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- ----- Thanks and regards Virendra Bhati +91-9172341457 Software Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110825/dc32854a/attachment-0001.htm>