premier commit

This commit is contained in:
Beu 2018-03-12 16:20:29 +01:00
commit af4ae883db
4 changed files with 263 additions and 0 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# zbx-pf_gateway
### Introduction
Ce projet permet de superviser les passerelles pfSense sur zabbix avec peu d'efforts
### HowTO
- copier le **bin/pf-gw** dans le dossier **/usr/local/bin/** de pfSense et le rendre executable.
- copier dans les options avancées de la WebUI le contenu du fichier **conf/userparameters**
- Importer dans zabbix le template situé dans template/pf_gateway.xml

20
bin/pf-gw Normal file
View File

@ -0,0 +1,20 @@
#!/bin/sh
if [ "$1" == "discovery" ]; then
sockets=`ls /var/run/dpinger_*.sock`
result=`echo -n '{"data": ['`
for i in $sockets ; do
data=`echo $i | cut -c 18- | cut -d "~" -f 1`
result=`echo -n $result'{"{#GWNAME}": "'`
result=`echo -n $result"$data"`
result=`echo -n $result'"},'`
done
result=`echo $result | sed 's/.$//'`
result=`echo -n $result']}'`
elif [ "$1" == "latency" ]; then
result=`cat /var/run/dpinger_${2}~*.sock 2> /dev/null | awk '{print $2 / 1000}' | bc | sed 's/^\./0./'`
elif [ "$1" == "packetloss" ]; then
result=`cat /var/run/dpinger_${2}~*.sock 2> /dev/null | awk '{print $4}'`
fi
echo $result

3
conf/userparameters.conf Normal file
View File

@ -0,0 +1,3 @@
UserParameter=pf-gw-latency[*],/usr/local/bin/pf-gw latency $1
UserParameter=pf-gw-pl[*],/usr/local/bin/pf-gw packetloss $1
UserParameter=pf-gw-discovery,/usr/local/bin/pf-gw discovery

228
template/pf_gateway.xml Normal file
View File

@ -0,0 +1,228 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.4</version>
<date>2018-03-12T15:15:08Z</date>
<groups>
<group>
<name>Templates/Network Devices</name>
</group>
</groups>
<templates>
<template>
<template>Template pfSense gateways</template>
<name>Template pfSense gateways</name>
<description/>
<groups>
<group>
<name>Templates/Network Devices</name>
</group>
</groups>
<applications>
<application>
<name>Network Interfaces</name>
</application>
</applications>
<items/>
<discovery_rules>
<discovery_rule>
<name>pfSense's Gateway</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>pf-gw-discovery</key>
<delay>12h</delay>
<status>0</status>
<allowed_hosts/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions/>
</filter>
<lifetime>30d</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name>Latency on {#GWNAME}</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>pf-gw-latency[{#GWNAME}]</key>
<delay>1m</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>ms</units>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Network Interfaces</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype/>
</item_prototype>
<item_prototype>
<name>Packet Loss on {#GWNAME}</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>pf-gw-pl[{#GWNAME}]</key>
<delay>1m</delay>
<history>90d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>%</units>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Network Interfaces</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<application_prototypes/>
<master_item_prototype/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Template pfSense gateways:pf-gw-latency[{#GWNAME}].avg(5m)}&gt;200 or {Template pfSense gateways:pf-gw-pl[{#GWNAME}].avg(5m)}&gt;10</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name>Gateway {#GWNAME} have a problem</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies>
<dependency>
<name>Gateway {#GWNAME} is down</name>
<expression>{Template pfSense gateways:pf-gw-latency[{#GWNAME}].avg(5m)}&gt;500 or {Template pfSense gateways:pf-gw-pl[{#GWNAME}].avg(5m)}&gt;20</expression>
<recovery_expression/>
</dependency>
</dependencies>
<tags/>
</trigger_prototype>
<trigger_prototype>
<expression>{Template pfSense gateways:pf-gw-latency[{#GWNAME}].avg(5m)}&gt;500 or {Template pfSense gateways:pf-gw-pl[{#GWNAME}].avg(5m)}&gt;20</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name>Gateway {#GWNAME} is down</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes>
<graph_prototype>
<name>Latency on {#GWNAME}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>1</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>FF3333</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template pfSense gateways</host>
<key>pf-gw-latency[{#GWNAME}]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
</graph_prototypes>
<host_prototypes/>
<jmx_endpoint/>
</discovery_rule>
</discovery_rules>
<httptests/>
<macros/>
<templates/>
<screens/>
</template>
</templates>
</zabbix_export>