Skip to content

Instantly share code, notes, and snippets.

@andrewyager
Created July 28, 2016 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewyager/f901714b9f6e5b0d4edd8eded057fa3c to your computer and use it in GitHub Desktop.
Save andrewyager/f901714b9f6e5b0d4edd8eded057fa3c to your computer and use it in GitHub Desktop.
This is a short script to loop through an set of extensions attached to an Asterisk box, and reboot the Polycom VVX handsets.
<?php
$phones = `asterisk -rx 'sip show peers'`;
$lines = explode("\n", $phones);
foreach ($lines as $line) {
$segments = preg_split("/\s+/", $line);
if (count($segments)>1) {
if ($segments[1]!="(Unspecified)") {
$parts = explode("/", $segments[0]);
$peer = `asterisk -rx 'sip show peer $parts[0]'`;
if (stristr($peer, 'vvx')) {
print "$parts[0] is a vvx\n";
print "sending sip notify polycom-check-cfg $parts[0]\n";
print `asterisk -rx 'sip notify polycom-check-cfg $parts[0]'\n`;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment