Code Monkey home page Code Monkey logo

snmphp's Introduction

snmphp

PHP classes for monitoring various devices via SNMP, supporting v1 and v2c.

This code could be the building block for the poller in a monitoring suite, for example.

Currently tested on HP ProCurve 1920-48G and Synology RS815+, but it's designed to be easily portable to any other SNMP enabled device.

Requires php5-snmp and snmp-mibs-downloader packages to be installed.

Example of Bootstrap integration

demo

Sample map_oids($query) function
$iface_list = $this->snmp->map_oids($this->snmp->walk("IF-MIB::ifDescr"));

Array
(
    [IF-MIB::ifDescr.1] => lo
    [IF-MIB::ifDescr.2] => sit0
    [IF-MIB::ifDescr.3] => eth0
    [IF-MIB::ifDescr.4] => eth1
    [IF-MIB::ifDescr.5] => eth2
    [IF-MIB::ifDescr.6] => eth3
    [IF-MIB::ifDescr.7] => bond0
    [IF-MIB::ifDescr.9] => tun0
)
Array
(
    [lo] => 1
    [sit0] => 2
    [eth0] => 3
    [eth1] => 4
    [eth2] => 5
    [eth3] => 6
    [bond0] => 7
    [tun0] => 9
)
Sample get_network_info() iteration output on Synology RS815+
function get_network_info() {
  $iface_list = $this->snmp->map_oids($this->snmp->walk("IF-MIB::ifDescr"));
  foreach($iface_list as $name=>$oid) {
    $netinfo[$name]['In octets']= $this->snmp->get("IF-MIB::ifInOctets.$oid");
    $netinfo[$name]['Out octets']= $this->snmp->get("IF-MIB::ifOutOctets.$oid");
  }
  return $netinfo;
}

Array
(
    [lo] => Array
        (
            [In octets] => 146186
            [Out octets] => 146186
        )

    [sit0] => Array
        (
            [In octets] => 0
            [Out octets] => 0
        )

    [eth0] => Array
        (
            [In octets] => 77262691
            [Out octets] => 5131418
        )

    [eth1] => Array
        (
            [In octets] => 12311560
            [Out octets] => 69724411
        )

    [eth2] => Array
        (
            [In octets] => 0
            [Out octets] => 0
        )

    [eth3] => Array
        (
            [In octets] => 0
            [Out octets] => 0
        )

    [bond0] => Array
        (
            [In octets] => 89575556
            [Out octets] => 74855829
        )

    [tun0] => Array
        (
            [In octets] => 9794197
            [Out octets] => 49403006
        )

)

snmphp's People

Stargazers

 avatar

Watchers

 avatar

Forkers

engeld

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.