Last active
December 16, 2015 08:53
-
-
Save q1x/930e49cd58a0674737ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set path | |
PATH=/opt/zabbix-gnomes/:$PATH | |
# Zabbix server | |
ZBXSERV="127.0.0.1" | |
# Set params | |
TEMPLATE="Template Cisco Catalyst Stack" | |
SERIAL_ITEMKEY="cswSwitchSerialNumber" | |
SERIAL_INVKEY="StackInventory[serials]" | |
SWVER_ITEMKEY="cswSwitchSoftwareVersion" | |
SWVER_INVKEY="StackInventory[versions]" | |
SWIMG_ITEMKEY="cswSwitchSoftwareImage" | |
SWIMG_INVKEY="StackInventory[images]" | |
# Set IFS | |
OLDIFS="$IFS" | |
IFS=$'\n' | |
# Loop through hosts | |
for host in $(zthostfinder.py -m "$TEMPLATE" ); do | |
SERIALS="" | |
SERIALS=$(for item in $(zhitemfinder.py "$host" -n -k "$SERIAL_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$SERIALS" != "" ]]; then zabbix_sender -z "$ZBXSERV" -s "$host" -k "$SERIAL_INVKEY" -o "$SERIALS"; fi | |
VERSIONS="" | |
VERSIONS=$(for item in $(zhitemfinder.py "$host" -n -k "$SWVER_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$VERSIONS" != "" ]]; then zabbix_sender -z "$ZBXSERV" -s "$host" -k "$SWVER_INVKEY" -o "$VERSIONS"; fi | |
IMAGES="" | |
IMAGES=$(for item in $(zhitemfinder.py "$host" -n -k "$SWIMG_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$IMAGES" != "" ]]; then zabbix_sender -z "$ZBXSERV" -s "$host" -k "$SWIMG_INVKEY" -o "$IMAGES"; fi | |
done | |
IFS="$OLDIFS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set path | |
PATH=/opt/zabbix-gnomes/:$PATH | |
# Zabbix server | |
ZBXSERV="127.0.0.1" | |
# Set params | |
TEMPLATE="Template Juniper EX" | |
SERIAL_ITEMKEY="hw.chassis.serial" | |
SERIAL_INVKEY="hw.inventory[serial]" | |
TYPE_ITEMKEY="hw.chassis.type" | |
TYPE_INVKEY="hw.inventory[type]" | |
OS_ITEMKEY="hw.chassis.os" | |
OS_INVKEY="hw.inventory[os]" | |
MAC_ITEMKEY="hw.chassis.mac" | |
MAC_INVKEY="hw.inventory[mac]" | |
# Set IFS | |
OLDIFS="$IFS" | |
IFS=$'\n' | |
# Loop through hosts | |
echo "Looping through hosts linked to template $TEMPLATE." | |
for host in $(zthostfinder.py -m "$TEMPLATE" ); do | |
echo "Processing host $host." | |
echo "Gathering serials." | |
SERIALS="" | |
SERIALS=$(for item in $(zhitemfinder.py "$host" -n -k "$SERIAL_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$SERIALS" != "" ]]; then | |
echo "Found $SERIALS." | |
zabbix_sender -z "$ZBXSERV" -s "$host" -k "$SERIAL_INVKEY" -o "$SERIALS" | |
else | |
echo "No serials found." | |
fi | |
echo "Gathering types." | |
TYPES="" | |
TYPES=$(for item in $(zhitemfinder.py "$host" -n -k "$TYPE_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$TYPES" != "" ]]; then | |
echo "Found $TYPES." | |
zabbix_sender -z "$ZBXSERV" -s "$host" -k "$TYPE_INVKEY" -o "$TYPES" | |
else | |
echo "No types found." | |
fi | |
echo "Gathering OSes." | |
OSES="" | |
OSES=$(for item in $(zhitemfinder.py "$host" -n -k "$OS_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$OSES" != "" ]]; then | |
echo "Found $OSES." | |
zabbix_sender -z "$ZBXSERV" -s "$host" -k "$OS_INVKEY" -o "$OSES" | |
else | |
echo "No OSes found." | |
fi | |
echo "Gathering MACs." | |
MACS="" | |
MACS=$(for item in $(zhitemfinder.py "$host" -n -k "$MAC_ITEMKEY"); do zgethistory.py -C 1 -t 86400 $item; done | sort | tr '\n' ',' | sed 's/,$//') | |
if [[ "$MACS" != "" ]]; then | |
echo "Found $MACS." | |
zabbix_sender -z "$ZBXSERV" -s "$host" -k "$MAC_INVKEY" -o "$MACS" | |
else | |
echo "No MACs found." | |
fi | |
done | |
IFS="$OLDIFS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment