From 9fa18b495450cf57e3006c0444c505bbab00b72b Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Fri, 15 Jun 2018 17:28:55 -0700
Subject: [PATCH] Add script to grab cache stats on mirrors

This is a first step in exposing cache hits and misses statistics. This
will grab raw numbers that we can publish or do other crunching on.

Change-Id: Id306f4cc71f48a7ced49fdba8824b533b78e0561
---
 modules/openstack_project/files/mirror/cache-stats.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 modules/openstack_project/files/mirror/cache-stats.sh

diff --git a/modules/openstack_project/files/mirror/cache-stats.sh b/modules/openstack_project/files/mirror/cache-stats.sh
new file mode 100644
index 0000000000..7235c24d25
--- /dev/null
+++ b/modules/openstack_project/files/mirror/cache-stats.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+for X in 0 1 2 ; do
+    HITS=$(grep ' cache hit ' /var/log/apache2/${HOSTNAME}*_808${X}_access.log | wc -l)
+    REFRESHES=$(grep ' conditional cache hit: entity refreshed ' /var/log/apache2/${HOSTNAME}*_808${X}_access.log | wc -l)
+    MISSES=$(grep ' cache miss: ' /var/log/apache2/${HOSTNAME}*_808${X}_access.log | wc -l)
+
+    echo "Port 808${X} Cache Hits: $HITS"
+    echo "Port 808${X} Cache Refresshes: $REFRESHES"
+    echo "Port 808${X} Cache Misses: $MISSES"
+    echo ""
+done