bgp.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #! /usr/bin/php
  2. <?php
  3. /*
  4. Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
  5. All rights reserved.
  6. Contact: Barry O'Donovan - barry (at) opensolutions (dot) ie
  7. http://www.opensolutions.ie/
  8. This file is part of the OSS_SNMP package.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. * Neither the name of Open Source Solutions Limited nor the
  17. names of its contributors may be used to endorse or promote products
  18. derived from this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  23. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. // This is an example script for OSS_SNMP Asterisk MIBs
  31. //
  32. // It needs to be called with a hostname / IP address and a community string
  33. if( count( $argv ) != 3 )
  34. {
  35. echo <<< HELPTEXT
  36. OSS_SNMP - A PHP SNMP library for people who hate SNMP MIBs and OIDs!
  37. Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
  38. All rights reserved.
  39. See: https://github.com/opensolutions/OSS_SNMP/
  40. This is an example script to show how to use OSS_SNMP. It requires two arguments:
  41. - the IP address of hostname of a SNMP capable host (with Asterisk SNMP enabled)
  42. - the SNMP v2 community string for that host
  43. For example:
  44. {$argv[0]} 192.168.10.20 public
  45. HELPTEXT;
  46. exit( 1 );
  47. }
  48. require_once( dirname( __FILE__ ) . '/../OSS_SNMP/SNMP.php' );
  49. $host = new \OSS_SNMP\SNMP( $argv[1], $argv[2] );
  50. echo "\n\n";
  51. echo "BGP version running on {$argv[1]}: " . $host->useBGP()->version() . "\n";
  52. echo "BGP - local ASN: " . $host->useBGP()->localASN() . "\n";
  53. echo "BGP - identifier: " . $host->useBGP()->identifier() . "\n";
  54. #echo "BGP - peers: \n\n";
  55. #print_r( $host->useBGP()->peerDetails(1) );
  56. echo "\n\n";
  57. exit( 0 );