@@ -0,0 +1,2119 @@
+#!/usr/bin/env python%0A%0Aimport sys%0Aimport os.path%0Aimport datetime%0Aimport optparse%0A%0ADESC=%22Nagios check: WARN if a file is smaller than a minimum number of bytes.%22%0A%0Adef main(argv):%0A    parser = optparse.OptionParser(description=DESC)%0A%0A    parser.add_option('-p', '--path', type='string', help=%22Path to check%22)%0A    parser.add_option('-s', '--size', type='string', help=%22Minimum file size. Supports B, K, M and G suffixes (default B)%22)%0A    opts, args = parser.parse_args()%0A%0A    if not opts.path or not opts.size:%0A        parser.print_help()%0A        return 1%0A%0A    if not os.path.exists(opts.path):%0A        print %22WARNING: Path %3C%25r%3E does not exist%22 %25 opts.path%0A        return 1%0A%0A    import re%0A%0A    def raise_(e):%0A        %22%22%22lambdas cannot contain statements, so this is an expression which can be used to raise an exception.%22%22%22%0A        raise e%0A%0A    rules = (%0A        (%0A            '%5E%5Cd+B$',%0A            lambda size: int(re.sub('B', '', size))%0A        ),%0A        (%0A            '%5E%5Cd+K$',%0A            lambda size: int(re.sub('K', '', size)) * 1024%0A        ),%0A        (%0A            '%5E%5Cd+M$',%0A            lambda size: int(re.sub('M', '', size)) * 1024 * 1024%0A        ),%0A        (%0A            '%5E%5Cd+G$',%0A            lambda size: int(re.sub('G', '', size)) * 1024 * 1024 * 1024%0A        ),%0A        (%0A            '%5E%5Cd+$',%0A            lambda size: int(size)%0A        ),%0A        (%0A            '.*',%0A            lambda size: raise_(Exception(%22Unknown size value %3C%25s%3E%22 %25 size))%0A        ),%0A    )%0A%0A    def parseSize(size):%0A        for reRule, multiplierRule in rules:%0A            if re.search(reRule, size):%0A                return multiplierRule(size)%0A%0A    minimum_size_in_bytes = parseSize(opts.size)%0A%0A    file_size = os.stat(opts.path).st_size%0A%0A    if file_size %3C minimum_size_in_bytes:%0A        print %22WARNING: Path %3C%25r%3E (%25dB) is less than %25dB%22 %5C%0A            %25 (opts.path, file_size, minimum_size_in_bytes)%0A        return 1%0A    else:%0A        print %22OK: Path %3C%25r%3E (%25dB) is larger than or equal to %25dB%22 %5C%0A            %25 (opts.path, file_size, minimum_size_in_bytes)%0A        return 0%0A%0Aif __name__ == %22__main__%22:%0A    sys.exit(main(sys.argv%5B1:%5D))%0A

Add a check to assert a file is a minimum size