Compress and prune directory of .avi

#!/bin/bash

#PREREQUISITES
#apt-get install cifs-utils
#apt-get install libav-tools

(
flock -n $FD

if [ $? -eq 0 ]; then

#Convert avi to mp4 to compress and save sapce
find /media/videorecordings/ -name *.avi -mtime +1 -exec avconv -y -i {} -vcodec libx264 -acodec libmp3lame -ac 2 {}.mp4 \; -exec rm {} -v \;

#Remove aged mp4 files
find /media/videorecordings/ -name *.mp4 -mtime +89 -exec rm {} \;

#Remove empty directories
find /media/videorecordings/ -type d -empty -delete

fi

) {FD}>/var/lock/prune_lock

Compress and prune directory of .avi

Zabbix External Check Time Comparison

OS: Ubuntu 14.04 LTS
Zabbix: 2.2.2

Enable External Checks:
mkdir -p /etc/zabbix/externalscripts
vi /etc/zabbix/zabbix-server.conf
add: ExternalScripts=/etc/zabbix/externalscripts
/etc/init.d/zabbix-server restart

Create External Check:
vi /etc/zabbix/externalscripts/timecheck.sh

if [ ! -z $1  ]; then
        SNMP_CMD="snmpget -Ov -c public -v1 $1 1.3.6.1.2.1.25.1.2.0"
        REMOTE_DATE=$($SNMP_CMD)
        REMOTE_DATE_HEX=$(echo ${REMOTE_DATE#Hex-STRING:})
        REMOTE_DATE_HEX_SIZE=${#REMOTE_DATE_HEX}

        if [ "$REMOTE_DATE_HEX_SIZE" -eq "23" ]; then # HANDLE SNMP TIMESTAMPS WITH AND WITHOUT TIMEZONE
                REMOTE_DATE_STR=$(perl -e '$octets = $ARGV[0]; $octets=~ s/ //g; $octets = pack("H*", $octets); @date = unpack("n C6 a C2",$octets); printf("%04d-%02d-%02d %02d:%02d:%02d.%d\n", @date);' "$REMOTE_DATE_HEX")
                else
                REMOTE_DATE_STR=$(perl -e '$octets = $ARGV[0]; $octets=~ s/ //g; $octets = pack("H*", $octets); @date = unpack("n C6 a C2",$octets); printf("%04d-%02d-%02d %02d:%02d:%02d.%d%s%02d:%02d\n", @date);' "$REMOTE_DATE_HEX")
        fi
        REMOTE_EPOCH=$(date -d "$REMOTE_DATE_STR" +"%s")
        LOCAL_EPOCH=$(date +%s);
        REMOTE_DIFF=$(echo "$REMOTE_EPOCH - $LOCAL_EPOCH" | bc)
        DIFF=$( echo $REMOTE_DIFF | tr -d -)
        echo "$DIFF
fi

Configure new Zabbix Item in Template or Host:

Name: Time Difference
Type: External check
Key: timecheck.sh[“{HOST.CONN}”]

Zabbix External Check Time Comparison

Create a Dummy Interface on Linux

OS: Ubuntu 14.04 LTS

#BRING UP A DUMMY INTERFACE AND ENSURE IT DOESN’T RESPOND TO ARP
install iproute2
modprobe dummy numdummies=2
ifconfig dummy0 192.168.1.1/32
ifconfig dummy0 up

echo “net.ipv4.conf.eth0.arp_ignore = 1” >> /etc/sysctl.conf
echo “net.ipv4.conf.all.arp_announce = 2” >>/etc/sysctl.conf
echo “net.ipv4.conf.eth0.arp_announce = 2” >> /etc/sysctl.conf
sysctl -p

#Allow Module and Interface to be loaded at Startup

echo “dummy numdummies=2” >> /etc/modules

vi /etc/network/interfaces
auto dummy0
iface dummy0 inet static
address 192.168.1.1
netmask 255.255.255.255

 

OS: OpenSuse 12.3

#do not broadcast arp for dummy interfaces
zypper install iproute2
echo “net.ipv4.conf.eth0.arp_ignore = 1” >> /etc/sysctl.conf
echo “net.ipv4.conf.all.arp_announce = 2” >>/etc/sysctl.conf
echo “net.ipv4.conf.eth0.arp_announce = 2” >> etc/sysctl.conf
sysctl -p

#create dummy interfaces
modprobe dummy
echo “options dummy numdummies=2” > /etc/modprobe.d/dummy.conf
echo dummy > /etc/modules-load.d/dummy.conf

#add ip address to dummy
vi /etc/sysconfig/network/ifcfg-dummy0
IPADDR=192.168.1.1
NETMASK=255.255.255.255
STARTMODE=auto

Create a Dummy Interface on Linux

Zabbix 2.2.2 Jabber Script

OS Version: Ubuntu 14.04
Zabbix Version: 2.2.2
Description: Script to allow zabbix to use jabber

#INSTALL PREREQUISITE SOFTWARE
apt-get install sendxmpp

#CREATE SENDXMPP SCRIPT
vi /etc/zabbix/alert.d/sendxmpp.sh

echo “$3” | sendxmpp  -u <username> -p <password> -j  <host fqdn>  “$1@<xmpp.domain>”

#MAKE SCRIPT EXECUTABLE
chmod a+x /etc/zabbix/alert.d/sendxmpp.sh

#ADD NEW MEDIA TYPE
Zabbix->Administration->Media Types -> New
Name: Jabber Notification
Type: Script
Script Name: sendxmpp.sh

Zabbix 2.2.2 Jabber Script