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% 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

 

19 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. 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

Leave a Reply

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