Skip to contents

Finds the RRA (round robin array) that best matches the consolidation function and the step and imports all values (from all data stores) in that RRA that are between timestamp start and end. Note that start is not included in the result.

Returns a data.frame object having the timestamp and the data stores as columns. The data store names are retrieved from the RRD file and set as the corresponding column names. The timestamps are also used as row names.

Usage

read_rra(filename, cf, step, n_steps, start, end = Sys.time())

Arguments

filename

File name

cf

The consolidation function that is applied to the data you want to fetch. Must be one of c("AVERAGE", "MIN", "MAX", "LAST")

step

step

n_steps

number of steps to return

start

start time

end

end time, defaults to the current system time

Details

The filename, cf (consolidation function) and step arguments uniquely identify an RRA array in the RRD file.

The arguments start and end define the time-slice to be retrieved. Note that start is not included in the result. Refer to the documentation for rrdfetch for more information.

The returned data.frame has the timestamp and the data stores as separate columns. The names of the data sources are extracted from the RRD file and set as column names. The timestamps are also used as row names.

See also

Other rrd functions: describe_rrd(), read_rrd()

Examples

rrd_cpu_0 <- system.file("extdata/cpu-0.rrd", package = "rrd")

# Note that the default end time is the current time (Sys.time())
# However, since the sample data is historic, specify the end time

start_time <- as.POSIXct("2018-05-01") # timestamp with data in example
end_time <- as.POSIXct("2018-05-02")   # timestamp with data in example

# read archive by specifying start time
avg_60 <- read_rra(rrd_cpu_0, cf = "AVERAGE", step = 60L, 
                     start = start_time, 
                     end = end_time)
names(avg_60)
#> [1] "timestamp" "user"      "sys"       "nice"      "idle"      "wait"     
#> [7] "irq"       "softirq"   "stolen"   
head(avg_60)
#> # A tibble: 6 × 9
#>   timestamp              user      sys  nice  idle  wait   irq softirq   stolen
#>   <dttm>                <dbl>    <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>    <dbl>
#> 1 2018-05-01 00:01:00 0.00458 0.00201      0 0.992     0     0       0 0.00144 
#> 2 2018-05-01 00:02:00 0.00258 0.000570     0 0.996     0     0       0 0.000570
#> 3 2018-05-01 00:03:00 0.00633 0.00144      0 0.992     0     0       0 0       
#> 4 2018-05-01 00:04:00 0.00515 0.00201      0 0.991     0     0       0 0.00144 
#> 5 2018-05-01 00:05:00 0.00402 0.000569     0 0.995     0     0       0 0.000569
#> 6 2018-05-01 00:06:00 0.00689 0.00144      0 0.992     0     0       0 0       
tail(avg_60)
#> # A tibble: 6 × 9
#>   timestamp              user      sys  nice  idle  wait   irq softirq stolen
#>   <dttm>                <dbl>    <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>  <dbl>
#> 1 2018-05-01 23:55:00 0.00546 0.00201      0 0.993     0     0       0      0
#> 2 2018-05-01 23:56:00 0.00458 0.00201      0 0.993     0     0       0      0
#> 3 2018-05-01 23:57:00 0.00258 0.000568     0 0.997     0     0       0      0
#> 4 2018-05-01 23:58:00 0.00633 0            0 0.994     0     0       0      0
#> 5 2018-05-01 23:59:00 0.00802 0.00144      0 0.991     0     0       0      0
#> 6 2018-05-02 00:00:00 0.00515 0.00345      0 0.991     0     0       0      0

# read archive by specifying number of rows to retrieve
avg_60 <- read_rra(rrd_cpu_0, cf = "AVERAGE", step = 60L, 
                   n_steps = 5, 
                   end = end_time)
names(avg_60)
#> [1] "timestamp" "user"      "sys"       "nice"      "idle"      "wait"     
#> [7] "irq"       "softirq"   "stolen"   
avg_60
#> # A tibble: 5 × 9
#>   timestamp              user      sys  nice  idle  wait   irq softirq stolen
#>   <dttm>                <dbl>    <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>  <dbl>
#> 1 2018-05-01 23:56:00 0.00458 0.00201      0 0.993     0     0       0      0
#> 2 2018-05-01 23:57:00 0.00258 0.000568     0 0.997     0     0       0      0
#> 3 2018-05-01 23:58:00 0.00633 0            0 0.994     0     0       0      0
#> 4 2018-05-01 23:59:00 0.00802 0.00144      0 0.991     0     0       0      0
#> 5 2018-05-02 00:00:00 0.00515 0.00345      0 0.991     0     0       0      0