Cisco IP Phone Inventory Script

**Disclaimer: Use all scripts  with caution. I am posting what I personally used. I am not responsible for any issues you may have with the use of the following script.

[divider]

Recently we came across an issue where we needed to verify all of our active IP Phones in the enterprise by serial number. There was no way that we could find to pull all of this information easily, so I got creative. I know we could have gone through each profile in CM to find it that way, or browsed to the web interface of each phone, but when you have a large amount of phones, that’s just not an option.

The following script is written in PHP. I tossed it on a web server and opened it in chrome. This script will go through and open the following URL for all addresses within a specified class-c network:

http://X.X.X.X/DeviceInformationX

This will return some XML data in this form. No authentication is needed to open this as long as HTTP services are enabled. This is my 7960 from my home voice lab:

<DeviceInformation>
<MACAddress>0015FA000000</MACAddress>
<HostName>SEP0015FA000000</HostName>
<phoneDN>100</phoneDN>
<appLoadID>P0030301MFG2</appLoadID>
<bootLoadID>PC0303010200</bootLoadID>
<versionID>3.1(MF.G2)</versionID>
<addonModule1/>
<addonModule2/>
<hardwareRevision>4.5</hardwareRevision>
<serialNumber>INM09000000</serialNumber>
<Codec>ADLCodec</Codec>
<Amps>5V Amp</Amps>
<C3PORevision>2</C3PORevision>
</DeviceInformation>

The script goes through and gathers this information for each address in the class C network of choice and then separates the “important” data for this specific cause. That includes the MAC Address, IP Address, and Serial Number. The output for the subnet is all displayed then right in the browser. There is no need to log in to each device or use any credentials. As long as the HTTP services are enabled on each phone and the URL above can be reached, you are good!

So here is the script in it’s entirety. Forgive me, I’m sure there may have been better ways to code this, but it works!

http://www.theroutingtable.com/download/cisco-ip-phone-inventory-script/

(It’s standard PHP and able to be edited easily if needed.)

In my case, I saved this as CM-serials.php. To actually run the script, I used the following url:

http://localhost/CM-serials.php?network=172.16.1

That will prompt the script to go through the 172.16.1.0/24 subnet for addresses. You change the three octets on the end of the URL to specify the specific network you are focusing on. If you have something larger than a /24, you can just run the scan in multiple different scans (/23, etc). Obviously this will only return data for phones that are on the network currently, so you may have to run at different times of the day to get all of your devices. Once completed, here is what the output will look like:

Script Output

Blacked out the identifying information for security, but you get the point. There are three columns displayed with the applicable information. From there, you can clean up the data in Excel or something like Notepad++ to get in the specific format that you might need.

 

If there are any issues with the script, let me know and I’d be happy to take a look at the script to see what’s up, just comment below.

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail
Kevin

Kevin

Cisco CCNP, Senior Network Engineer in the Healthcare Industry. Currently working on my CCIE R&S which is the focus of most of my latest blog posts. #NFD15 Delegate.

3 thoughts on “Cisco IP Phone Inventory Script

  • August 9, 2016 at 9:13 pm
    Permalink

    I was able to get the scrip to run on a Linux box, but the output it only IP Addresses. Serial Numbers and MAC Addresses are blank. Did I miss something?

    Robert

    Reply
  • August 10, 2016 at 1:04 pm
    Permalink

    I was able to run the script from a Linux server, however the output is only IP Addresses. I have not altered the code at all. Any ideas what the issue could be?

    Robert

    Reply
    • Kevin
      June 14, 2017 at 8:12 am
      Permalink

      Sorry, I missed this comment. Make sure that http access is enabled on your phones in callmanager. If that is not enabled then the script won’t be able to pull any data and only the IP addresses will be shown as you mentioned.

      Reply

Leave a Reply

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