File: //lib/python2.7/site-packages/lap/tac_flows_queue.py
from __future__ import generators
from glob import glob as ls
from datetime import date
import os
def dirwalk(dir):
"walk a directory tree, using a generator"
for f in os.listdir(dir):
fullpath = os.path.join(dir,f)
if os.path.isdir(fullpath) and not os.path.islink(fullpath):
for x in dirwalk(fullpath): # recurse into subdir
yield x
else:
yield fullpath
def __run__(params):
year = date.today().strftime("%Y")
path = params.get("path", "/var/lib/sfcapd")
total = len([ fid for fid in dirwalk("%s/%s" % (path, year)) ])
if total > int(params.get("limit", 36)):
return [2, "CRITICAL: %s %s files not processed" % (total, path.split('/')[-1])]
return [0, "OK: %s %s files not processed" % (total, path.split('/')[-1])]