{"action":"created","issue":{"url":"https://api.github.com/repos/zfsonlinux/zfs/issues/4670","repository_url":"https://api.github.com/repos/zfsonlinux/zfs","labels_url":"https://api.github.com/repos/zfsonlinux/zfs/issues/4670/labels{/name}","comments_url":"https://api.github.com/repos/zfsonlinux/zfs/issues/4670/comments","events_url":"https://api.github.com/repos/zfsonlinux/zfs/issues/4670/events","html_url":"https://github.com/zfsonlinux/zfs/issues/4670","id":155832275,"number":4670,"title":"zpool status always returns true","user":{"login":"jimsalterjrs","id":1280796,"avatar_url":"https://avatars.githubusercontent.com/u/1280796?v=3","gravatar_id":"","url":"https://api.github.com/users/jimsalterjrs","html_url":"https://github.com/jimsalterjrs","followers_url":"https://api.github.com/users/jimsalterjrs/followers","following_url":"https://api.github.com/users/jimsalterjrs/following{/other_user}","gists_url":"https://api.github.com/users/jimsalterjrs/gists{/gist_id}","starred_url":"https://api.github.com/users/jimsalterjrs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimsalterjrs/subscriptions","organizations_url":"https://api.github.com/users/jimsalterjrs/orgs","repos_url":"https://api.github.com/users/jimsalterjrs/repos","events_url":"https://api.github.com/users/jimsalterjrs/events{/privacy}","received_events_url":"https://api.github.com/users/jimsalterjrs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-19T20:52:29Z","updated_at":"2016-05-20T19:34:43Z","closed_at":null,"body":"`zpool status` returns true, even on a completely faulted pool.  This means that automated monitors and alerts are forced to rely on parsing text (which can change without warning) to evaluate pool health.\r\n\r\n````\r\nroot@locutus:/data/test# zpool status test && echo $?\r\n  pool: test\r\n state: DEGRADED\r\nstatus: One or more devices could not be used because the label is missing or\r\n\tinvalid.  Sufficient replicas exist for the pool to continue\r\n\tfunctioning in a degraded state.\r\naction: Replace the device using 'zpool replace'.\r\n   see: http://zfsonlinux.org/msg/ZFS-8000-4J\r\n  scan: scrub repaired 0 in 0h0m with 0 errors on Thu May 19 16:30:13 2016\r\nconfig:\r\n\r\n\tNAME        STATE     READ WRITE CKSUM\r\n\ttest        DEGRADED     0     0     0\r\n\t  mirror-0  DEGRADED     0     0     0\r\n\t    nbd0    UNAVAIL      0     0     0  corrupted data\r\n\t    nbd1    ONLINE       0     0     0\r\n\t  mirror-1  ONLINE       0     0     0\r\n\t    nbd2    ONLINE       0     0     0\r\n\t    nbd3    ONLINE       0     0     0\r\n\r\nerrors: No known data errors\r\n0\r\n````\r\n\r\nIn the above example, a DEGRADED pool's status still returns 0.\r\n\r\n````\r\nroot@banshee:~# zpool status -x test ; echo $?\r\n  pool: test\r\n state: UNAVAIL\r\nstatus: One or more devices are faulted in response to IO failures.\r\naction: Make sure the affected devices are connected, then run 'zpool clear'.\r\n   see: http://zfsonlinux.org/msg/ZFS-8000-HC\r\n  scan: scrub in progress since Thu May 19 16:45:22 2016\r\n    187M scanned out of 187M at 2.13M/s, 0h0m to go\r\n    0 repaired, 99.87% done\r\nconfig:\r\n\r\n\tNAME        STATE     READ WRITE CKSUM\r\n\ttest        UNAVAIL      0     0     0  insufficient replicas\r\n\t  mirror-0  UNAVAIL      0     0     0  insufficient replicas\r\n\t    nbd0    UNAVAIL      0     0     0  corrupted data\r\n\t    nbd1    UNAVAIL      0     0     0  corrupted data\r\n\t  mirror-1  ONLINE       0     0     0\r\n\t    nbd2    ONLINE       0     0     0\r\n\t    nbd3    ONLINE       0     0     0\r\n\r\nerrors: 1539 data errors, use '-v' for a list\r\n0\r\n````\r\nAnd here we see even a completely UNAVAIL pool *still* returning 0 from a status check.\r\n\r\nI would really, really like to see `zpool status` returning a parseable exit code.  An additional option for text output in a stable format designed for machine parsing (as well as predictable exit codes) would be even better.\r\n"},"comment":{"url":"https://api.github.com/repos/zfsonlinux/zfs/issues/comments/220698866","html_url":"https://github.com/zfsonlinux/zfs/issues/4670#issuecomment-220698866","issue_url":"https://api.github.com/repos/zfsonlinux/zfs/issues/4670","id":220698866,"user":{"login":"richardelling","id":867533,"avatar_url":"https://avatars.githubusercontent.com/u/867533?v=3","gravatar_id":"","url":"https://api.github.com/users/richardelling","html_url":"https://github.com/richardelling","followers_url":"https://api.github.com/users/richardelling/followers","following_url":"https://api.github.com/users/richardelling/following{/other_user}","gists_url":"https://api.github.com/users/richardelling/gists{/gist_id}","starred_url":"https://api.github.com/users/richardelling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardelling/subscriptions","organizations_url":"https://api.github.com/users/richardelling/orgs","repos_url":"https://api.github.com/users/richardelling/repos","events_url":"https://api.github.com/users/richardelling/events{/privacy}","received_events_url":"https://api.github.com/users/richardelling/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T19:34:43Z","updated_at":"2016-05-20T19:34:43Z","body":"Try: zpool get  health\r\n"}}
{"actor":{"display_login":"richardelling"}}