Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active October 27, 2015 08:10
Show Gist options
  • Save tkuchiki/c919f7e0293001eb26a4 to your computer and use it in GitHub Desktop.
Save tkuchiki/c919f7e0293001eb26a4 to your computer and use it in GitHub Desktop.
gearmand template for zabbix
UserParameter=user.discovery.gearmand[*],/etc/zabbix/user.discovery.gearmand.sh "$1"
UserParameter=gearmand[*],/etc/zabbix/gearmand.sh $1 $2 $3
#!/bin/bash
PORT="${1}"
FUNC="${2}"
queue=2
jobs_running=3
capable_workers=4
STAT=$(eval echo '$'${3})
gearadmin --status --port ${PORT} | awk -v f=${FUNC} -v stat=${STAT} 'f == $1 {print $stat}'
#!/bin/bash
TMP_IFS=${IFS}
DATA=""
for PORT in ${1}; do
IFS=$'\n'
for FUNC_NAME in $(gearadmin --status --port ${PORT} | grep -v '^\.' | awk '{print $1}'); do
IFS=${TMP_IFS}
DATA="${DATA},"$(printf '{"{#GEARMAND_FUNC_NAME}":"%s","{#GEARMAND_PORT}":%d}' "${FUNC_NAME}" ${PORT})
done
done
echo "{\"data\":[$(echo ${DATA} | sed -e 's/^,//')]}"
...
Include=/etc/zabbix/zabbix_agentd.d/gearmand.conf
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<date>2015-10-27T07:40:52Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Template_gearmand</template>
<name>Template_gearmand</name>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>gearmand</name>
</application>
</applications>
<items/>
<discovery_rules>
<discovery_rule>
<name>gearmand discovery</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>user.discovery.gearmand[{$GEARMAND_PORTS}]</key>
<delay>60</delay>
<status>0</status>
<allowed_hosts/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>:</filter>
<lifetime>30</lifetime>
<description/>
<item_prototypes>
<item_prototype>
<name>gearmand[{#GEARMAND_PORT}] is running</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>net.tcp.listen[{#GEARMAND_PORT}]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>gearmand</name>
</application>
</applications>
<valuemap/>
</item_prototype>
<item_prototype>
<name>gearmand[{#GEARMAND_PORT}] {#GEARMAND_FUNC_NAME} capable workers</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>gearmand[{#GEARMAND_PORT}, {#GEARMAND_FUNC_NAME}, capable_workers]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>gearmand</name>
</application>
</applications>
<valuemap/>
</item_prototype>
<item_prototype>
<name>gearmand[{#GEARMAND_PORT}] {#GEARMAND_FUNC_NAME} jobs running</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>gearmand[{#GEARMAND_PORT}, {#GEARMAND_FUNC_NAME}, jobs_running]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>gearmand</name>
</application>
</applications>
<valuemap/>
</item_prototype>
<item_prototype>
<name>gearmand[{#GEARMAND_PORT}] {#GEARMAND_FUNC_NAME} queue</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>gearmand[{#GEARMAND_PORT}, {#GEARMAND_FUNC_NAME}, queue]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authpassphrase/>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>gearmand</name>
</application>
</applications>
<valuemap/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Template_gearmand:gearmand[{#GEARMAND_PORT}, {#GEARMAND_FUNC_NAME}, capable_workers].last(0)}=0</expression>
<name>gearmand[{#GEARMAND_PORT}] {#GEARMAND_FUNC_NAME} worker not running</name>
<url/>
<status>0</status>
<priority>3</priority>
<description/>
<type>0</type>
</trigger_prototype>
<trigger_prototype>
<expression>{Template_gearmand:net.tcp.listen[{#GEARMAND_PORT}].last(0)}=0</expression>
<name>gearmand {#GEARMAND_PORT} not listening</name>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes/>
</discovery_rule>
</discovery_rules>
<macros>
<macro>
<macro>{$GEARMAND_PORTS}</macro>
<value>4730</value>
</macro>
</macros>
<templates/>
<screens/>
</template>
</templates>
</zabbix_export>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment