Author Topic: Statistics PSDK CurrentState for Agent  (Read 11357 times)

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Statistics PSDK CurrentState for Agent
« on: February 02, 2015, 04:44:48 PM »
Hello, I´d like to know how to query the current state for an agent in order to know if he/she is Ready/NotReady/AfterCallWork for different medias.

Also how to know if the agent is logged in or not at all.

Thanks in advance for any information

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Statistics PSDK CurrentState for Agent
« Reply #1 on: February 02, 2015, 05:08:04 PM »
Try to use Statistic with Category "CurrentTargetState" or "CurrentState".
« Last Edit: February 03, 2015, 08:57:15 AM by Kubig »

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #2 on: February 02, 2015, 08:10:01 PM »
Thanks that worked, I cannot filter status per media though.

I get status 4 for ready, 8 for not ready and 9 for acw, do you know if there is any documentation or Enum for interpreting theese numbers?

Thanks

Offline Janis

  • Full Member
  • ***
  • Posts: 123
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #3 on: February 03, 2015, 07:40:34 AM »
4 WaitForNextCall (Ready)
5 OffHook
6 CallDialing
7 CallRinging
8 NotReadyForNextCall
9 AfterCallWork
13 CallOnHold
16 ASM_Engaged
17 ASM_Outbound
18 CallUnknown
19 CallConsult
20 CallInternal
21 CallOutbound
22 CallInbound
23 LoggedOut

Offline Janis

  • Full Member
  • ***
  • Posts: 123
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #4 on: February 03, 2015, 07:44:50 AM »
We are using following stat to get detailed information about agent state:

Category=CurrentState
MainMask=*
Objects=Agent
Subject=DNAction

You should get list of all active actions by media. Do filtering in your code.

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Statistics PSDK CurrentState for Agent
« Reply #5 on: February 03, 2015, 01:24:53 PM »
You monitor the DNS associated to the Place associated to the agent, not the agent itself

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #6 on: February 03, 2015, 01:41:40 PM »
I see, I´ll look into it, thank you all. BTW janisk where did you get that list from?

Offline Janis

  • Full Member
  • ***
  • Posts: 123
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #7 on: February 03, 2015, 02:58:59 PM »
The List comes from StatServer Deployment guide where the STATUS Table is described.

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #8 on: February 03, 2015, 04:12:24 PM »
Thanks

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #9 on: February 03, 2015, 04:20:43 PM »
I´ve managed to obtain the desired result using janisk´s stat definition with a RequestOpenStatisticEx.

The only problem is that I´m using the deprecated DnActionMask class, is there any alternative to it?

Thank you all

Code:

RequestOpenStatisticEx request =
RequestOpenStatisticEx.create();

StatisticObject object = StatisticObject.create();
object.setObjectId("MCR_Agent0");
object.setObjectType(StatisticObjectType.Agent);
object.setTenantName("Environment");
object.setTenantPassword("");

Notification notification = Notification.create();
notification.setMode(NotificationMode.Periodical);
notification.setFrequency(2);

DnActionMask mainMask = ActionsMask.createDNActionsMask();
mainMask.setBit(DnActions.WaitForNextCall);
mainMask.setBit(DnActions.CallDialing);
mainMask.setBit(DnActions.CallRinging);
mainMask.setBit(DnActions.NotReadyForNextCall);
mainMask.setBit(DnActions.CallOnHold);
mainMask.setBit(DnActions.CallUnknown);
mainMask.setBit(DnActions.CallConsult);
mainMask.setBit(DnActions.CallInternal);
mainMask.setBit(DnActions.CallOutbound);
mainMask.setBit(DnActions.CallInbound);
mainMask.setBit(DnActions.LoggedOut);

DnActionMask relMask = ActionsMask.createDNActionsMask();

StatisticMetricEx metric = StatisticMetricEx.create();
metric.setCategory(StatisticCategory.CurrentState);
metric.setMainMask(mainMask);
metric.setRelativeMask(relMask);
metric.setSubject(StatisticSubject.DNAction);
metric.setTimeProfile("Default");
metric.setIntervalType(StatisticInterval.GrowingWindow);

request.setStatisticMetricEx(metric);

request.setNotification(notification);
request.setStatisticObject(object);

RESULT:
[INFO,StatServerProtocol,2015-02-03 13:17:07,077] - com.genesyslab.PCT.invoker:149 - 'EventInfo' (2) attributes:
VOID_VALUE [object] = ObjectValue: AgentStatus {
  AgentId = MCR_Agent0
  LoginId = 7003
  Status = 4
  Time = 1230848819
  Place = PlaceStatus {
    PlaceId = SIP_Server_Place9
    PlaceStatus = 4
    Time = 1230848819
    DnStatuses = DnStatusesCollection (size=3) [
      [0] DnStatus {
        DN Id = 7009
        SwitchId = SIP_Switch
        GSW DN TYPES = 1
        DN Status = 4
        Time = 1230848428
        Actions = DnActionCollection (size=1) [
          [0] DnAction {
            Action = WaitForNextCall
            Time = 1230848428
            ActionDataType = CallData
            ConnectionId = 0000000000000000
            DNIS = null
            ANI = null
            UserData = null
          }
        ]
      }
      [1] DnStatus {
        DN Id = chat
        SwitchId = null
        GSW DN TYPES = 0
        DN Status = 4
        Time = 1230848819
        Actions = DnActionCollection (size=1) [
          [0] DnAction {
            Action = WaitForNextCall
            Time = 1230848819
            ActionDataType = CallData
            ConnectionId = 0000000000000000
            DNIS = null
            ANI = null
            UserData = KVList:
'MediaType' [str] = "chat"
          }
        ]
      }
      [2] DnStatus {
        DN Id = email
        SwitchId = null
        GSW DN TYPES = 0
        DN Status = 8
        Time = 1230848814
        Actions = DnActionCollection (size=1) [
          [0] DnAction {
            Action = NotReadyForNextCall
            Time = 1230848814
            ActionDataType = CallData
            ConnectionId = 0000000000000000
            DNIS = null
            ANI = null
            UserData = KVList:
'MediaType' [str] = "email"
'ReasonCode' [str] = "Break"
          }
        ]
      }
    ]
  }
}


Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: Statistics PSDK CurrentState for Agent
« Reply #10 on: February 04, 2015, 09:09:07 AM »
Statistic PSDK is not deprecated - may be you are using old version of specific library.

Offline gstkein

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 4
Re: Statistics PSDK CurrentState for Agent
« Reply #11 on: February 05, 2015, 04:50:55 PM »
I´ve fixed it, what was marked as deprecated was "DnActionMask mainMask = ActionsMask.createDNActionsMask(); "

I just replaced that for it´s parent class since there was no difference between both and it worked.

RequestOpenStatisticEx request =
RequestOpenStatisticEx.create();

StatisticObject object = StatisticObject.create();
object.setObjectId(agentEmployeId);
object.setObjectType(StatisticObjectType.Agent);
object.setTenantName(tenantName);
object.setTenantPassword("");


Notification notification = Notification.create();
notification.setMode(NotificationMode.Immediate);


DnActionsMask mainMask = new DnActionsMask();
mainMask.setBit(DnActions.WaitForNextCall);
mainMask.setBit(DnActions.CallDialing);
mainMask.setBit(DnActions.CallRinging);
mainMask.setBit(DnActions.OffHook);
mainMask.setBit(DnActions.NotReadyForNextCall);
mainMask.setBit(DnActions.CallOnHold);
mainMask.setBit(DnActions.CallUnknown);
mainMask.setBit(DnActions.CallConsult);
mainMask.setBit(DnActions.CallInternal);
mainMask.setBit(DnActions.CallOutbound);
mainMask.setBit(DnActions.CallInbound);
mainMask.setBit(DnActions.LoggedOut);

DnActionsMask relMask = new DnActionsMask();

StatisticMetricEx metric = StatisticMetricEx.create();
metric.setCategory(StatisticCategory.CurrentState);
metric.setMainMask(mainMask);
metric.setRelativeMask(relMask);
metric.setSubject(StatisticSubject.DNAction);
metric.setTimeProfile("Default");
metric.setIntervalType(StatisticInterval.GrowingWindow);

request.setStatisticMetricEx(metric);

request.setNotification(notification);
request.setStatisticObject(object);

Offline callmevijayc

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Re: Statistics PSDK CurrentState for Agent
« Reply #12 on: July 07, 2015, 11:35:28 PM »
Any have idea how to get the statistics for statistics category CurrentTargetState. I am getting result for  statistics category currentState but not for CurrentStatetrager

Offline RobertH

  • Jr. Member
  • **
  • Posts: 69
  • Karma: 1
Re: Statistics PSDK CurrentState for Agent
« Reply #13 on: August 06, 2015, 02:07:11 PM »
You need to open stat and subscribe for updates. "StatisticCategory.CurrentTargetState" is different from others, you can't peek it.
Reason is that, if you will query long list of objects, it may cause stat server performance HIT.

So use of this stat is:
- open
- it gets current values for all objects (HIT)
- it is getting deltas on each objects on state change

your application must add stat server event handler and handle updates for this stats.

On Open:
Message= 'EventStatisticOpened' (22) attributes:
TM_LENGTH [int] = 0
LONG_VALUE [int] = 0
USER_REQ_ID [int] = -1
TM_SERVER [int] = 1438869600
REQ_ID [int] = 1
Message= 'EventCurrentTargetStateSnapshot' (17) attributes:
TM_LENGTH [int] = 0
USER_REQ_ID [int] = -1
LONG_VALUE [int] = 0
CURRENT_TARGET_STATE_INFO [CurrentTargetState] = CurrentTargetStateSnapshot (size=1) [
    [0] CurrentTargetStateInfo {


On change state (be aware: Not Ready to NotReady - Reason is not change state for this stat)
Message= 'EventCurrentTargetStateTargetUpdated' (19) attributes:
CURRENT_TARGET_STATE_DELTA [CurrentTargetState] = CurrentTargetStateDelta

[code]
RequestGetStatisticEx req = RequestGetStatisticEx.create();
StatisticObject object = StatisticObject.create();
object.setObjectId("agentusername");
object.setObjectType(StatisticObjectType.Agent);
object.setTenantName("Environment");
object.setTenantPassword("");

StatisticMetricEx statisticMetricEx = StatisticMetricEx.create();
statisticMetricEx.setCategory(StatisticCategory.CurrentTargetState);
statisticMetricEx.setSubject(StatisticSubject.AgentStatus);
ActionsMask actMask = ActionsMask.createDNActionsMask();
ActionsMask relMask = ActionsMask.createDNActionsMask();

statisticMetricEx.setMainMask(actMask);
statisticMetricEx.setRelativeMask(relMask);
statisticMetricEx.setIntervalLength(10);
statisticMetricEx.setIntervalType(StatisticInterval.GrowingWindow);


req.setStatisticObject(object);
req.setStatisticMetricEx(statisticMetricEx);

                Notification notification = Notification.create();
notification.setMode(NotificationMode.Immediate);

RequestOpenStatisticEx reqo = RequestOpenStatisticEx.create();
reqo.setNotification(notification);
reqo.setStatisticObject(object);
reqo.setStatisticMetricEx(statisticMetricEx);

try {
statServerProtocol.send(reqo);

} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
[code][/code]

Offline escarneiro

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Statistics PSDK CurrentState for Agent
« Reply #14 on: July 20, 2017, 06:02:21 PM »
How do someone find the Tenant Name ? What is it at all ?