XML 2 SNMP

V 1.4.4

This is a plugin Translate a XML file to snmp request monitored SNMP and return code

It's IGINA project comme from XML TO SNMP bases

Manage :

  • FORTIGATE. XML v5.0
  • Equallogic.
  • CISCO.
  • ARUBA.
  • DELL.
  • DELL Switch.
  • HP Procurve.
  • Bleucoat.
  • Free BSD PF.
  • F5 BIGIP.
  • APC.
  • PDU.
  • Netapp.
  • Linux.
  • Printers.

Changelog:

1.4.4 may 27 2015

ADD option warning-custom =xml type name ex => fgHaStatsSesCount in fortigate xml file warning = value critical = value

1.4.3 Oct 07 2013

Modif syntax Hash ARRAY compliance new Perl

accept in --value-secondary idlike part oid index filter

ex --value-secondary idlike=1.1922986878

in XML definition : section seuil_oid can use warning_oid and critical_oid

1.4.2 Aug 05 2013

More perform Function Show

issue a disfonction with --value-secondary

1.4.1 Apr 3 2013

add function show for interpret array show in xml file

1.4.0 mar 26 2013

can use multiple filter with condition (and) in --value-secondary

ex --value-secondary dev1=0x6cf37fc42818:condition=and:dev2=MY_ESSID

add sub analyze_array_to_secondary can determine in array describ the good oid index

manage in analyze_array_to_secondary sub a conditional with multiple enter

condition is aruba-ap mac address and name ESSID give the index oid

1.3.1 mar 08 2013

with all type can use --value-secondary optimization request snmp with filter --value-secondary can use option id=index oid with --value-secondary

Usage :

./check_xml2snmp.pl [-v] -H  -C  [-2] | (-l login -x passwd)  [-P ] -F  -T status|bw|error [-t ] [-V] [-u ] --type-secondary

Options:

Flag Description

-v, --verbose print extra debugging information

-h, --help print this help message

-H, --hostname=HOST name or IP address of host to check

-C, --community=COMMUNITY NAME community name for the host's SNMP agent (implies v 1 protocol)

-2, --v2c use SNMP v2 (instead of SNMP v1)

-P, --port=PORT SNMPd port (Default 161)

-t, --timeout=INTEGER timeout for SNMP in seconds (Default: 5)

-w, --warning=integer value work only with warning-custom

-c, --critical=integer value work only with warning-custom

--warning-custom only with -c and -w find in xml file seuil section value you wan custom

-V, --version prints version number

-F, --file XML data

-T, --type=status|bw|error This allows to use pre-defined system type Currently support

systems types are: status return the state off each interface can be use for select name bw return the pourcent bandwith with speed interface referer off each interface can be use

with value-secondary error return errors from each interface can be use with value-secondary --value-secondary --value-secondary give select interface and bandwith off interface variable : if name off interface in the describ OID maxbw value [XX]Mb separator off each variable (:) separator off each group variable (,)

Example for TYPE bw of interface-2.xml

With different bandwith of default

--value-secondary if="FastEthernet0/1":maxbw=4Mb,if="FastEthernet0/5":maxbw=2Mb

For TYPE error

--value-secondary if="FastEthernet0/1",if="FastEthernet0/5"

Exemple

Help without xml file

 ./check_xml2snmp.pl --help

XML TO SNMP  Monitor for Nagios version 1.4.3
 by Fabien Bizet - tokiess(at)gmail.com

Usage: check_xml2snmp_1_4_3.pl [-v] -H  -C  [-2] | (-l login -x passwd)  [-P ] -F  -T  [-t ] [-V] [-u ] --type-secondary
-v, --verbose
        print extra debugging information
-h, --help
        print this help message
-H, --hostname=HOST
        name or IP address of host to check
-C, --community=COMMUNITY NAME
        community name for the host's SNMP agent (implies v 1 protocol)
-2, --v2c
        use SNMP v2 (instead of SNMP v1)
-P, --port=PORT
        SNMPd port (Default 161)
-t, --timeout=INTEGER
        timeout for SNMP in seconds (Default: 5)
-V, --version
        prints version number
-F, --file XML data
--show
-T, --type=

Help with xml file

 ./check_xml2snm.pl -F interface-2.xml --help

XML TO SNMP  Monitor for Nagios version 1.4.3
 by Fabien Bizet - tokiess(at)gmail.com

Usage: check_xml2snmp_1_4_3.pl [-v] -H  -C  [-2] | (-l login -x passwd)  [-P ] -F  -T status|bw|error [-t ] [-V] [-u ] --type-secondary
-v, --verbose
        print extra debugging information
-h, --help
        print this help message
-H, --hostname=HOST
        name or IP address of host to check
-C, --community=COMMUNITY NAME
        community name for the host's SNMP agent (implies v 1 protocol)
-2, --v2c
        use SNMP v2 (instead of SNMP v1)
-P, --port=PORT
        SNMPd port (Default 161)
-t, --timeout=INTEGER
        timeout for SNMP in seconds (Default: 5)
-V, --version
        prints version number
-F, --file XML data
--show
-T, --type=status|bw|error
        This allows to use pre-defined system type
        Currently support systems types are:
              status  return the state off each interface can be use for select name
              bw      return the pourcent bandwith with speed interface referer
                      off each interface can be use with value-secondary
              error   return errors from each interface can be use with value-secondary

        option --value-secondary give select interface and bandwith off interface
               variable :
                   if = name off interface in the describ OID
                   maxbw =  value [XX]Mb
               separator off each variable (:)
               separator off each group variable (,)
        ex :   for TYPE bw
              with different bandwith of default
              --value-secondary if="FastEthernet0/1":maxbw=4Mb,if="FastEthernet0/5":maxbw=2Mb
               for TYPE error
               -value-secondary if="FastEthernet0/1",if="FastEthernet0/5"
        check_xml2snmp -F [dir]/interface-2.xml -H [IP] -C [community] --show [only with 1.4.1 core version]

Do show interfaces

check_xml2snmp.pl -F interface-2.xml -H xx.xx.xx.xx -C *********** --show

 ---------Describ Interface : Index Interface---------

 : FastEthernet0/0 : index : 1

 : FastEthernet0/1 : index : 2

 : Null0 : index : 3

 : Tunnel0 : index : 4

 : Tunnel1 : index : 5

 : Tunnel2 : index : 6

 : NVI0 : index : 7

 : Tunnel3 : index : 8

 : Tunnel4 : index : 9

 : Tunnel5 : index : 10

 : Tunnel6 : index : 11

 : Tunnel7 : index : 12

 : Loopback0 : index : 13

 : Tunnel8 : index : 14

 : Tunnel9 : index : 15

 : Loopback1 : index : 16

 : Tunnel10 : index : 17

 : FastEthernet0/0/0 : index : 20

 : FastEthernet0/0/1 : index : 21

 : FastEthernet0/0/2 : index : 22

 : FastEthernet0/0/3 : index : 23

 : Vlan1 : index : 24

 : Vlan90 : index : 25

 : Vlan81 : index : 26

 : Tunnel11 : index : 27

 : Tunnel12 : index : 29

Check interface status FA0/1


check_xml2snmp.pl -F interface-2.xml -H **.**.**.** -C *********** -T status --value-secondary if=FastEthernet0/1

OK OK ifOperStatus FastEthernet0/0  - ifOperStatus FastEthernet0/0  = 1 up,  |ifOperStatus(FastEthernet0/0)=1

Ckeck with idlike in option --value-secondary

you can use referer in --value-secondary : if || id (index) || idlike


check_xml2snmp.pl -F equallogic.xml -2 -H **.**.**.** -C ************ -T power --value-secondary idlike=1.1215703825

 OK OK PowerSupplyCurrentState Power Cooling Module 0  - PowerSupplyCurrentState Power Cooling Module 0  = 1 normal,  OK PowerSupplyCurrentState Power Cooling Module 1  - PowerSupplyCurrentState Power Cooling Module 1  = 1 normal,  |PowerSupplyCurrentState(Power Cooling Module 0)=1 PowerSupplyCurrentState(Power Cooling Module 1)=1

Use warning-custom


you want check sessions fortigate warning 80000 and critical 90000 
check in xml file fortigate-2.xml
table name="system_types"

  fgha  fgHaStatsSesCount

check_xml2snmp.pl -F fortigate-2.xml -H **.**.**.** -C *********** -T fgha -w 80000 -c 90000 --warning-custom fgHaStatsSesCount

OK OK fgHaStatsCpuUsage **********  - fgHaStatsCpuUsage ********** = 11 ,  OK fgHaStatsCpuUsage **********- fgHaStatsCpuUsage **********  = 2 ,  OK fgHaStatsMemUsage ********** - fgHaStatsMemUsage ********** = 58 ,  OK fgHaStatsMemUsage ********** - fgHaStatsMemUsage ********** = 14 ,  OK fgHaStatsSesCount ********** - fgHaStatsSesCount ********** = 9604 ,  OK fgHaStatsSesCount ********** - fgHaStatsSesCount ********** = 419 ,  OK fgVdNumber   - fgVdNumber   = 20 ,  |fgHaStatsCpuUsage(**********)=11 fgHaStatsCpuUsage(********** )=2 fgHaStatsMemUsage(**********)=58 fgHaStatsMemUsage(**********)=14 fgHaStatsSesCount(**********)=9604 fgHaStatsSesCount(**********)=419 fgVdNumber()=20