def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-s","--source", type=str, default="/var/logs", help="The logs source path in order to rotate")
    parser.add_argument("-s3","--uploadToS3", action="store_true", help="The logs source path in order to rotate")
    parser.add_argument("-v", "--verbose", action="store_true", help="Increase output verbosity")
    args = parser.parse_args()

    logicalPath = args.source + "/archive_dc"
    rotatePath = args.source + "/archive"

            
    if args.verbose :
        print ("Source: [%s]" % args.source)

    #Source
    numOfFiles = logRotate(args.source,logicalPath)
	
    #UploadToS3
    if args.uploadToS3 and (numOfFiles > 0) :
        uploadToS3(logicalPath)
    
	#Move to archived dir (other process will maintain this files)
	if numOfFiles > 0:
	    moveLogsToArchive(logicalPath,rotatePath) 

    return
Exemple #2
0
def main(): 
    #Key Function to present
    parser = argparse.ArgumentParser()
    parser.add_argument("-s","--source", type=str, default="/var/logs/archive", help="The logs source path in order to rotate")
    parser.add_argument("-r","--rotatePath", type=str, default="/var/logs/archive", help="The archive path")
    parser.add_argument("-ds3","--disableUploadToS3", action="store_true", default=False, help="False, to disable S3 function.")
    parser.add_argument("-v", "--verbose", action="store_true", help="Increase output verbosity")
    args = parser.parse_args()

    logicalPath = args.source + "/archive_dc"
    rotatePath = args.rotatePath

            
    if args.verbose :
        print ("Source: [%s]" % args.source)
        print ("rotatePath: [%s]" % args.rotatePath)
        print ("uploadToS3: [%s]" % str(args.disableUploadToS3))

    #Source
    logRotate(args.source,logicalPath)
    #UploadToS3
    if not args.disableUploadToS3 :
        print "uploadToS3(logicalPath) has been started"
        uploadToS3(logicalPath)
    
    moveLogsToArchive(logicalPath,rotatePath) 

    return
Exemple #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-s",
                        "--source",
                        type=str,
                        default="/var/logs",
                        help="The logs source path in order to rotate")
    parser.add_argument("-s3",
                        "--uploadToS3",
                        action="store_true",
                        help="The logs source path in order to rotate")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="Increase output verbosity")
    args = parser.parse_args()

    logicalPath = args.source + "/archive_dc"
    rotatePath = args.source + "/archive"

    if args.verbose:
        print("Source: [%s]" % args.source)

    #Source
    numOfFiles = logRotate(args.source, logicalPath)

    #UploadToS3
    if args.uploadToS3 and (numOfFiles > 0):
        uploadToS3(logicalPath)

        #Move to archived dir (other process will maintain this files)
        if numOfFiles > 0:
            moveLogsToArchive(logicalPath, rotatePath)

    return