Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reliably Extract Realtime Data From CMS Supervisor 1

Status
Not open for further replies.

Bucky101

IS-IT--Management
Feb 9, 2006
419
AU
Hey,
I have an acsauto script driven by a .bat file driven by a scheduled task set to run every minute, to extract the realtime data to csv.
It will run successfully for a number of minutes to hours but then it will halt with a Message Box Error of "Attempt to Access Invalid Address".
This unfortunately will halt the .bat and it will not recover without intervention.

How can I better improve the resiliency of this process?
Is there any official manual on the acsauto scripting?





everyminute.bat
Code:
taskkill /F /IM ACS* /T 
taskkill /F /IM acs* /T

rem Running the realtime report
start /WAIT "" "H:\Agent Group Realtime\AGR.acsauto"

AGR.acsauto
Code:
'LANGUAGE=ENU 
'SERVERNAME=1.2.3.4

Public Sub Main()

On Error Resume Next

dtvar = Now
dvar = year(dtvar)&right("0"&month(dtvar),2)&right("0"&day(dtvar),2)
tvar = right("0"&Hour(dtvar),2)&right("0"&Minute(dtvar),2)
minvar = right("0"&Minute(dtvar),2)
fnvar = dvar&tvar

cvsSrv.Reports.ACD = 2
Set Info = cvsSrv.Reports.Reports("Real-Time\Agent\Agent Group Report")

   If Info Is Nothing Then
        If cvsSrv.Interactive Then
              MsgBox "The report Real-Time\Agent\Agent Group Report was not found on ACD 2.", vbCritical Or vbOKOnly, "Avaya CMS Supervisor"
        Else
              Set Log = CreateObject("ACSERR.cvsLog") 
              Log.AutoLogWrite "Real-Time\Agent\Agent Group Report was not found on ACD 2"
              Set Log = Nothing
              
        End If
   Else

      b = cvsSrv.Reports.CreateReport(Info,Rep)
      Rep.TimeZone = "UTC"
      Rep.SetProperty "Agent Group","AG1"
      b = Rep.ExportData("H:\Documents\Agent Group Realtime\AG1 - "&fnvar&".csv", 44, 1, False, True, True)

      b = cvsSrv.Reports.CreateReport(Info,Rep)
      Rep.TimeZone = "UTC"
      Rep.SetProperty "Agent Group","AG2"
      b = Rep.ExportData("H:\Documents\Agent Group Realtime\AG2 - "&fnvar&".csv", 44, 1, False, True, True)

      b = cvsSrv.Reports.CreateReport(Info,Rep)
      Rep.TimeZone = "UTC"
      Rep.SetProperty "Agent Group","AG3"
      b = Rep.ExportData("H:\Documents\Agent Group Realtime\AG3 - "&fnvar&".csv", 44, 1, False, True, True)

      b = cvsSrv.Reports.CreateReport(Info,Rep)
      Rep.TimeZone = "UTC"
      Rep.SetProperty "Agent Group","AG4"
      b = Rep.ExportData("H:\Documents\Agent Group Realtime\AG4 - "&fnvar&".csv", 44, 1, False, True, True)


Rep.Quit

' Kills active report & server
If Not cmsServer.Interactive Then
cmsServer.ActiveTasks.Remove cmsReport.TaskID
cmsApplication.Servers.Remove cmsServer.ServerKey
End If

' Logs out
cmsReport.Quit
cmsConnection.Logout
cmsConnection.Disconnect
cmsServer.Connected = False

' Releases objects
Set cmsReport = Nothing
Set cmsCatalog = Nothing
Set cmsConnection = Nothing
Set cmsServer = Nothing
Set cmsApplication = Nothing

Set Info = Nothing

End If

End Sub

 
I had a similar program in excel (vba). It ran for months at a time with no issue. Let me see if I can find it. Just out of curiosity, when you get the real time data, what do you do with it?

Your script looks fine, the error has more to do with your H drive I think. "Attempt to Access Invalid Address" typically means that the script is trying to access a resource or perform an action that it cannot complete due to an invalid address or destination. My assumption is access to your H drive is bouncing. As a test, change it to a local c: drive, run it for a day and see if you get the error.
 
I am then using a powershell script to INSERT the data into a database which is then visualised nicely in a BI tool along side other data relating to this campaign.
No its not the disk as the script itself is also on H: - Its the same behavior as below, I think its relating to too many sessions but I have no idea why it just suddenly falls over after running for hours

 
Okay, let's tackle this assuming there is a resource leak somewhere. First, let's move your objects into a sub so they can be declared and released. This will help ensure that resources are properly cleaned up, preventing memory leaks.

Second, let's beef up your error handling.

Third, let's reuse the objects better.

Try the code below -- it should be more efficient because the objects are declared once and reused rather than re-declared with each run of AG1 through AG4. And the error handling is better because it is now focused on process clean up and logic errors.

EDITED: Forgot to add in your CMS Closure statements.

Code:
'LANGUAGE=ENU 
'SERVERNAME=1.2.3.4

Dim Info
Dim Rep

Public Sub Main()
    On Error Resume Next

    Dim dtvar, dvar, tvar, minvar, fnvar
    dtvar = Now
    dvar = Year(dtvar) & Right("0" & Month(dtvar), 2) & Right("0" & Day(dtvar), 2)
    tvar = Right("0" & Hour(dtvar), 2) & Right("0" & Minute(dtvar), 2)
    minvar = Right("0" & Minute(dtvar), 2)
    fnvar = dvar & tvar

    If Info Is Nothing Then
        Set Info = cvsSrv.Reports.Reports("Real-Time\Agent\Agent Group Report")
        If Info Is Nothing Then
            If cvsSrv.Interactive Then
                MsgBox "The report Real-Time\Agent\Agent Group Report was not found on ACD 2.", vbCritical Or vbOKOnly, "Avaya CMS Supervisor"
            Else
                Set Log = CreateObject("ACSERR.cvsLog")
                Log.AutoLogWrite "Real-Time\Agent\Agent Group Report was not found on ACD 2"
                Set Log = Nothing
            End If
        End If
    End If

    If Not Info Is Nothing Then
        If Rep Is Nothing Then
            Set Rep = cvsSrv.Reports.CreateReport(Info, Rep)
            Rep.TimeZone = "UTC"
        End If

        ExportAndCleanup Rep, "AG1", fnvar
        ExportAndCleanup Rep, "AG2", fnvar
        ExportAndCleanup Rep, "AG3", fnvar
        ExportAndCleanup Rep, "AG4", fnvar

        Rep.Quit

        ' Kills active report & server
        If Not cmsServer.Interactive Then
            cmsServer.ActiveTasks.Remove cmsReport.TaskID
            cmsApplication.Servers.Remove cmsServer.ServerKey
        End If

        ' Logs out
        cmsReport.Quit
        cmsConnection.Logout
        cmsConnection.Disconnect
        cmsServer.Connected = False

        ' Releases objects
        Set cmsReport = Nothing
        Set cmsCatalog = Nothing
        Set cmsConnection = Nothing
        Set cmsServer = Nothing
        Set cmsApplication = Nothing

        Set Info = Nothing
    End If

    On Error Resume Next ' Error handling for object cleanup
    On Error GoTo 0 ' Disable error handling
End Sub

Sub ExportAndCleanup(ByRef Rep, ByVal AgentGroup, ByVal fnvar)
    Dim b
    If Not Rep Is Nothing Then
        Rep.SetProperty "Agent Group", AgentGroup
        b = Rep.ExportData("H:\Documents\Agent Group Realtime\" & AgentGroup & " - " & fnvar & ".csv", 44, 1, False, True, True)
    End If
End Sub
 
So, I was thinking about your code and problem over lunch. I have VBA code that does what you're doing but I've stepped away from VBA in favor of Python lately. I was thinking: why not use python. Python is a far better language than cScript/vbScript used by Avaya CMS Supervisor and python will allow you to write directly to your database without opening and closing (4) excel/csv docs every minute.

I'll take a look this weekend and see what I can come up with.

 
Hey SoftwareRT,

Thanks, that would be awesome. However full disclosure, due to network and system permission constraints the reason I am using Powershell is because this environment is heavily locked down and I cannot install anything.
I am actually using powershell to grab the csv file created by VBA and via a webclient library, POST the contents of the csv to an API which then recieves the contents and does the INSERT (which is actually in PHP FYI but that doesn't matter here)

The reason I am using VBA Script is because its native to this Avaya process. I do not have the skills to create a powershell or python script to load the Avaya libraries and executables to do what it needs to do - plus I cannot find any documentation about the Avaya CMS Scripting
If I could directly interface to Avaya CMS, pull down the realtime reporting data and then POST it to my API - that would be amazing.
 
Okay, so you're really locked down on what you can load onto your systems...And as far as I know, there isn't a way to get real-time reporting data from CMS (There are third party programs and something called clint -- but I've never had any luck getting clint to work).

I found my VBA and it's similar to the one I uploaded earlier, hopefully that VBA is running consistently.

Other progress: I attempted to program the CMS cvs libraries into powershell and python, both struggle with the 32Bit .dlls. So, I'm down to one option: Opening CMS in Putty via python paramiko and getting the info from the connection. I'll give that a try tomorrow.

If I build out python, can your run python at your location?

Chas
 
Hey Chas,

No I wouldn't be able to so perhaps dont waste your time but I do appreciate the effort.

I have 'stabalized' the report extraction by adjusting the scheduled .bat - now running every 2 minutes

Code:
TASKKILL /F /IM ACScript.exe
TASKKILL /F /IM acsRep.exe
TASKKILL /F /IM ACSTrans.exe
TASKKILL /F /IM acsApp.exe
TASKKILL /F /IM acsSRV.exe
taskkill /F /IM ACS* /T
taskkill /F /IM acs* /T


rem Running the realtime report
start "" "H:\Documents\Agent Group Realtime\AGR - Multi.acsauto"

echo %TIME%

timeout /t 90 /nobreak > NUL

powershell.exe -ExecutionPolicy RemoteSigned -File "H:\Documents\Agent Group Realtime\postreport1.ps1"

TASKKILL /F /IM ACScript.exe
TASKKILL /F /IM acsRep.exe
TASKKILL /F /IM ACSTrans.exe
TASKKILL /F /IM acsApp.exe
TASKKILL /F /IM acsSRV.exe
taskkill /F /IM ACS* /T
taskkill /F /IM acs* /T


Basically its a hack but is able to workaround what ever bug is causing the intermittant popup of "Attempt to Access Invalid Address"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top