--- /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 $@
--- /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)"
--- /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 <foerste@schlittermann.de> Mon, 23 May 2016 14:08:14 +0200
--- /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
--- /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 <foerste@schlittermann.de>
+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
--- /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 <foerste@schlittermann.de>
+
+Files: debian/*
+Copyright: 2016 Matthias Förste <foerste@schlittermann.de>
+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 <http://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
--- /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)
+
+
+
+
--- /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)