How to automatically extract data from an Avaya Communication Manager

You might call this post “the secret of my success” as a PBX admin for Avaya Communication Manager. Avaya provides some utilities for their techs and business partners, but customers don’t really have a lot of tools to easily extract data. In this post, I’ll show you how to extract ANYTHING from Avaya from a command line so it’s suitable for scripting. In my case, I parse the data further and generate a list of all stations and report of changes to my PBX every 15 minutes. Have you ever wondered who used to have extension 4438? How about that phone for the intern over the summer named “Bodkin Van Horn” that you deleted but now he has been hired and you want to give him the same extension? How about the question “how long has this extension been unplugged”?

Back in mid 00s, I wrote some PHP integrate with CM using telnet. Since I didn’t know much about PHP’s ANSI support, I ended up writing my own ANSI parser of the raw data. Anyway, it was great, but many customers don’t support telnet and want all communication to CM to be through ssh, which is reasonable, right?

Then I found this post from Benjamin Roy where he provided a perl module to do it through ssh. Also, he meticulously reverse-engineered Avaya’s OSSI protocol, which I think is impressive and sounds like fun. But I didn’t use OSSI; I just wanted a way to get data using ssh. So I took Ben’s code and tweaked it a little bit. It’s straight perl code – it’s not a module or anything like that. It does have dependencies on a couple other modules though. You do not need to be a perl developer to use this. It’s really easy. Here is a link to the script. Just save this as “av.pl”. Try to run it with “perl -c av.pl” (the -c means just check to make sure it compiles but do not run it). You might get some errors about missing modules. There are only three, and this is how you install them if you need to:

perl -MCPAN -e "install Expect"
perl -MCPAN -e "install Data::Dumper"
perl -MCPAN -e "install Term::VT102"

I should probably mention here – if you don’t have a Linux server in your environment, you should really get one. Your Virtual Machine team can make one for you – just about any distribution of Lunux will do and they take almost no resources. If you need to justify it, just say something like “utility server for PBX monitoring” or something like that.

Anyway, back to the script. Naturally, it needs to connect to your PBX, so create a little text file like “mypbx.txt” with the contents

10.10.40.89,5022,cmusername,Passw0rd,ssh

Obviously, replace the IP address, username, and password of your PBX.

And then create another file called “commands.txt” with the contents

list trunk
display station 3100

This can contain whatever commands you’d like. list reg, list station, list trunk, list locations, list measurements, stat cdr, etc. It should be any command that can be “paged” through, you know?

And then simply run this line

perl av.pl mypbx.txt commands.txt

The script will connect to the PBX defined in mypbx.txt, run the commands in commands.txt and output the results to STDOUT!

This is the core script to a bunch of stuff I automate in my PBXs. In a later post, I’ll show you how I parse the results with Perl and make use of the data.

I call this “the secret of my success” because I use this data to build a simple html page of all extensions in all of my PBXs every 15 minutes. I keep this page up all the time in a browser tab, which enables me to simply “control-f” for any name in the PBX and I have the extension number and the IP address of the station (or ‘unregistered’ if it’s unplugged). I can see unregistered ‘guest’ numbers, see the station’s history, etc. There’s a lot more I do with this information and I look forward to showing you.

Please let me know what you think! And if there’s anything I can do to help you get it working.

Lastly, if any of you need to do any telephone system testing (capacity, QA, DID number ports, call-flow, queuing, etc), please check out my post about CallsByCloud. If you sign up and use the promotion code ‘roger2015’, you’ll get $10 in credit and a 20{0ed28e3470e974017c124b0897303dd14e34b5245564abb28916e7d48d9b07c0} discount on the per-minute rate.

Also, if you hate unsolicited outbound telemarketing, consider subscribing to the Jolly Roger Telephone Company. Your telemarketers will entertain and delight you. Sample recordings here.

Thanks all!

Roger

 

42 thoughts on “How to automatically extract data from an Avaya Communication Manager

  1. Janelle

    I am assuming this can be put and run on any pre-exsisting Linux server? Have quite a few that do nothing other than function for Avaya in some way.

    Reply
    1. roger Post author

      Yes definitely. The only issue might be installing the perl modules. I have never tried on the Avaya Utility Server, for example. You might need to install the CPAN module before the rest. And Avaya may not want you to load up their pre-installed appliances like that.

      Reply
        1. roger Post author

          Oh I’m SO GLAD you got it working! That makes me very happy.

          You probably know that you can redirect STDOUT to a file with a ‘>’, for example

          perl av.pl mypbx.txt commands.txt >/home/roger/pbx-stuff.txt

          Or, to append to the file, use >>

          perl av.pl mypbx.txt commands.txt >>/home/roger/pbx-stuff.txt

          But you can also show it to the screen with the linux ‘tee’ command

          perl av.pl mypbx.txt commands.txt | tee /home/roger/pbx-stuff.txt

          To append to the file, use the -a option:

          perl av.pl mypbx.txt commands.txt | tee -a /home/roger/pbx-stuff.txt

          This will display to the screen and write to the file.

          I have more stuff for you!

          Reply
  2. Janelle

    This is fabulous! I can’t wait to see more posts. I have to admit, I know nothing about PERL, but I was able to get this all set up.

    Reply
  3. Tom Truty

    Hi Roger,

    Just starting with your blog and it’s really awesome! Would you mind to share where you find this script most useful, i.e. sharing your commands.txt content?
    I can guess list stations, status of stations, trunks’ etc but I can imagine the possibilities are infinite and it might take years to find them all ;0)

    Cheers
    Tom

    Reply
    1. roger Post author

      Oh thank you Tom! Yes, I will share that in my next article, including a script to parse the output into something useful. But you are right about the list station, etc. What I do is list station and list reg. And then merge the two so I see all stations, their IP address firmware version, region, and call server. This lets me see unregistered IP stations, which is really useful when people need a guest extension for a visitor.

      Reply
  4. Nestor

    Hi Roger,

    This post is awesome. Thank you very much to share with us. Just a quick question about the script. Can we use this script to add, change or remove users? If yes, do you have an example that we can use?

    Thanks again.

    Nestor

    Reply
    1. roger Post author

      Yes! I have used it for this, but it didn’t always work when changing data on back pages. It worked fine for changes on page 1 (like the station name). But I tried to use it once for changing some site info on page 4 and it didn’t always work. Remember Procomm? I miss Procomm scripts. I wonder if there’s still a community of Procomm users and Aspect scripters? That scripting language was awesome!

      Reply
  5. ivan

    Hi,

    I have it working, but I have a issue, I have several reports scheduled from cron, and in the same day, when it should run 6 times a day it only stores data from 2 or 3 reports, the rest is as if the script had not executed the command or would not have been able to store it, has ever happened to you?

    Thanks and greets.

    Reply
  6. Mehul

    Just following up to see if you ever got around to posting an article on how to parse this output? And maybe ‘recommended’ commands to run in this script?

    Thanks for putting this together

    Reply
      1. Mehul

        Thanks! I got your email notification from earlier today when you posted the article. I started working on a shell script to parse the data. I will definitely check out your perl script!

        Reply
  7. Pingback: How to parse Avaya Communication Manager output into useful csv or database tables | Roger the Phone Guy

  8. Aaron S.

    Roger,

    Very cool, I am working with netmiko and some other perl modules to do some similar discovery.
    Drop me a line, I have something to share with you 🙂
    – Aaron

    Reply
  9. Alex

    Hey Roger,

    Thanks for the script, should be pretty useful IMO. Do you have a GitHub repo for this and other scripts? That would make collaboration easier if somebody would like to contribute.

    Also as a suggestion, you might want to use App::FatPacker to make distributable copies of your scripts with all the dependencies from CPAN bundled in. I wish I knew about this thing back when I did Avaya stuff, would have made my life a lot easier. 🙂

    Regards,
    Alex.

    Reply
    1. roger Post author

      OMG Dwalin??? You are my hero!!! Email me at roger@rogerthephoneguy.com so I can praise you more! I read your blog. Well, I have it in my news feed but I don’t think I have seen anything from you in a long time. I’m so flattered that you found this post! You don’t do Avaya stuff anymore?

      Reply
      1. Alex

        Please, don’t make me blush. 🙂 Sent you an email, let’s keep in touch.

        And no I don’t do Avaya stuff anymore, well, at least actively. That’s a long story. 🙂

        Regards,
        Alex.

        Reply
  10. italo

    Hi, Roger great web site ,,,,am looking for Mac address the all hard phone on my Avaya system, i have the CM versio 6.3 . in avaya site administrator or web admin.. no there are command to extract the mac adders all phone running, any resource or any idea to get that information, thera any scrtip for that

    thank for you excellent colaboration

    Reply
    1. roger Post author

      Sorry I missed this, Italo. You can get the MAC address from the “status station”

      I have a PHP script that does this. I have to find it. It does a “list station” and then a subsequent “status station” for each one. Then a perl script parses the output. There are probably easier ways to do it. I stopped using it years ago. Would you like to see it? Do you know PHP? It’ll take some tweaking to get it working in your environment.

      Reply
  11. Sooraj Kumar

    hi mr roger ,

    Seems like you are really a good programmer and do scripting …
    could you please share with me the script for login to communication manager-telnet and perform some commands like create a station , remove a station etc ….highly appreciate your support ..we are really in need for that …we are uisng avaya aura communication manager 7..Kindly provide your contact details too..

    Reply
  12. Pingback: How to Parse Avaya Communication Manager data to a database for analysis – Part 3 | Roger the Phone Guy

  13. Tom Lynn

    Roger,
    A quick note from another phone guy!

    Users should be aware that putting your password into a text file need to consider the security implications. They will need to either secure the file by change it’s permissions so that only they and perhaps root can read the file, or they can do away with the requirement by creating an ssh key and pushing it to the communication manager server. Telnet folks, please upgrade. you know you need to.
    Here’s a link to a short article that shows how this is done from the linux command line.

    https://www.howtogeek.com/168147/add-public-ssh-key-to-remote-server-in-a-single-command/

    If you have duplex servers, please remember that you’ll have to push your public key to both servers individually. If you push it to PROCR address, you’ll only be addressing the active server.

    Reply
  14. Tom Lynn

    One more thought on the keyfile, you just leave the password portion of the mypbx.txt file empy like this:
    IPADDRESS,5022,userid,,ssh

    two commas after userid

    Reply
  15. Babu

    Hi Rojer, Is there any script which we can be executed it from windows 10 machine instead of Linux server.

    I have gone through your script, it has content what exactly i wanted, but we don’t have any linux box to use it.

    IF you share some script which can be executed from Windows 10 machine that would be grateful….

    Reply
    1. roger Post author

      I gave up on Windows because of the SSH requirement. I had a ton of PHP scripts that could do it over telnet. Is telnet enabled in your Avaya? If so, you could install PHP on Windows. Someone earlier said they got the script working using cygwin, which is a linux environment. Also, Windows 10 has a linux subsystem now, but I’ve never tried it.

      I suppose Python might be able to do it. But I’m WAY too new at Python to attempt it. I love perl.

      Reply
  16. liquidvw

    Thank you for this. This is very cool and was easy to follow. So after setting this up on linux, I was determined to make this work on windows using Cygwin. The process was very similar except that I needed to install Expect.pm from here: https://metacpan.org/pod/release/RGIERSIG/Expect-1.21/Expect.pod
    Then install openSSH from the cygwin installer.

    Now my question. Looking to do something simple like ‘disp ala’. The output I get is always 0. I’m assuming I need to run the command ‘disp ala’, then ‘enter’ then ‘f3’. How do you put ‘f3’ in the commands file?

    Reply
    1. roger Post author

      There’s a way in the script. But my sample script was w2ktt, which doesn’t require F keys, does it? I’m away from my Avaya so I’m going on memory. But you can send F keys in the ANSI terminal. I think F3 is just char 27 and then OR.

      This from https://unix.stackexchange.com/questions/53581/sending-function-keys-f1-f12-over-ssh

      F1 ^[OP
      F2 ^[OQ
      F3 ^[OR
      F4 ^[OS
      F5 ^[[15~
      F6 ^[[17~
      F7 ^[[18~
      F8 ^[[19~
      F9 ^[[20~
      F10 ^[[21~
      F11 ^[[23~
      F12 ^[[24~

      Reply
  17. liquidvw

    Thanks for this. After running this on a linux box, I wanted to see it work on a Windows box using Cygwin. Your steps are pretty much the same for Windows except I needed to install expect.pm and openssh.

    My question is this. How do you run the command ‘disp ala’ as its necessary to press F3 after you run the command. How do you pass the F3 via the commands file?

    Reply
  18. liquidvw

    Tried running ‘disp alarms’, but it returns “0”. How do you run command ‘disp ala’ then run ‘f3’ to enter the 2nd screen?

    Reply
  19. Suresh Tenneti

    Hey Roger,

    Need your help in building an automation script that does MACD work on Avaya. We are trying to automate the MACD work. Let me know, if you have any suggestions or sample works or point me into the right direction.

    You can mail me @: suresh.tenneti@gmail.com

    Reply
  20. Holger

    Hi Roger,

    I’m rather new to Avaya but working on a compliance check against CM using NASL/Nessus. Wonder if awk is available on the stripped down RH Linux CM is based on?

    Reply
    1. roger Post author

      Did you get your answer. I’m so sorry I missed this. Yes, awk appears to be available. Along with vi, grep, and other “standard” tools you’d expect.

      Reply
  21. Heron

    Hi Roger,

    Very good article, I am using ZOC7 with REXX language to get all the content that I need and works fine.
    I have a question for you: Do you have a code example to do “list media-gateway” then based on the reply do a “display media-gateway xx” ?

    Reply
  22. Heron Leal

    If any of you guys are having issues when installing perl CPAN, try this:

    sudo apt-get install gcc
    sudo apt-get install build-essential

    sudo perl -MCPAN -e shell
    install Expect
    install Data::Dumper
    install Term::VT102

    Reply
  23. Dheeraj Grover

    Hi Roger,
    Getting below while installing missing modules.
    Kindly help me for fix this.
    thanks in advance
    ==========================================================

    [5/27/2020 9:26:41 AM] dgrover@QORBLVSIACM02> perl -MCPAN -e “install Expect”
    [5/27/2020 9:26:41 AM] CPAN: Storable loaded ok
    [5/27/2020 9:26:42 AM] Going to read /var/home/dgrover/.cpan/Metadata
    [5/27/2020 9:26:42 AM] Warning: Found only 0 objects in /var/home/dgrover/.cpan/Metadata
    [5/27/2020 9:26:42 AM] CPAN: LWP::UserAgent loaded ok
    [5/27/2020 9:26:42 AM] Fetching with LWP:
    [5/27/2020 9:26:42 AM] ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    [5/27/2020 9:27:21 AM] LWP failed with code[500] message[LWP::Protocol::MyFTP: Bad hostname ‘ftp.perl.org’]
    [5/27/2020 9:27:21 AM] Fetching with Net::FTP:
    [5/27/2020 9:27:21 AM] ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    [5/27/2020 9:28:01 AM]
    [5/27/2020 9:28:01 AM] Trying with “/usr/bin/wget -O -” to get
    [5/27/2020 9:28:01 AM] ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    [5/27/2020 9:28:01 AM] –2020-05-27 09:28:01– ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
    [5/27/2020 9:28:01 AM] => `-‘
    [5/27/2020 9:29:22 AM] Resolving http://ftp.perl.org... failed: Temporary failure in name resolution.
    [5/27/2020 9:29:22 AM] wget: unable to resolve host address `ftp.perl.org’
    [5/27/2020 9:29:22 AM]
    [5/27/2020 9:29:22 AM] System call “/usr/bin/wget -O – “ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz” > /var/home/dgrover/.cpan/sources/authors/01mailrc.txt”
    [5/27/2020 9:29:22 AM] returned status 1 (wstat 256)
    [5/27/2020 9:29:22 AM] Warning: expected file [/var/home/dgrover/.cpan/sources/authors/01mailrc.txt.gz] doesn’t exist
    [5/27/2020 9:29:22 AM] Issuing “/usr/bin/ftp -n”
    [5/27/2020 9:30:41 AM] ftp: http://ftp.perl.org: Temporary failure in name resolution
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Local directory now /var/home/dgrover/.cpan/sources/authors
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Not connected.
    [5/27/2020 9:30:41 AM] Bad luck… Still failed!
    [5/27/2020 9:30:42 AM] Can’t access URL ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz.
    [5/27/2020 9:30:42 AM]
    [5/27/2020 9:30:43 AM] Please check, if the URLs I found in your configuration file () are valid.
    [5/27/2020 9:30:43 AM] The urllist can be edited. E.g. with ‘o conf urllist push ftp://myurl/
    ================================================================================

    Reply
    1. roger Post author

      Sometimes modules depend upon other binaries, but this one is new to me. The log shows failure in name resolution though. Can you ping http://ftp.perl.org from that box?

      I also came across this. Apparently there’s a bundle that includes all dependencies, although CPAN is supposed to handle that too:

      perl -MCPAN -e ‘install Bundle::Expect’

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *