Storage
banshee/storage-collection/storage/netapp/https/ontap-9.6/
disks
The state and the container of each disk of a NetApp ONTAP cluster, to see a broken disk, by its REST API.
by banshee1 installation1 version
Published on October 27, 2026. First version.
// The disks of a NetApp ONTAP cluster, by its REST API (GET /api/storage/disks), which ONTAP serves from 9.6:
// the state of each, and what it serves (an aggregate, a spare...), so that a broken disk is seen.
// The address of the API is the cluster's management address, the host's: https://<host:address>/api/.
need('protocol:http');
$address = need('host:address');
$user = need('protocol:http:user');
$password = need('protocol:http:password');
per('disk', 'Disks');
output('state', 'text', array('label' => 'State', 'per' => 'disk'));
output('container', 'text', array('label' => 'Container', 'per' => 'disk'));
watch.state('failed', 'Disk broken', 'state', array(
'warning' => array('maintenance', 'reconstructing', 'removed', 'unfail'),
'critical' => array('broken'),
));
watch.state('unowned', 'Disk not in use', 'container', array('warning' => array('unassigned', 'foreign', 'unsupported', 'unknown'), 'enabled' => false));
watch.missing('missing', 'Disk missing', 'state', array('enabled' => false));
// One page of records at a time: ONTAP gives the next page's path under _links.next.href when it cuts the
// list, until the last. The password goes in Basic: the answer is not secret.
$path = '/api/storage/disks?fields=name,state,container_type&max_records=1000';
$disks = array();
while ($path != '') {
$answer = http.get('https://' . $address . $path, user=$user, password=$password);
if ($answer['status'] == 401 || $answer['status'] == 403) {
fail('misconfigured', 'ONTAP refuses the account, code ' . $answer['status']);
}
if ($answer['status'] != 200) {
fail('unreachable', 'The ONTAP API answers code ' . $answer['status'],
'ONTAP serves its REST API from 9.6.');
}
$page = json.read($answer['body']);
foreach ($page['records'] as $record) {
$disks = list.add($disks, $record);
}
$path = '';
$links = list.get($page, '_links', array());
if (list.has($links, 'next')) {
$path = $links['next']['href'];
}
}
if (list.count($disks) == 0) {
fail('misconfigured', 'The ONTAP API lists no disk', 'ONTAP Select and Cloud Volumes ONTAP may have none to list.');
}
// {"name": "1.0.5", "state": "present", "container_type": "aggregate"}. The states of a disk: broken, copy,
// maintenance, partner, pending, present, reconstructing, removed, spare, unfail, zeroing.
foreach ($disks as $disk) {
$name = $disk['name'];
value('state', list.get($disk, 'state', 'unknown'), $name);
value('container', list.get($disk, 'container_type', 'unknown'), $name);
}