kanshi 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/kanshi/queries.rb +28 -0
- data/lib/kanshi/scrolls_reporter.rb +6 -1
- metadata +1 -1
data/lib/kanshi/queries.rb
CHANGED
@@ -32,4 +32,32 @@ SELECT
|
|
32
32
|
SUM(idx_blks_hit)::bigint AS idx_blks_hit
|
33
33
|
FROM
|
34
34
|
pg_statio_user_tables;
|
35
|
+
|
36
|
+
SELECT
|
37
|
+
COUNT(*) AS locks_waiting
|
38
|
+
FROM
|
39
|
+
pg_locks
|
40
|
+
WHERE
|
41
|
+
granted = 'f';
|
42
|
+
|
43
|
+
SELECT
|
44
|
+
EXTRACT('epoch' from SUM(NOW() - xact_start)) AS total_open_xact_time
|
45
|
+
FROM
|
46
|
+
pg_stat_activity
|
47
|
+
WHERE
|
48
|
+
xact_start IS NOT NULL;
|
49
|
+
|
50
|
+
SELECT
|
51
|
+
COUNT(*) AS xact_waiting
|
52
|
+
FROM
|
53
|
+
pg_stat_activity
|
54
|
+
WHERE
|
55
|
+
waiting = 't';
|
56
|
+
|
57
|
+
SELECT
|
58
|
+
COUNT(*) AS xact_idle
|
59
|
+
FROM
|
60
|
+
pg_stat_activity
|
61
|
+
WHERE
|
62
|
+
current_query = '<IDLE> in transaction';
|
35
63
|
EOF
|
@@ -41,7 +41,12 @@ private
|
|
41
41
|
hit = data[:blks_hit] || 0
|
42
42
|
read = data[:blks_read] || 0
|
43
43
|
if hit + read > 0
|
44
|
-
data[:
|
44
|
+
data[:blks_hit_ratio] = 100.0 * hit / (hit + read)
|
45
|
+
end
|
46
|
+
hit = data[:heap_blks_hit] || 0
|
47
|
+
read = data[:heap_blks_read] || 0
|
48
|
+
if hit > 0
|
49
|
+
data[:heap_hit_ratio] = 100.0 * (hit - read) / hit
|
45
50
|
end
|
46
51
|
data
|
47
52
|
end
|