Ad Widget

Collapse

smal tool for create host xml from snmp enabled switch/router

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • slavik
    Junior Member
    • Feb 2011
    • 15

    #1

    smal tool for create host xml from snmp enabled switch/router

    hi
    I wrote small utility which create host xml from live snmp-enabled switch or router.
    donload php source
    feel free to comment if you find this tool useful or useless, or share with me ideas or OID to monitor.
  • slavik
    Junior Member
    • Feb 2011
    • 15

    #2
    new version:
    + added bulk mode, "php snmp-zabbix.php 15.21.41.11 12.17.10.13 72.2.18.2"
    + brocade FC switches support

    Comment

    • jrprado
      Junior Member
      • Sep 2010
      • 28

      #3
      Please advise how to use. What should be made ​​to work? What parameters should I use or modify?

      Thanks for sharing

      Comment

      • slavik
        Junior Member
        • Feb 2011
        • 15

        #4
        short usage tips

        usage
        single device mode:
        php snmp-zabbix.php ip_address_there xml_name_there
        i.e. php snmp-zabbix.php 1.2.3.4 server1.xml
        bulk mode:
        php snmp-zabbix.php ip_address1 ip_address2 ... ip_address99999
        (I'm not sure about your system limitations for parameter's list length)
        i.e. php snmp-zabbix.php 1.2.3.4 1.2.3.5 2.3.4.5 5.6.7.8 1.3.5.7

        current version limitations
        1. uses snmp v2, and hardcoded community "public".
        2. hardcoded xml filename in bulk mode.

        output
        software produces XML file, which you should import into zabbix in host import page.

        feel free to ask if you have any questions or report bugs.

        Comment

        • slavik
          Junior Member
          • Feb 2011
          • 15

          #5
          ps:
          You can easily change "public" community string in code into something what you use. I mean code does not use any obfuscation and not encoded.
          I can't imagine simple way for specify community string for each device.

          Comment

          • jrprado
            Junior Member
            • Sep 2010
            • 28

            #6
            Hi slavik,

            I change a community in code to my network. I run a script and receive this error below:

            Code:
            php snmp-zabbix.php 10.7.1.16 teste.xml
            PHP Fatal error:  Call to undefined function snmpwalk() in /var/www/html/snmp-zabbix.php on line 318
            Code on line 318:

            Code:
            function getifs()
            {
                    global $deviceip, $snmp_community_string;
                    //$snmpcmd="snmpwalk -v 2c -c $snmp_community_string -O qv $deviceip";
                    $result=snmpwalk("$deviceip", "$snmp_community_string", "IF-MIB::ifIndex");
                    return $result;
            }
            Thanks for reply!

            Comment

            • slavik
              Junior Member
              • Feb 2011
              • 15

              #7
              You can't comment this line (snmpwalk(...)) out.
              You should compile/install php with snmp support anyway.
              PS: this is because exec("snmpwalk ...") returns only single line, and snmpget(...) doesn't works with HC (HighCapacity, Counter64) items.
              Last edited by slavik; 13-03-2011, 18:25.

              Comment

              • slavik
                Junior Member
                • Feb 2011
                • 15

                #8
                beatsstudio, show me error.
                ps: in last version php must compiled/installed with snmp support always.

                Comment

                • slavik
                  Junior Member
                  • Feb 2011
                  • 15

                  #9
                  update

                  current version limitations
                  1. uses snmp v2, and hardcoded community "public".
                  2. hardcoded xml filename in bulk mode.
                  3. no national characters, or special symbols supported.

                  Comment

                  • SolBuzz.com
                    Junior Member
                    • Feb 2011
                    • 1

                    #10
                    thanks slavik!

                    I also Like jrprado an error and I have corrected the way slavik, I was successful
                    Now I can easily change "public" community string in code
                    thanks slavika for sharing

                    Comment

                    • dantony79
                      Junior Member
                      • Aug 2010
                      • 12

                      #11
                      I just cannot see the imported file under templates.

                      i imported the firewall1.xml into zabbix

                      after running "php snmp-zabbix.php 10.100.100.251 firewall1.xml"

                      but how where can i see the imported "firewall1.xml".

                      I just cannot see the imported file under templates.

                      Please guide me if i am wrong.

                      Originally posted by slavik
                      usage
                      single device mode:
                      php snmp-zabbix.php ip_address_there xml_name_there
                      i.e. php snmp-zabbix.php 1.2.3.4 server1.xml
                      bulk mode:
                      php snmp-zabbix.php ip_address1 ip_address2 ... ip_address99999
                      (I'm not sure about your system limitations for parameter's list length)
                      i.e. php snmp-zabbix.php 1.2.3.4 1.2.3.5 2.3.4.5 5.6.7.8 1.3.5.7

                      current version limitations
                      1. uses snmp v2, and hardcoded community "public".
                      2. hardcoded xml filename in bulk mode.

                      output
                      software produces XML file, which you should import into zabbix in host import page.

                      feel free to ask if you have any questions or report bugs.

                      Comment

                      • slavik
                        Junior Member
                        • Feb 2011
                        • 15

                        #12
                        hi dantony79
                        You should see in "hosts" host with ip=10.100.100.251. If xml contains something usual of course. otherwise, you should see some errors as result of import.

                        Comment

                        • warren
                          Junior Member
                          • Apr 2011
                          • 1

                          #13
                          Thanks slavik, this is a very handy tool. I've modded my copy around a bit for my purposes, but I wanted to highlight one in particular.

                          In function asksnmp, there is a line:
                          if (FALSE==$result) return NULL;

                          I found that the created XML template didn't have all items for things such as interface errors. Instead, it only had the items for ports that currently had errors.

                          Changing the line above to FALSE === $result (3 equals signs) corrects this.

                          Thanks!

                          Comment

                          • slavik
                            Junior Member
                            • Feb 2011
                            • 15

                            #14
                            tnx warren.
                            fixed version was uploaded.
                            project moved from my personal svn into http://code.google.com/p/snmp-zabbix/
                            feel free to report bugs
                            Last edited by slavik; 17-05-2011, 09:41.

                            Comment

                            • efrain02
                              Banned
                              • Apr 2011
                              • 81

                              #15
                              Maybe a more clear explanation would help.
                              Last edited by efrain02; 22-06-2011, 17:04. Reason: Wrong typing

                              Comment

                              Working...