I am working on a script to automate some of my phone\networking-related task. One of them being, mapping out phones and extensions to a network port. For example, x1001 with mac address for John Doe is in Room 1, and on the networking switch 1 on port1. I store room information in the Account Code section under the extension when the extension is created.
What I have been doing is going into bulk handler and manually downloading “extension” and “clearly devices” into a folder and parsing the data with my script.
My question is I want to automate the bulk handler part of this. Is there a to get the same type of information from the bulk handler from the command line?
asterisk -rx 'database show'
is what I am thinking but trying to see if there is an easier method I might be missing before I got down that route.
I am already using the arp table and MAC address table from the script to identify what MAC address is plugged into each port. But I need a way to identify x1001 belongs to John Doe with XXXX.YYYY.ZZZZ MAC address. My use case for this is if a user emails in saying my phone is not working. I can quick run my script identify John Doe is at x1001 and his phone is plugged into XX port on switch, then reboot the phone via switch. That usually fixes 90% of the problems.
I work for a school district so we have a lot of movement during the year.
Thanks for that, that would be one place to look for an extension and email address. What about cross-reference the extension to Mac address? I realized I am using the clearly IP module which might be in a different place, but for example, if it was for Endpoint manager instead?
Not familiar with either EPM or Clearly, but I assume that for either, the provisioning files , likely in /tftpboot , should provide that mapping from file name (mac address tied) and its content ( which would vary by phone hardware)
Most device manufacturers have a setting to add a MAC to the Useragent on a registered device, so you could query it directly from an extension that way.
@danielf currently I am pulling data from bulk handler export of extension are Extension, Name, email address, account code. I also pull Device which give me extension and MAC address. Lastly I gather which phone are currently online with ‘pjsip show endpoints’.
From there I have a script the parse all my switch nightly and maps the Mac addresses to port.
@danielf So I am manually pulling it from bulk handler exports CSV currently. My script will then parse the csv for the information I need. But I need to remember to pull this, since I am not the only one that uses this script or add/remove/modify extensions. I sometimes forgot to update the bulk handler info.
I am looking for help to do this in the cli, similar to the ‘pjsip show endpoints’ command, which I can add into my nightly script.
If you are using the EPM, the config files probably have most of the info you want. For example - for polycom phones the config files have the MAC address in the name, and the config file has the name and extension number in it. Then you could look up in the voicemail.conf file to get the email address.
Alternatively, look in the mysql DB for the things you want…
MAC addresses are baked into the phone, any relationship to an IP address is technically ephemeral unless you either hard-wire that in your DHCP service or your end point manager is demanding a particular one (which would be rash to say the least) I again suggest that the answer can be derived by locating the extension name in a particular config file resulting in an extension keyed to a mac-address in your arp-scan