Created
March 21, 2014 22:19
-
-
Save acruise/9697667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- /usr/bin/rrd2whisper 2013-09-02 14:26:29.000000000 -0700 | |
| +++ /home/alex/bin/rrd2whisper.py 2014-03-21 15:17:15.757422147 -0700 | |
| @@ -38,6 +38,11 @@ | |
| ', '.join(aggregationMethods), | |
| default='average', | |
| type='string') | |
| +option_parser.add_option( | |
| + '--now', | |
| + help="The time to use as \"now\"", | |
| + default=None, | |
| + type='int') | |
| (options, args) = option_parser.parse_args() | |
| @@ -94,6 +99,12 @@ | |
| raise SystemExit(err) | |
| archives = [] | |
| + | |
| +if not options.now: | |
| + latest = int(time.time()) | |
| +else: | |
| + latest = options.now | |
| + | |
| xFilesFactor = options.xFilesFactor | |
| for rra in relevant_rras: | |
| precision = rra['pdp_per_row'] * seconds_per_pdp | |
| @@ -103,7 +114,6 @@ | |
| archives.append((precision, points)) | |
| for datasource in datasources: | |
| - now = int(time.time()) | |
| path = rrd_path.replace('.rrd', '_%s.wsp' % datasource) | |
| try: | |
| whisper.create(path, archives, xFilesFactor=xFilesFactor) | |
| @@ -117,7 +127,7 @@ | |
| archiveNumber = len(archives) - 1 | |
| for precision, points in reversed(archives): | |
| retention = precision * points | |
| - endTime = now - now % precision | |
| + endTime = latest - latest % precision | |
| startTime = endTime - retention | |
| (time_info, columns, rows) = rrdtool.fetch( | |
| rrd_path, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment