summaryrefslogtreecommitdiffstats
path: root/src/proc_uptime.c
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2017-09-17 22:17:33 +0000
committerLennart Weller <lhw@ring0.de>2017-09-17 22:17:33 +0000
commit6aaf5ba7ed0980c14bdc554fc8839a2126455ed5 (patch)
tree6161925716661486e7f47c479668a9487b039d83 /src/proc_uptime.c
parentNew upstream version 1.7.0+dfsg (diff)
downloadnetdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.tar.xz
netdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.zip
New upstream version 1.8.0+dfsgupstream/1.8.0+dfsg
Diffstat (limited to 'src/proc_uptime.c')
-rw-r--r--src/proc_uptime.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/proc_uptime.c b/src/proc_uptime.c
index f74cccb97..fb05b5cb3 100644
--- a/src/proc_uptime.c
+++ b/src/proc_uptime.c
@@ -3,7 +3,6 @@
int do_proc_uptime(int update_every, usec_t dt) {
(void)dt;
- static RRDSET *st = NULL;
collected_number uptime = 0;
#ifdef CLOCK_BOOTTIME_IS_AVAILABLE
@@ -38,17 +37,31 @@ int do_proc_uptime(int update_every, usec_t dt) {
// --------------------------------------------------------------------
- if(unlikely(!st))
- st = rrdset_find_localhost("system.uptime");
+ static RRDSET *st = NULL;
+ static RRDDIM *rd = NULL;
if(unlikely(!st)) {
- st = rrdset_create_localhost("system", "uptime", NULL, "uptime", NULL, "System Uptime", "seconds", 1000
- , update_every, RRDSET_TYPE_LINE);
- rrddim_add(st, "uptime", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
+
+ st = rrdset_create_localhost(
+ "system"
+ , "uptime"
+ , NULL
+ , "uptime"
+ , NULL
+ , "System Uptime"
+ , "seconds"
+ , 1000
+ , update_every
+ , RRDSET_TYPE_LINE
+ );
+
+ rd = rrddim_add(st, "uptime", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
}
- else rrdset_next(st);
+ else
+ rrdset_next(st);
+
+ rrddim_set_by_pointer(st, rd, uptime);
- rrddim_set(st, "uptime", uptime);
rrdset_done(st);
return 0;