Ahmed Munir
2012-Sep-18 19:41 UTC
[asterisk-users] Trigger Asterisk after data inserted in mysql
Hi all, I would like to know, is there a way to trigger Asterisk after data inserted into mysql DB? Like here what I'm trying to do, when the new data inserted into MySQL DB, it sends the request to Asterisk along with the new data (that is inserted in DB) for making outbound call i.e. Realtime. Currently I've set a cron job that execute my script every 30 seconds and checks for a new data in DB. If new data is inserted in 30 seconds that script will run and sends the data to Asterisk for making calls. (This is the case which I'm thinking to avoid) Please advise. -- Regards, Ahmed Munir Chohan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120918/723c350e/attachment.htm>
James Sharp
2012-Sep-18 20:09 UTC
[asterisk-users] Trigger Asterisk after data inserted in mysql
On 9/18/2012 3:41 PM, Ahmed Munir wrote:> Hi all, > > > I would like to know, is there a way to trigger Asterisk after data > inserted into mysql DB? Like here what I'm trying to do, when the new > data inserted into MySQL DB, it sends the request to Asterisk along with > the new data (that is inserted in DB) for making outbound call i.e. > Realtime. > > Currently I've set a cron job that execute my script every 30 seconds > and checks for a new data in DB. If new data is inserted in 30 seconds > that script will run and sends the data to Asterisk for making calls. > (This is the case which I'm thinking to avoid) > > Please advise.You could create a trigger in mysql that calls a shell script that pokes Asterisk properly. Look here for a start: http://forums.mysql.com/read.php?99,170973,236208#msg-236208
David Cook
2012-Sep-19 18:04 UTC
[asterisk-users] Trigger Asterisk after data inserted in mysql
It looks like the answer is yes. http://crazytechthoughts.blogspot.ca/2011/12/call-external-program-from-mysql.html From the page, here is code to execute a UDF library and call a shell. Clearly there would be a heavy penalty to launching a shell so you would want to carefully evaluate the frequency this is executed on your system. | DELIMITER @@| |CREATE| |TRIGGER| |Test_Trigger | |AFTER| |INSERT| |ON| |MyTable | |FOR| |EACH ROW | |BEGIN| |||DECLARE| |cmd ||CHAR||(255);| |||DECLARE| |result ||int||(10);| |||SET| |cmd=CONCAT(||'sudo /home/sarbac/hello_world '||,||'Sarbajit'||);| |||SET| |result = sys_exec(cmd);| |END||;| |@@| |DELIMITER ; | -dbc> Message: 1 > Date: Tue, 18 Sep 2012 15:41:46 -0400 > From: Ahmed Munir <ahmedmunir007 at gmail.com> > Subject: [asterisk-users] Trigger Asterisk after data inserted in > mysql > To: asterisk-users at lists.digium.com > Message-ID: > <CAGMN=JdbE5FdDSQXxZ9OrWXu3Pvgc-hj-EnPxUrG=RJHGSD-eg at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hi all, > > > I would like to know, is there a way to trigger Asterisk after data > inserted into mysql DB? Like here what I'm trying to do, when the new data > inserted into MySQL DB, it sends the request to Asterisk along with the new > data (that is inserted in DB) for making outbound call i.e. Realtime. > > Currently I've set a cron job that execute my script every 30 seconds and > checks for a new data in DB. If new data is inserted in 30 seconds that > script will run and sends the data to Asterisk for making calls. (This is > the case which I'm thinking to avoid) > > Please advise. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120919/f7589552/attachment.htm>
Bryant Zimmerman
2012-Sep-19 18:30 UTC
[asterisk-users] Trigger Asterisk after data inserted in mysql
David The way we do this is to have a trigger insert into a batch table. This table can be polled from a secondary process. That process/service is responsible for monitoring, working and cleanup. This allows for you to poll a highly optimized table without taking the db performance hit from larger tables that will grow over time. We process millions of cdr and process records a day this way. It also allows you balanced process loads across multiple servers. This can be extremely important on systems that are more heavily loaded. It also allows you to remove process load and latencies from the database servers. Thanks Bryant Zimmerman (ZK Tech Inc.) 616-855-1030 Ext. 2003 ---------------------------------------- From: "David Cook" <dbc_asterisk at advan.ca> Sent: Wednesday, September 19, 2012 2:04 PM To: asterisk-users at lists.digium.com Subject: Re: [asterisk-users] Trigger Asterisk after data inserted in mysql It looks like the answer is yes. http://crazytechthoughts.blogspot.ca/2011/12/call-external-program-from-mysq l.html
C. Savinovich
2012-Sep-19 20:44 UTC
[asterisk-users] Trigger Asterisk after data inserted in mysql
<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;"><div>Hello David,</div><div><br></div><div>>>><span>If you're going to top-post (which is against the rules on this list),<span id="GD__CURSOR"> </span></span></div><div><br></div><div>I apologize if mistaken, but out of curiosity, can you please refer me to where in the rules it says that we can not top-post in this list?</div><div><br></div><div>Thanks<br></div><div><br></div><div>Christian Savinovich</div><div><strong><em>VoIP & Telephony Consultant</em></strong></div><div>646-982-3572</div><div> </div><div><br><br></div> <blockquote id="replyBlockquote" webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px; font-size:10pt; color:black; font-family:verdana;"> <div id="wmQuoteWrapper"> -------- Original Message --------<br> Subject: Re: [asterisk-users] Trigger Asterisk after data inserted in<br> mysql<br> From: Chad Wallace <<a href="mailto:cwallace@lodgingcompany.com">cwallace@lodgingcompany.com</a>><br> Date: Wed, September 19, 2012 4:30 pm<br> To: <a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a><br> <br> On Wed, 19 Sep 2012 14:04:33 -0400<br> David Cook <<a href="http://dbc_asterisk@advan.ca">dbc_asterisk@advan.ca</a>> wrote:<br> <br>> It looks like the answer is yes.<br><br> I thought the answer was 42.<br> <br> If you're going to top-post (which is against the rules on this list),<br> the least you can do is phrase your answers in a way that illustrates<br> the question.<br> <br> Thanks!<br> <br> <br> -- <br> <br> C. Chad Wallace, <a href="http://B.Sc">B.Sc</a>.<br> The Lodging Company<br> <a href="http://www.lodgingcompany.com">http://www.lodgingcompany.com</a>/<br> OpenPGP Public Key ID: 0x262208A0<br> <br> <br> --<br> _____________________________________________________________________<br> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com">http://www.api-digital.com</a> --<br> New to Asterisk? Join us for a live introductory webinar every Thurs:<br> <a href="http://www.asterisk.org/hello">http://www.asterisk.org/hello</a><br> <br> asterisk-users mailing list<br> To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br> </div> </blockquote></span></body></html>
C. Savinovich
2012-Sep-19 21:24 UTC
[asterisk-users] Trigger Asterisk after data inserted in mysql
<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;"><div><span>>>>If you're going to top-post (which is against the rules on this list), <br> </span></div><div><span><br></span></div><div><span> I agree with you. Just really wanted to locate where it was defined.<br></span></div><div><br></div><div>Christian Savinovich</div><div><strong><em>VoIP & Telephony Consultant</em></strong></div><div>646-982-3572</div><div> </div><div><br><br></div> <blockquote id="replyBlockquote" webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px; font-size:10pt; color:black; font-family:verdana;"> <div id="wmQuoteWrapper"> -------- Original Message --------<br> Subject: Re: [asterisk-users] Trigger Asterisk after data inserted in<br> mysql<br> From: Chad Wallace <<a href="mailto:cwallace@lodgingcompany.com">cwallace@lodgingcompany.com</a>><br> Date: Wed, September 19, 2012 5:14 pm<br> To: <a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a><br> <br> On Wed, 19 Sep 2012 13:44:47 -0700<br> "C. Savinovich" <<a href="http://c.savinovich@itntelecom.com">c.savinovich@itntelecom.com</a>> wrote:<br> <br>> Hello David,<br> > <br> > >>>If you're going to top-post (which is against the rules on this<br> > >>>list), <br> > <br> > I apologize if mistaken, but out of curiosity, can you please refer<br> > me to where in the rules it says that we can not top-post in this<br> > list?<br><br> It's understandable that many are unaware of the rules, since it took<br> some hunting for me to find them again. They aren't mentioned at all on<br> any of the mailman pages at <a href="http://lists.digium.com">lists.digium.com</a>. The rules can be found<br> here:<br> <br> <a href="http://www.asterisk.org/community/rules">http://www.asterisk.org/community/rules</a><br> <br> Anyway, there are many who like to top-post, and I'm not interested in<br> a holy war.<br> <br> I just wanted to point out that if you want to top-post, it may be<br> worthwhile to consider ways to minimize the impact--like phrasing the<br> answer so that the question is immediately apparent, and you don't force<br> your readers to scroll down, possibly dodging signatures, disclaimers,<br> pasted logs, and dragons, just to get to the question being answered.<br> <br> <br> <br>> -------- Original Message --------<br> > Subject: Re: [asterisk-users] Trigger Asterisk after data inserted in<br> > mysql<br> > From: Chad Wallace <<a href="http://cwallace@lodgingcompany.com">cwallace@lodgingcompany.com</a>><br> > Date: Wed, September 19, 2012 4:30 pm<br> > To: <a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a><br> > <br> > On Wed, 19 Sep 2012 14:04:33 -0400<br> > David Cook <<a href="http://dbc_asterisk@advan.ca">dbc_asterisk@advan.ca</a>> wrote:<br> > <br> > > It looks like the answer is yes.<br> > <br> > I thought the answer was 42.<br> > <br> > If you're going to top-post (which is against the rules on this list),<br> > the least you can do is phrase your answers in a way that illustrates<br> > the question.<br> > <br> > Thanks!<br> > <br> > <br> > --<br> > <br> > C. Chad Wallace, <a href="http://B.Sc">B.Sc</a>.<br> > The Lodging Company<br> > <a href="http://www.lodgingcompany.com">http://www.lodgingcompany.com</a>/<br> > OpenPGP Public Key ID: 0x262208A0<br> > <br> > <br> > --<br> > _____________________________________________________________________<br> > -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com">http://www.api-digital.com</a> --<br> > New to Asterisk? Join us for a live introductory webinar every Thurs:<br> > <a href="http://www.asterisk.org/hello">http://www.asterisk.org/hello</a><br> > <br> > asterisk-users mailing list<br> > To UNSUBSCRIBE or update options visit:<br> > <a href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br><br> <br> -- <br> <br> C. Chad Wallace, <a href="http://B.Sc">B.Sc</a>.<br> The Lodging Company<br> <a href="http://www.lodgingcompany.com">http://www.lodgingcompany.com</a>/<br> OpenPGP Public Key ID: 0x262208A0<br> <br> <br> --<br> _____________________________________________________________________<br> -- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com">http://www.api-digital.com</a> --<br> New to Asterisk? Join us for a live introductory webinar every Thurs:<br> <a href="http://www.asterisk.org/hello">http://www.asterisk.org/hello</a><br> <br> asterisk-users mailing list<br> To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br> </div> </blockquote></span></body></html>
Ahmed Munir
2012-Sep-21 21:52 UTC
[asterisk-users] Trigger Asterisk after data inserted in MySQL
Thanks Bryant and David for sharing.> From: "Bryant Zimmerman" <BryantZ at zktech.com> > Subject: Re: [asterisk-users] Trigger Asterisk after data inserted in > mysql > To: "Asterisk Users Mailing List - Non-Commercial Discussion" > <asterisk-users at lists.digium.com> > Message-ID: <4d5734ed$7d50d85e$77bd1cd6$@zktech.com> > Content-Type: text/plain; charset="us-ascii" > > David > > The way we do this is to have a trigger insert into a batch table. This > table can be polled from a secondary process. That process/service is > responsible for monitoring, working and cleanup. This allows for you to > poll a highly optimized table without taking the db performance hit from > larger tables that will grow over time. We process millions of cdr and > process records a day this way. It also allows you balanced process loads > across multiple servers. This can be extremely important on systems that > are more heavily loaded. It also allows you to remove process load and > latencies from the database servers. > > Thanks > > Bryant Zimmerman (ZK Tech Inc.) > 616-855-1030 Ext. 2003 > > ---------------------------------------- > From: "David Cook" <dbc_asterisk at advan.ca> > Sent: Wednesday, September 19, 2012 2:04 PM > To: asterisk-users at lists.digium.com > Subject: Re: [asterisk-users] Trigger Asterisk after data inserted in > mysql > > It looks like the answer is yes. > > > http://crazytechthoughts.blogspot.ca/2011/12/call-external-program-from-mysq > l.html > > >From the page, here is code to execute a UDF library and call a shell. > Clearly there would be a heavy penalty to launching a shell so you would > want to carefully evaluate the frequency this is executed on your system. > > DELIMITER @@ CREATE TRIGGER Test_Trigger AFTER INSERT ON MyTable FOR > EACH ROW BEGIN DECLARE cmd CHAR(255); DECLARE result int(10); SET > cmd=CONCAT('sudo /home/sarbac/hello_world ','Sarbajit'); SET result > sys_exec(cmd); END; @@ DELIMITER ; > > -dbc > > Message: 1 Date: Tue, 18 Sep 2012 15:41:46 -0400 From: Ahmed Munir > <ahmedmunir007 at gmail.com> Subject: [asterisk-users] Trigger Asterisk after > data inserted in mysql To: asterisk-users at lists.digium.comMessage-ID: > <CAGMN=JdbE5FdDSQXxZ9OrWXu3Pvgc-hj-EnPxUrG> RJHGSD-eg at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" Hi all, I would like to > know, is there a way to trigger Asterisk after data inserted into mysql DB? > Like here what I'm trying to do, when the new data inserted into MySQL DB, > it sends the request to Asterisk along with the new data (that is inserted > in DB) for making outbound call i.e. Realtime. Currently I've set a cron > job that execute my script every 30 seconds and checks for a new data in > DB. If new data is inserted in 30 seconds that script will run and sends > the data to Asterisk for making calls. (This is the case which I'm thinking > to avoid) Please advise. > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://lists.digium.com/pipermail/asterisk-users/attachments/20120919/b8c396a7/attachment.htm > > > > ------------------------------ >-- Regards, Ahmed Munir Chohan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120921/cd0772dc/attachment.htm>