<div dir="ltr">This v5 is merged.<div>Thanks.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 8:03 PM, Todd Gill <span dir="ltr"><<a href="mailto:tgill@redhat.com" target="_blank">tgill@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I had earlier sent an email to dm-devel proposing we add a feature<br>
in multipathd to output multipath map topology in JSON format. This<br>
patch contains to the code for that feature.<br>
<br>
Having an option for the  CLI to output in JSON would allow higher<br>
level applications to more easily monitor/manage multipath.<br>
<br>
I thought it was best to take advantage of some of the existing<br>
snprintf_xxx functions rather than adding a library dependency<br>
to multipathd.<br>
<br>
Any feedback welcome.<br>
<br>
v2:<br>
- added major/minor version fields<br>
- updates from feedback<br>
- added path groups<br>
- changed indent levels to make it easier to read<br>
- removed quotes from integer fields<br>
- fixed bug when the JSON string length exceeded the allocated memory<br>
- removed multipath field from path object - it isn't needed since<br>
  the path is inside the map<br>
<br>
v3:<br>
- split out vend/prod/rev into seperate fields<br>
- added new format specifiers for map:<br>
  %v - vend<br>
  %p - prod<br>
  %e - rev<br>
- removed vend/prod/rev from the path level since it is in the map<br>
<br>
v4:<br>
- removed space from major/minor version fields<br>
<br>
v5:<br>
- add group number at the group level<br>
- use an underscore to seperate words in the key part of the<br>
JSON<br>
- remove hcil, next_check, size, serial fields<br>
- remove uuid from the path level - it is already in the map<br>
- change JSON key from dm-st to dm_st<br>
- make all keys lower case<br>
- remove unnecessary call to memset - this addresses the performance<br>
problem.  memset is already called in MALLOC (zalloc)<br>
- multiply the initial allocation of memory with VECTOR_SIZE(vecs->mpvec)<br>
to reduce the number of realloc calls.<br>
- corrected reply + 1 in return of string length, correct length is<br>
c - reply, not c - reply + 1<br>
<br>
# multipathd show map dm-4 json<br>
{<br>
   "major_version": 0,<br>
   "minor_version": 1,<br>
   "map":{<br>
      "name" : "360a980004236646530244268305a3147",<br>
      "uuid" : "360a980004236646530244268305a3147",<br>
      "sysfs" : "dm-4",<br>
      "failback" : "immediate",<br>
      "queueing" : "on",<br>
      "paths" : 2,<br>
      "write_prot" : "rw",<br>
      "dm_st" : "active",<br>
      "features" : "4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle",<br>
      "hwhandler" : "0",<br>
      "action" : "",<br>
      "path_faults" : 0,<br>
      "vend" : "NETAPP",<br>
      "prod" : "LUN",<br>
      "rev" : "811a",<br>
      "switch_grp" : 0,<br>
      "map_loads" : 1,<br>
      "total_q_time" : 0,<br>
      "q_timeouts" : 0,<br>
      "path_groups": [{<br>
         "selector" : "service-time 0",<br>
         "pri" : 50,<br>
         "dm_st" : "active",<br>
         "group" : 1,<br>
         "paths": [{<br>
            "dev" : "sdi",<br>
            "dev_t" : "8:128",<br>
            "dm_st" : "active",<br>
            "dev_st" : "running",<br>
            "chk_st" : "ready",<br>
            "checker" : "tur",<br>
            "pri" : 50,<br>
            "host_wwnn" : "0x50014380120d8425",<br>
            "target_wwnn" : "0x500a098080ba5a64",<br>
            "host_wwpn" : "0x50014380120d8424",<br>
            "target_wwpn" : "0x500a098180ba5a64",<br>
            "host_adapter" : "0000:00:03.0"<br>
         }]<br>
      },{<br>
         "selector" : "service-time 0",<br>
         "pri" : 10,<br>
         "dm_st" : "enabled",<br>
         "group" : 2,<br>
         "paths": [{<br>
            "dev" : "sdp",<br>
            "dev_t" : "8:240",<br>
            "dm_st" : "active",<br>
            "dev_st" : "running",<br>
            "chk_st" : "ready",<br>
            "checker" : "tur",<br>
            "pri" : 10,<br>
            "host_wwnn" : "0x50014380120d8427",<br>
            "target_wwnn" : "0x500a098080ba5a64",<br>
            "host_wwpn" : "0x50014380120d8426",<br>
            "target_wwpn" : "0x500a098190ba5a64",<br>
            "host_adapter" : "0000:00:03.0"<br>
         }]<br>
      }]<br>
   }<br>
}<br>
<br>
Todd Gill (1):<br>
  add display of map information in JSON format<br>
<br>
 libmultipath/print.c      | 222 ++++++++++++++++++++++++++++++++++++++++++++++<br>
 libmultipath/print.h      |  61 +++++++++++++<br>
 multipathd/cli.c          |   3 +<br>
 multipathd/cli.h          |   2 +<br>
 multipathd/cli_handlers.c |  93 +++++++++++++++++++<br>
 multipathd/cli_handlers.h |   2 +<br>
 multipathd/main.c         |   2 +<br>
 7 files changed, 385 insertions(+)<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.5.5<br>
<br>
--<br>
dm-devel mailing list<br>
<a href="mailto:dm-devel@redhat.com">dm-devel@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/dm-devel" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/dm-devel</a><br>
</font></span></blockquote></div><br></div>