Dynamic agents unavailable

Hello,

I’ve been having a strange problem where my dynamic queue agents go to Unavailable status.

  Dave (Local/[email protected]/n) (dynamic) (Unavailable) has taken no calls yet

This only seems to occur on my agents that have multiple devices. This seems to occur when one device is not logged in.

I’ve dug through the forum and checked everything I could find. The preload module lines seems to be the most popular culprit but I do have those in my modules.conf. Couple other options I’ve seen mentioned are USEDEVSTATE and USEQUEUESTATE which are set to TRUE and FALSE.

Running the latest 2.8 FreePBX on Asterisk 1.4.35 with the Devstate patch.

Any input would be appreciated.

Thanks,
Dave

it does work and the users logging on and off also works.

Something is not right with your system, and in particular, if you are finding the #exec line in your code then it’s up to your Asterisk configuration to be operating properly since as you can see, the script does run.

I’m not saying there can’t be any bugs since there are always plenty hiding themselves in any program, but I don know the fundamentals work so you probably need to dig a bit deeper into your specific configuration. For starters, get it to work with the generage_hints.php script.

Sigh… I hate semicolons.

Just because I feel the need to publicize my idiocy, and in case anyone else happens to have a config with the same problem.

When adjusting your options in asterisk.conf to enable execincludes make sure the entire [options] section isn’t commented.

;[options]

was my problem.

:frowning:

color coded syntax editors are your friend :slight_smile:

Patch cleared the warning but not the problem. However, I do have the exact problem figured out. Just not a solution.

Starting from DYNAMICHINTS=false with all devices fixed hints are created and everything works fine. If I switch to DYNAMICHINTS=true with a default user on the device adhoc extensions will not function correctly until I clear the user entries from the device in astdb.

/DEVICE/8008/user : 8008

Once I set that to an empty string that adhoc user will be able to login ONCE if their extension is set as a default on the device. After that *12 just says goodbye, and *11 will say already logged in on the console. If the device has no default extension set everything works correctly until asterisk is restarted. Once asterisk is restarted no hints are created. If a device has a user entry in the astdb it will have to be *12’d before it can login.

so for a short recap.

DYNAMICHINTS false = Everything works
DYNAMICHINTS true, default adhoc user set = hints lost on reboot, nothing works anyways
DYNAMICHINTS true, no default adhoc user set = hints lost on reboot, need to *12 the device to work after.

Something seems broken with default adhoc extensions, and it sounds like generate_hints.php is not executing on asterisk startup. I did find it in extensions_addition.conf in one location.

[ext-local]
include => ext-local-custom
#exec /var/lib/asterisk/bin/generate_hints.php nointercom

and execincludes = yes in asterisk.conf

I’m beginning to know way to much about the internal workings on this thing. :stuck_out_tongue:

/var/lib/asterisk/bin/generate_hints.php does generate hints with a PHP warning which I’m assuming is because I manually called it.

PHP Notice: Undefined variable: dialstring in /var/lib/asterisk/bin/generate_hints.php on line 96
exten => 8002,hint,SIP/8002&SIP/80021

I did have the agents dynamically logging in and out. It allowed them to bring their extension with them to the office which was nice. That started acting up and I had them stop. The feature is just completely broken now and I haven’t been able to figure out why.

If I set DYNAMICHINTS=true all the ext-local hints disappear. I switched all my devices to adhoc and tried to login and get a console message of already logged in. I then logout and try again and get the same message. No ext-local hints are generated.

Tried the usual trick of re-saving the device and user and still no go.

Not sure what’s going on at this point but everything appears to be working fine with DYNAMICHINTS=false and the devices set to fixed extensions.

you probably have your php warnings up to high which could cause other problems.

The undefined variable is technically a bug and it’s possible that the warning being set as you do when in production could be causing problems.

you can try applying this patch to it and see if the warning goes away and if so, if your system starts to work:


Index: generate_hints.php
===================================================================
--- generate_hints.php	(revision 10463)
+++ generate_hints.php	(working copy)
@@ -91,6 +91,7 @@
 		global $ast_with_dahdi;
 
 		$device_array = explode( '&', $devices );
+		$dialstring = '';
 		foreach ($device_array as $adevice) {
 			$dds = $astman->database_get('DEVICE',$adevice.'/dial');
 			$dialstring .= $dds.'&';

If it still doesn’t work and the warnings are gone, then there’s still an issue in your system.

I just checked in that change, r10602, though it is not published yet.

The DYNAMICHINTS capability was explicitly implemented to deal with users logging in and out in cases where you may be subsequently restarting Asterisk from the CLI or when Asterisk is restarted where otherwise you would end up with bogus state information since these hints are dynamically updated and thus need to be determined any time Asterisk is started or otherwise reloads the dialplan. (Otherwise you are stuck with what things looked like the last time you pressed the Apply Configuration Bar next time a reload/restart occurs…

if you are dynamically logging in/out of devices then you want to have DYNAMICHINTS=true set.

If that is failing for you then something is wrong somewhere.

the following command (assuming a standard installation path) will let you manually test if the script is working or not:

/var/lib/asterisk/bin/generate_hints.php

you should see a chunk of dialplan spit out. I would suggest determining why that is broken, whether you need that setting set or not, since there may be other issues on your system that you are not aware of if that is not working.

Also - if that was broken, lots of other things on your system were probably not working right as well…

if you have the patch installed properly you should not get an invalid for the agent states, my best guess is something is not going right with the patch.

When properly patched, the state of the agent should be identical to the state of the associated ‘hint’ which you can see by typing ‘show hints’ at the CLI, as that is exactly what the patch does, it just retrieves the value of this hint.

So, check the hint and make sure it does not also have issues.

The [email protected] hints were missing. I had DYNAMICHINTS=true set which seems to be the reason. Switched it to false and everything is now working correctly.

If I’m understanding the description of that it should generate the hints on asterisk startup via an #exec call in the config to generate_hints.php. “grep ‘#exec’ *” returns no such line.

Hmm… I do have that patch, however, I disabled USEQUEUESTATE because of a different problem.

When USEQUEUESTATE is enabled my agents often end up with an invalid status.

Dave (Local/[email protected]/n) (Invalid) has taken no calls yet

The only way I’ve found to clear that is to disable USEQUEUESTATE. This user also has 2 devices.

I’ve been creating the second devices for users that want to have a softphone for their laptops. I was using one device, however, users would forget to unplug their hardphone and calls would end up being directed to the last device that registered.

If you have agents with multiple devices then there is likely not an ‘easy’ fix right now.

The current dialplan tries to use one of the agent’s devices as its status and if the device it picks is unavailable, that is going to reflect in the agents overall status.

The best fix for your issue is patch Asterisk with the patch referenced with USEQUEUESTATE in amportal.conf and set that to TRUE, I believe this is the link:

https://issues.asterisk.org/view.php?id=15168

Then the state of the agent will be determined based on the hint which incorporates all devices that are logged in. (The issue you are having is one of the key points why the patch was developed but unfortunately Asterisk delayed the introduction of the HINT state until Asterisk 1.8 and never back ported it to 1.4 like they should have since there “state” fix they put in 1.4 and 1.6 never fully fixed the problem it was intended to fix as you are finding out.)

The good news is you are running 1.4 so you should be able to patch your Asterisk and get this hint functionality.

(note - if you choose to just move to Asterisk 1.8, I think they expect the hint to be lowercase (hint: instead of HINT:). That has been updated in the code since the above patch is case insensitive, but it may not be published yet in which case you could simply pull down the queue’s functions.inc.php file and replace yours with it.