Blob Blame History Raw
From 22b65c30c5eca015bb5aabf0a0d1d2c4aba21daa Mon Sep 17 00:00:00 2001
From: Muthu-vigneshwaran <mvignesh@redhat.com>
Date: Mon, 22 Aug 2016 16:53:59 +0530
Subject: [PATCH 51/86] quota: add quota events

The patch targets to capture quota related events which are
important to be notified.

>Reviewed-on: http://review.gluster.org/15235
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Tested-by: Manikandan Selvaganesh <mselvaga@redhat.com>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com>
>Reviewed-by: Raghavendra G <rgowdapp@redhat.com>

Change-Id: Iba440d675b11c346faab4c23260899d05296d8a7
BUG: 1361078
Signed-off-by: Muthu-vigneshwaran <mvignesh@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/84798
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
 events/eventskeygen.py             |    2 +-
 xlators/features/quota/src/quota.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/events/eventskeygen.py b/events/eventskeygen.py
index 144c554..a118a4c 100644
--- a/events/eventskeygen.py
+++ b/events/eventskeygen.py
@@ -90,7 +90,7 @@ keys = (
     "EVENT_QUOTA_SOFT_TIMEOUT",
     "EVENT_QUOTA_HARD_TIMEOUT",
     "EVENT_QUOTA_DEFAULT_SOFT_LIMIT",
-
+    "EVENT_QUOTA_CROSSED_SOFT_LIMIT",
 )
 
 LAST_EVENT = "EVENT_LAST"
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index dd7bf80..50eaa1f 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -15,6 +15,7 @@
 #include "statedump.h"
 #include "quota-common-utils.h"
 #include "quota-messages.h"
+#include "events.h"
 
 struct volume_options options[];
 
@@ -5008,7 +5009,12 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
                 gf_msg (this->name, GF_LOG_ALERT, 0,
                         Q_MSG_CROSSED_SOFT_LIMIT, "Usage crossed soft limit: "
                         "%s used by %s", usage_str, path);
+
+                gf_event (EVENT_QUOTA_CROSSED_SOFT_LIMIT, "Usage=%s;volume=%s;"
+                          "path=%s", usage_str, priv->volume_uuid, path);
+
                 ctx->prev_log = cur_time;
+
         }
         /* Usage is above soft limit */
         else if (cur_size > ctx->soft_lim &&
@@ -5020,6 +5026,10 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
                 gf_msg (this->name, GF_LOG_ALERT, 0, Q_MSG_CROSSED_SOFT_LIMIT,
                         "Usage is above soft limit: %s used by %s",
                         usage_str, path);
+
+                gf_event (EVENT_QUOTA_CROSSED_SOFT_LIMIT, "Usage=%s;volume=%s;"
+                          "path=%s", usage_str, priv->volume_uuid, path);
+
                 ctx->prev_log = cur_time;
         }
 
-- 
1.7.1