# HG changeset patch # User Matthias Förste # Date 1464008187 -7200 # Node ID b6e0cc8761dfa721f527e489fae262b54a5f4643 [import] diff -r 000000000000 -r b6e0cc8761df Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,14 @@ +SCRIPT = check_avastlicense + +.PHONY: all clean + +all: $(SCRIPT) + +clean: + rm -rf $(SCRIPT) + +%: %.sh Makefile + # $@ + @sh -n $< + @cp $< $@ + @chmod +x $@ diff -r 000000000000 -r b6e0cc8761df check_avastlicense.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_avastlicense.sh Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,64 @@ +#!/bin/sh -e + +ME=$0 + +e=3 +s='UNKNOWN' + +trap 'trap - EXIT; exit "${e}"' INT QUIT TERM EXIT + +die() { + echo "$ME: $@" >&2 + exit +} + + +FILE='/etc/avast/license.avastlic' +# in seconds +CRITICAL=$((7*24*60*60)) +WARNING=$((2*CRITICAL)) +PATTERN='^UpdateValidThru=[0-9]+' +DELIMITER='=' +NAME='AVASTLICENSE' + +while getopts "f:w:c:" opt; do + case $opt in + c) + CRITICAL="$OPTARG" + ;; + d) + DELIMITER="$OPTARG" + ;; + f) + FILE="$OPTARG" + ;; + p) + PATTERN="$OPTARG" + ;; + w) + WARNING="$OPTARG" + ;; + esac +done +shift $((OPTIND-1)) + +now=$(date +%s) +expires=$(grep -E $PATTERN $FILE | cut -d$DELIMITER -f2) + +[ -n "$expires" ] || die 'Expiry not found!' + +left=$((expires - now)) +if [ $left -le $CRITICAL ]; then + e=2 + s='CRITICAL' +elif [ $left -le $WARNING ]; then + e=1 + s='WARNING' +elif [ $left -gt 0 ]; then + e=0 + s='OK' +else + die 'this should not happen unless $CRITICAL & $WARNING are negative; this is not supported' +fi + +echo "$NAME $s: file '$FILE' expires at $(date -d @$expires)" diff -r 000000000000 -r b6e0cc8761df debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/changelog Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,5 @@ +monitoring-plugin-avastlicense (0.1-1) oldoldstable oldstable stable; urgency=low + + * Initial release + + -- Matthias Förste Mon, 23 May 2016 14:08:14 +0200 diff -r 000000000000 -r b6e0cc8761df debian/compat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/compat Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,1 @@ +9 diff -r 000000000000 -r b6e0cc8761df debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/control Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,14 @@ +Source: monitoring-plugin-avastlicense +Section: net +Priority: optional +Maintainer: Matthias Förste +Build-Depends: debhelper (>= 9) +Standards-Version: 3.9.5 +Homepage: https://ssl.schlittermann.de/hg/ius/nagios/monitoring-plugin-avastlicense/ +#Vcs-Git: git://anonscm.debian.org/collab-maint/monitoring-plugin-avastlicense.git +#Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/monitoring-plugin-avastlicense.git;a=summary + +Package: monitoring-plugin-avastlicense +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: check avast license file expiry diff -r 000000000000 -r b6e0cc8761df debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/copyright Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,23 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: * +Copyright: 2016 Matthias Förste + +Files: debian/* +Copyright: 2016 Matthias Förste +License: GPL-2+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff -r 000000000000 -r b6e0cc8761df debian/docs diff -r 000000000000 -r b6e0cc8761df debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/rules Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,32 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +# main packaging script based on dh7 syntax +%: + dh $@ + +# debmake generated override targets +# This is example for Cmake (See http://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) + + + + diff -r 000000000000 -r b6e0cc8761df debian/source/format --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/source/format Mon May 23 14:56:27 2016 +0200 @@ -0,0 +1,1 @@ +3.0 (quilt)