From patchwork Wed Aug 8 02:43:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: QI Fuli X-Patchwork-Id: 10559411 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 583C7157B for ; Wed, 8 Aug 2018 02:43:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B5E02A611 for ; Wed, 8 Aug 2018 02:43:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E0282A630; Wed, 8 Aug 2018 02:43:57 +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 AA35E2A620 for ; Wed, 8 Aug 2018 02:43:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5437A210DF5FB; Tue, 7 Aug 2018 19:43:56 -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=202.219.69.170; helo=mgwkm03.jp.fujitsu.com; envelope-from=qi.fuli@jp.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from mgwkm03.jp.fujitsu.com (mgwkm03.jp.fujitsu.com [202.219.69.170]) (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 E5B6D210D97AF for ; Tue, 7 Aug 2018 19:43:54 -0700 (PDT) Received: from kw-mxoi2.gw.nic.fujitsu.com (unknown [192.168.231.133]) by mgwkm03.jp.fujitsu.com with smtp id 32d0_5e7f_bf1efb6e_4e96_49bf_8ff3_d7eeefb6a9ec; Wed, 08 Aug 2018 11:43:50 +0900 Received: from m3050.s.css.fujitsu.com (msm.b.css.fujitsu.com [10.134.21.208]) by kw-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 84A19AC00ED for ; Wed, 8 Aug 2018 11:43:49 +0900 (JST) Received: from localhost.localdomain (unknown [10.124.196.110]) by m3050.s.css.fujitsu.com (Postfix) with ESMTP id 630EC16D; Wed, 8 Aug 2018 11:43:49 +0900 (JST) From: QI Fuli To: linux-nvdimm@lists.01.org Subject: [ndctl PATCH v2] ndctl, list: add alarm_enable_ to list Date: Wed, 8 Aug 2018 11:43:35 +0900 Message-Id: <20180808024335.12793-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, so that users could check if the "ndctl inject-smart ---alarm=on/off" works well or not. Signed-off-by: QI Fuli --- v1 -> v2: remove the renaming for list items. ndctl/util/json-smart.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ndctl/util/json-smart.c b/ndctl/util/json-smart.c index 6a1f294..e25483d 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); + } 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); + } 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: