Perl POE programs (for the Asterisk manager?) hang Linux

I have recently been experimenting with the Perl Object Environment. It’s a neat event-driven framework that builds on top of Perl. I started using it for the Perl Asterisk manager interface.

I started using the Asterisk manager as a way to get information out of Asterisk and to display on the LCD on my system. The POE component is much easier than coding up something in Expect, and it’s a wondeful standardized layer for catching events. I’ve been experimenting with a POE program that displays the number of waiting voicemails on the LCD panel. Here’s the core of the program, which essentially says that when the manager indicates a new waiting voicemail, call the voicemail_state_handler procedure, and when there is a voicemail status report, call the voicemail_status_state_handler procedure.

POE::Component::Client::Asterisk::Manager->new(
Alias => ‘vm-monitor’,
Username => ‘user’, # not real!
Password => ‘secret’, # also not real!
CallBacks => {
input => ‘:all’,
voicemail => {
‘Event’ => ‘MessageWaiting’,
},
voicemail_status => {
‘Response’ => ‘Success’,
‘Message’ => ‘Mailbox Message Count’,
},
},
inline_states => {
input => \&input_state_handler,
voicemail => \&voicemail_state_handler,
voicemail_status => \&voicemail_status_state_handler,
},
);

POE::Kernel->run();

I’ve also experimented with programs that report other Asterisk data, or even programs that tick off a clock for display on an LCD. What they all have in common is that eventually, the system will lock up. Hard. Nothing responds, not even the attached monitor. I haven’t done any detailed diagnosis, but I can’t figure out what might cause the computer to just hang hard. The best I have for a working theory at this point is that the POE loop isn’t correctly freeing objects and is exhausting system memory to the point where a critical system task is interrupted, but that’s just a working theory.

Leave a Reply