Ad Widget

Collapse

command-line import/export facility dynamic items, triggers and graphs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dima_dm
    Senior Member
    • Dec 2009
    • 2697

    #1

    command-line import/export facility dynamic items, triggers and graphs

    I need dynamic items, triggers and graphs for monitoring different network equipment. For example: I need print Port Description in the title of graphs. Port Description is changing during the time.
    My algorithm is working as following:
    perl script is pooling SNMP requests on network device one time per day and creates XML configuration file for each device. After that script is importing new configuration file to Zabbix server via command-line Import/Export facility. Due to this process I have actual Port Description in graphs any time.

    Dear visitors of a forum, please vote for this facility
    command-line import/export facility


    In the appendix an example of a script to create XML configuration file for monitoring Cisco Router and Cisco Catalyst
    Example:
    ./cisco_xml.pl Hostname HostIP 75 5 public 5 lab-cisco
    P.S. Required Perl Lib Net-SNMP (example Net-SNMP-5.2.0 http://backpan.perl.org/authors/id/D/DT/DTOWN/)


    You can:
    1) Configure SNMP on switch or router
    XXXXXXX - SNMP community
    Example:
    snmp-server community XXXXXXX RO 1

    access-list 1 permit 10.0.2.0 0.0.0.255
    access-list 1 deny any

    On Zabbix Server
    2) check SNMP configuration on device
    HostIP - IP of you device
    XXXXXXX - SNMP community
    Example:
    snmpwalk -v 2c -c XXXXXXX HostIP .1.3.6.1.2.1.2.2.1.1
    IF-MIB::ifIndex.1 = INTEGER: 1
    IF-MIB::ifIndex.2 = INTEGER: 2
    IF-MIB::ifIndex.3 = INTEGER: 3
    IF-MIB::ifIndex.4 = INTEGER: 4
    IF-MIB::ifIndex.5 = INTEGER: 5
    IF-MIB::ifIndex.6 = INTEGER: 6
    IF-MIB::ifIndex.7 = INTEGER: 7
    IF-MIB::ifIndex.8 = INTEGER: 8
    IF-MIB::ifIndex.9 = INTEGER: 9
    IF-MIB::ifIndex.10 = INTEGER: 10
    IF-MIB::ifIndex.11 = INTEGER: 11
    IF-MIB::ifIndex.12 = INTEGER: 12
    IF-MIB::ifIndex.13 = INTEGER: 13
    IF-MIB::ifIndex.14 = INTEGER: 14
    IF-MIB::ifIndex.15 = INTEGER: 15
    IF-MIB::ifIndex.16 = INTEGER: 16
    IF-MIB::ifIndex.17 = INTEGER: 17
    IF-MIB::ifIndex.18 = INTEGER: 18
    IF-MIB::ifIndex.19 = INTEGER: 19
    IF-MIB::ifIndex.20 = INTEGER: 20
    IF-MIB::ifIndex.21 = INTEGER: 21
    IF-MIB::ifIndex.22 = INTEGER: 22
    IF-MIB::ifIndex.23 = INTEGER: 23
    IF-MIB::ifIndex.24 = INTEGER: 24
    IF-MIB::ifIndex.25 = INTEGER: 25
    IF-MIB::ifIndex.26 = INTEGER: 26
    IF-MIB::ifIndex.27 = INTEGER: 27
    IF-MIB::ifIndex.28 = INTEGER: 28
    IF-MIB::ifIndex.29 = INTEGER: 29
    IF-MIB::ifIndex.30 = INTEGER: 30
    IF-MIB::ifIndex.31 = INTEGER: 31
    IF-MIB::ifIndex.32 = INTEGER: 32
    IF-MIB::ifIndex.33 = INTEGER: 33
    IF-MIB::ifIndex.34 = INTEGER: 34
    IF-MIB::ifIndex.35 = INTEGER: 35
    IF-MIB::ifIndex.36 = INTEGER: 36
    IF-MIB::ifIndex.37 = INTEGER: 37
    3) run script (For Script Required Perl Lib Net-SNMP (example Net-SNMP-5.2.0 http://backpan.perl.org/authors/id/D/DT/DTOWN/)
    ./cisco_xml.pl Hostname HostIP 75 5 public 5 lab-cisco
    Where
    Hostname - Name of you device
    HostIP - IP of you device
    public - SNMP community
    lab-cisco - Zabbix Group for device (group must exist in Zabbix)
    4) Import xml file Template_Hostname.xml into Zabbix
    If you see error in Apache log:
    Fatal error: require_once() [function.require]: Failed opening required 'include/classes/class.domdocument.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/zabbix/include/config.inc.php on line 70
    Check PHP module
    I install:
    php-gd
    php-pear
    php
    php-bcmath
    php-mysql
    php-pdo
    php-xml
    php-mbstring

    In some php builds it is required also php-dom module
    5) Create host Hostname and link it with Template_Hostname
    Latest versions of script
    Attached Files
    Last edited by dima_dm; 18-10-2012, 12:40. Reason: and Cisco Catalyst
  • ericgearhart
    Senior Member
    • Jan 2009
    • 115

    #2
    See also this feature request, for dynamic SNMP ifAlias being referenced in an Item/Graph/Trigger... very similar to what you're asking for:

    Comment

    • dima_dm
      Senior Member
      • Dec 2009
      • 2697

      #3
      My decision more flexible because configuration is changing during the time.
      On equipment may contain new interfaces, VLAN etc.
      SNMP not the unique protocol of monitoring of the equipment. There is IPMI, WBEM, netflow, Vendor specific API etc. Port Description change is only one example of command-line Import/Export use.
      Command-line Import/Export is a MEGA facility. This feature allows to transfer dynamic objects building algorithm from ZABBIX source code to users script (XML builder).
      Last edited by dima_dm; 19-01-2010, 08:07. Reason: other protocol of monitoring

      Comment

      • dima_dm
        Senior Member
        • Dec 2009
        • 2697

        #4
        Bug for Zabbix 1.8.1 are corrected. New graph are added.
        New version
        2.03.2010. bugfix. Trigger is Activated and other cosmetic bugs are fixed.
        P.S. The new version was not tested on versions up to Zabbix 1.8.1
        Attached Files
        Last edited by dima_dm; 02-03-2010, 11:00. Reason: Trigger is Activated and other cosmetic bugs are fixed.

        Comment

        • dima_dm
          Senior Member
          • Dec 2009
          • 2697

          #5
          17.03.2010 New version
          FAN monitoring is added
          Device reboot monitoring is added
          14.07.2010 New version (see file cisco_xml.20100714.zip)
          New graphs (Packets per Second for all ports) is added
          17.03.2011 Version 1.5 (see file cisco_xml.20110317.zip)
          add 64 bit counters support
          Minor bug is fixed (for symbols <>)
          24.10.2012 for Zabbix 2.0 Version 2.0 cisco_xml.20121024.zip
          Attached Files
          Last edited by dima_dm; 24-10-2012, 14:55.

          Comment

          • umasse
            Junior Member
            • Mar 2010
            • 5

            #6
            Thanks a lot!
            It works amazingly well!!!

            Comment

            • limo
              Senior Member
              • Dec 2004
              • 192

              #7
              Hi to all,

              I have made little changes to script to achieve my things
              Code:
              Usage: $0 HOSTNAME IP [PORTLOAD] [MEMLOAD] [COMMUNITY] [History] [Trends] [MINUTES] [FocusOn] [FocusedPortMinutes] [NormalPortMinutes] [PortStatus] [GROUPS]\n";
              So number of days for history and trends are configurable, I have added parameter FocusOn which is regular expression, which port to focus. Focused ports are then watched more frequently (FocusedPortMinutes) instead of normalports (NormalPortMinutes).
              PortStatus is boolean, if to enable chckinginterface status (online/offline) or only check snmp counters.

              Result of this is, that when FocusOn in 'link', all ports which has description like 'link', will be checked more frequently than access ports.

              Enjoy!
              Lukas
              Attached Files

              Comment

              • furkamania
                Junior Member
                • May 2010
                • 6

                #8
                i ran the script it gives me some MIB's i dont know what am i exactly suppose to do with them =S

                please help

                Comment

                • dima_dm
                  Senior Member
                  • Dec 2009
                  • 2697

                  #9
                  This script build xml configuration file for Zabbix. You can import file Template_<You_Name>.xml in Zabbix server.
                  Last edited by dima_dm; 11-05-2010, 19:03.

                  Comment

                  • furkamania
                    Junior Member
                    • May 2010
                    • 6

                    #10
                    but i cannot see the created file...do i have to create it myself i am confused...

                    Comment

                    • dima_dm
                      Senior Member
                      • Dec 2009
                      • 2697

                      #11
                      You can:
                      1) Configure SNMP on switch or router
                      XXXXXXX - SNMP community
                      Example:
                      snmp-server community XXXXXXX RO 1

                      access-list 1 permit 10.0.2.0 0.0.0.255
                      access-list 1 deny any

                      On Zabbix Server
                      2) check SNMP configuration on device
                      HostIP - IP of you device
                      XXXXXXX - SNMP community
                      Example:
                      snmpwalk -v 2c -c XXXXXXX HostIP .1.3.6.1.2.1.2.2.1.1
                      IF-MIB::ifIndex.1 = INTEGER: 1
                      IF-MIB::ifIndex.2 = INTEGER: 2
                      IF-MIB::ifIndex.3 = INTEGER: 3
                      IF-MIB::ifIndex.4 = INTEGER: 4
                      IF-MIB::ifIndex.5 = INTEGER: 5
                      IF-MIB::ifIndex.6 = INTEGER: 6
                      IF-MIB::ifIndex.7 = INTEGER: 7
                      IF-MIB::ifIndex.8 = INTEGER: 8
                      IF-MIB::ifIndex.9 = INTEGER: 9
                      IF-MIB::ifIndex.10 = INTEGER: 10
                      IF-MIB::ifIndex.11 = INTEGER: 11
                      IF-MIB::ifIndex.12 = INTEGER: 12
                      IF-MIB::ifIndex.13 = INTEGER: 13
                      IF-MIB::ifIndex.14 = INTEGER: 14
                      IF-MIB::ifIndex.15 = INTEGER: 15
                      IF-MIB::ifIndex.16 = INTEGER: 16
                      IF-MIB::ifIndex.17 = INTEGER: 17
                      IF-MIB::ifIndex.18 = INTEGER: 18
                      IF-MIB::ifIndex.19 = INTEGER: 19
                      IF-MIB::ifIndex.20 = INTEGER: 20
                      IF-MIB::ifIndex.21 = INTEGER: 21
                      IF-MIB::ifIndex.22 = INTEGER: 22
                      IF-MIB::ifIndex.23 = INTEGER: 23
                      IF-MIB::ifIndex.24 = INTEGER: 24
                      IF-MIB::ifIndex.25 = INTEGER: 25
                      IF-MIB::ifIndex.26 = INTEGER: 26
                      IF-MIB::ifIndex.27 = INTEGER: 27
                      IF-MIB::ifIndex.28 = INTEGER: 28
                      IF-MIB::ifIndex.29 = INTEGER: 29
                      IF-MIB::ifIndex.30 = INTEGER: 30
                      IF-MIB::ifIndex.31 = INTEGER: 31
                      IF-MIB::ifIndex.32 = INTEGER: 32
                      IF-MIB::ifIndex.33 = INTEGER: 33
                      IF-MIB::ifIndex.34 = INTEGER: 34
                      IF-MIB::ifIndex.35 = INTEGER: 35
                      IF-MIB::ifIndex.36 = INTEGER: 36
                      IF-MIB::ifIndex.37 = INTEGER: 37
                      3) run script (For Script Required Perl Lib Net-SNMP (example Net-SNMP-5.2.0 http://backpan.perl.org/authors/id/D/DT/DTOWN/)
                      ./cisco_xml.pl Hostname HostIP 75 5 public 5 lab-cisco
                      Where
                      Hostname - Name of you device
                      HostIP - IP of you device
                      public - SNMP community
                      lab-cisco - Zabbix Group for device (group must exist in Zabbix)
                      4) Import xml file Template_Hostname.xml into Zabbix
                      If you see error in Apache log:
                      Fatal error: require_once() [function.require]: Failed opening required 'include/classes/class.domdocument.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/zabbix/include/config.inc.php on line 70
                      Check PHP module
                      I install:
                      php-gd
                      php-pear
                      php
                      php-bcmath
                      php-mysql
                      php-pdo
                      php-xml
                      php-mbstring

                      In some php builds it is required also php-dom module
                      5) Create host Hostname and link it with Template_Hostname
                      Last edited by dima_dm; 21-07-2011, 10:29. Reason: php module

                      Comment

                      • victorhugopa
                        Member
                        Zabbix Certified Specialist
                        • Apr 2010
                        • 66

                        #12
                        Originally posted by umasse
                        Thanks a lot!
                        It works amazingly well!!!
                        I agree!!
                        Tks dima_dm!!

                        []'s
                        Victor Hugo

                        Comment

                        • Melanxolik
                          Senior Member
                          • Nov 2009
                          • 174

                          #13
                          I have error import generate template:
                          * Error in query [INSERT INTO items (itemid,description,key_,hostid,delay,history,stat us,type,snmp_community,snmp_oid,value_type,data_ty pe,trapper_hosts,snmp_port,units,multiplier,delta, snmpv3_securityname,snmpv3_securitylevel,snmpv3_au thpassphrase,snmpv3_privpassphrase,formula,trends, logtimefmt,valuemapid,delay_flex,params,ipmi_senso r,templateid,authtype,username,password,publickey, privatekey) VALUES (24129,'sysUpTime','sysUpTimeInstance',10113,180*3 ,20,0,4,'121211','1.3.6.1.2.1.1.3.0',3,0,'localhos t',161,'sec',1,0,'',0,'','','0.01',link,'',0,'','' ,'',0,0,'','','','')] [Unknown column 'link' in 'field list']
                          * Internal zabbix error
                          Version 1.8.2

                          Comment

                          • dima_dm
                            Senior Member
                            • Dec 2009
                            • 2697

                            #14
                            Mistake in MySQL syntax. The word link should be placed in inverted commas.
                            Example:
                            'link'

                            Comment

                            • DB601
                              Member
                              • Jun 2010
                              • 30

                              #15
                              [
                              hello,

                              i want execute this script and i followed these steps but i have this msg:
                              " -bash: ./cisco_xml.pl: /usr/bin/perl^M: bad interpreter: No such file or directory "

                              can someone help me please!!!!!!!!!!!!!!!! i'm confused :'(

                              thank you

                              Comment

                              Working...