From patchwork Tue Aug 7 15:35:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: QI Fuli X-Patchwork-Id: 10558789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA37414E5 for ; Tue, 7 Aug 2018 15:35:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B728728DBA for ; Tue, 7 Aug 2018 15:35:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A991D29E90; Tue, 7 Aug 2018 15:35:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A19C28DBA for ; Tue, 7 Aug 2018 15:35:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D5328210DF4FD; Tue, 7 Aug 2018 08:35:28 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=211.128.242.43; helo=mgwym04.jp.fujitsu.com; envelope-from=qi.fuli@jp.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from mgwym04.jp.fujitsu.com (mgwym04.jp.fujitsu.com [211.128.242.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 86CC8210DC1B7 for ; Tue, 7 Aug 2018 08:35:26 -0700 (PDT) Received: from yt-mxoi1.gw.nic.fujitsu.com (unknown [192.168.229.67]) by mgwym04.jp.fujitsu.com with smtp id 4e13_3bdb_cbbf870b_0f14_43f8_b134_e527740d986b; Wed, 08 Aug 2018 00:35:18 +0900 Received: from m3050.s.css.fujitsu.com (msm.b.css.fujitsu.com [10.134.21.208]) by yt-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id AB087AC01D8 for ; Wed, 8 Aug 2018 00:35:17 +0900 (JST) Received: from localhost.localdomain (unknown [10.124.196.110]) by m3050.s.css.fujitsu.com (Postfix) with ESMTP id 94A30166; Wed, 8 Aug 2018 00:35:17 +0900 (JST) From: QI Fuli To: linux-nvdimm@lists.01.org Subject: [ndctl PATCH] ndctl, list: emit alarm_enable_ and clarify misc list items Date: Wed, 8 Aug 2018 00:35:14 +0900 Message-Id: <20180807153514.31748-1-qi.fuli@jp.fujitsu.com> X-Mailer: git-send-email 2.18.0 X-TM-AS-MML: disable X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds alarm_enable_ to list. Therefore, users can know if the "ndclt inject-smart ---alarm=on/off" works or not. Users may confuse "alarm_enable" with "alarm_flag" and "media_temperature" with "ctrl_temperature", this patch also used to clarify these items. Signed-off-by: QI Fuli --- ndctl/util/json-smart.c | 45 ++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/ndctl/util/json-smart.c b/ndctl/util/json-smart.c index 6a1f294..a0677a6 100644 --- a/ndctl/util/json-smart.c +++ b/ndctl/util/json-smart.c @@ -39,34 +39,61 @@ static void smart_threshold_to_json(struct ndctl_dimm *dimm, unsigned int temp; double t; + jobj = json_object_new_boolean(true); + if (jobj) + json_object_object_add(jhealth, + "alarm_enable_media_temperature", jobj); temp = ndctl_cmd_smart_threshold_get_temperature(cmd); t = ndctl_decode_smart_temperature(temp); jobj = json_object_new_double(t); if (jobj) json_object_object_add(jhealth, - "temperature_threshold", jobj); + "media_temperature_threshold", jobj); + } else { + jobj = json_object_new_boolean(false); + if (jobj) + json_object_object_add(jhealth, + "alarm_enable_media_temperature", jobj); } if (alarm_control & ND_SMART_CTEMP_TRIP) { unsigned int temp; double t; + jobj = json_object_new_boolean(true); + if (jobj) + json_object_object_add(jhealth, + "alarm_enable_ctrl_temperature", jobj); temp = ndctl_cmd_smart_threshold_get_ctrl_temperature(cmd); t = ndctl_decode_smart_temperature(temp); jobj = json_object_new_double(t); if (jobj) json_object_object_add(jhealth, - "controller_temperature_threshold", jobj); + "ctrl_temperature_threshold", jobj); + } else { + jobj = json_object_new_boolean(false); + if (jobj) + json_object_object_add(jhealth, + "alarm_enable_ctrl_temperature", jobj); } if (alarm_control & ND_SMART_SPARE_TRIP) { unsigned int spares; + jobj = json_object_new_boolean(true); + if (jobj) + json_object_object_add(jhealth, + "alarm_enable_spares", jobj); spares = ndctl_cmd_smart_threshold_get_spares(cmd); jobj = json_object_new_int(spares); if (jobj) json_object_object_add(jhealth, "spares_threshold", jobj); + } else { + jobj = json_object_new_boolean(false); + if (jobj) + json_object_object_add(jhealth, + "alarm_enable_spares", jobj); } out: @@ -118,7 +145,8 @@ struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm) jobj = json_object_new_double(t); if (jobj) - json_object_object_add(jhealth, "temperature_celsius", jobj); + json_object_object_add(jhealth, + "media_temperature_celsius", jobj); } if (flags & ND_SMART_CTEMP_VALID) { @@ -128,7 +156,7 @@ struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm) jobj = json_object_new_double(t); if (jobj) json_object_object_add(jhealth, - "controller_temperature_celsius", jobj); + "ctrl_temperature_celsius", jobj); } if (flags & ND_SMART_SPARES_VALID) { @@ -147,15 +175,18 @@ struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm) jobj = json_object_new_boolean(temp_flag); if (jobj) - json_object_object_add(jhealth, "alarm_temperature", jobj); + json_object_object_add(jhealth, + "alarm_flag_media_temperature", jobj); jobj = json_object_new_boolean(ctrl_temp_flag); if (jobj) - json_object_object_add(jhealth, "alarm_controller_temperature", jobj); + json_object_object_add(jhealth, + "alarm_flag_ctrl_temperature", jobj); jobj = json_object_new_boolean(spares_flag); if (jobj) - json_object_object_add(jhealth, "alarm_spares", jobj); + json_object_object_add(jhealth, + "alarm_flag_spares", jobj); } smart_threshold_to_json(dimm, jhealth);