From 444ede1ec1dff088709b27c273aecff3caf2b90f Mon Sep 17 00:00:00 2001
From: Nikolay Stanchev <ns17@it-innovation.soton.ac.uk>
Date: Tue, 10 Apr 2018 13:38:56 +0100
Subject: [PATCH] Documentation update - [Issue #61]

---
 docs/monitoring.md | 62 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 49 insertions(+), 13 deletions(-)

diff --git a/docs/monitoring.md b/docs/monitoring.md
index c69733e..9a33a74 100644
--- a/docs/monitoring.md
+++ b/docs/monitoring.md
@@ -557,19 +557,22 @@ From the whole sample period (1s), the VM has been 0.9s in state 'placed'. Hence
 the VM has been reported to be in state __placing__. Since it has exited state __placing__, the total time spent in this state (9.3s + 0.1s = 9.4s) is reported.
 This includes the state time from previous reports. The mean state time value for __placing__ is the same as the sum value because the VM has only been once in this state.
 
-| global tags | current_state (tag) | current_state_time | unplaced_sum | unplaced_mst | placing_sum | placing_mst | placed_sum | placed_mst | booting_sum | booting_mst | booted_sum | booted_mst | connecting_sum | connecting_mst | connected_sum | connected_mst | time |
-| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
-| ... | placing | 0.3 | 0.7 | 0.7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 1.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 2.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 3.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 4.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 5.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 6.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 7.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 8.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placing | 9.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
-| ... | placed | 0.9 | 0 | 0 | 9.4 | 9.4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| global tags | current_state (tag) | current_state_time | unplaced_sum | unplaced_mst | placing_sum | placing_mst | placed_sum | placed_mst | ... | time |
+| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
+| ... | placing | 0.3 | 0.7 | 0.7 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 1.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 2.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 3.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 4.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 5.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 6.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 7.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 8.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placing | 9.3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ... |
+| ... | placed | 0.9 | 0 | 0 | 9.4 | 9.4 | 0 | 0 | 0 | ... |
+
+In the table above, the state fields __booting_sum__, __booting_mst__, __booted_sum__, __booted_mst__, __connecting_sum__, __connecting_mst__, __connected_sum__ and __connected_mst__ 
+were truncated, since these are always reported to be 0 and are not the states being monitored in the measurements row.
 
 
 ##### Media component configuration state model
@@ -593,6 +596,39 @@ An example (based on the figure above) of some measurement rows for a media comp
 
 ### Example endpoint state configuration queries
 
+The following queries illustrate how to calculate _mean time between failures_ (MTBF) and _mean down time_ (MDT) for a specific endpoint.
+
+_Q. What is the Mean Time Between Failures (MTBF) of endpoint 'adaptive_streaming_I1_apache1'?_
+
+```
+select mean(connected_mst) as "apache1_MTBF(s)" from "endpoint_config" where connected_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+```
+
+```
+name: endpoint_config
+time apache1_MTBF(s)
+---- ----------------
+0    3605
+```
+
+_Q. What is the Mean Down Time (MDT) of endpoint 'adaptive_streaming_I1_apache1'?_
+
+```
+select mean(unplaced_mst) as "unplaced_mdt" into "endpoint_config_mdt" from "endpoint_config" where unplaced_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+select mean(placing_mst) as "placing_mdt" into "endpoint_config_mdt" from "endpoint_config" where placing_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+select mean(placed_mst) as "placed_mdt" into "endpoint_config_mdt" from "endpoint_config" where placed_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+select mean(booting_mst) as "booting_mdt" into "endpoint_config_mdt" from "endpoint_config" where booting_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+select mean(booted_mst) as "booted_mdt" into "endpoint_config_mdt" from "endpoint_config" where booted_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+select mean(connecting_mst) as "connecting_mdt" into "endpoint_config_mdt" from "endpoint_config" where connecting_mst <> 0 and ipendpoint = 'adaptive_streaming_I1_apache1'
+select (unplaced_mdt + placing_mdt + placed_mdt + booting_mdt + booted_mdt + connecting_mdt) as "MDT(s)" from "endpoint_config_mdt"
+```
+
+```
+name: endpoint_config_mdt
+time MDT(s)
+---- ------
+0    33.7
+```
 
 ### Example media component state configuration queries
 
-- 
GitLab