diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa85164 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.pyc +*.pyo +.svn +*.egg-info +build +dist diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..6332391 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,8 @@ +# This graft causes all files located under the ZenPacks/ subdirectory to be +# included in the built ZenPack .egg. Files located in the top-level directory +# of the ZenPack will not be explicitly included. +# +# You can read more about the format and available options available in this +# MANIFEST.in file at the following URL. +# http://docs.python.org/distutils/sourcedist.html +graft ZenPacks diff --git a/README.md b/README.md new file mode 100644 index 0000000..854de5e --- /dev/null +++ b/README.md @@ -0,0 +1,156 @@ +# NetApp 7-Mode ZenPack + +The ZenPack provides monitoring for NetApp data storage devices running ONTAP 7-Mode. Data is collected through ZAPI and ZAPI uses XML and HTTP to communicate with NetApp. NetApp Manageability SDK (NMSDK) provides wrapper around ZAPI in Python. This ZenPack is using these wrapper libraries. I hope I managed to get non-blocking code while waiting for the responses from the NetApp. Python Collector and deferreds are used through code, I hope I did that in a right way. + + + +## Releases + +Version 1.0.0 - [Download](https://github.com/htolic/ZenPacks.CS.NetApp.SevenMode/releases/download/v1.0.0/ZenPacks.CS.NetApp.SevenMode-1.0.0-py2.7.egg) + +- Released: 2019-02-26 +- Requires [PythonCollector ZenPack](https://www.zenoss.com/product/zenpacks/pythoncollector) (>=1.10.1) +- Compatible with Zenoss 4.2.5, Zenoss 6.2.1 + +## Table of contents + +- [NetApp 7-Mode ZenPack](#netapp-7-mode-zenpack) + - [Releases](#releases) + - [Table of contents](#table-of-contents) + - [Features](#features) + - [Device: NetApp 7-Mode](#device-netapp-7-mode) + - [Component: Aggregates](#component-aggregates) + - [Component: Disks](#component-disks) + - [Component: Plexes](#component-plexes) + - [Component: RAID Groups](#component-raid-groups) + - [Component: Spare Disks](#component-spare-disks) + - [Component: Volumes](#component-volumes) + - [Usage](#usage) + - [Changelog](#changelog) + +## Features + +### Device: NetApp 7-Mode + +- Creates Device Class /Storage/NetApp/7Mode +- Creates Event Class /Events/Storage/NetApp +- Adds Modeler Plugin CS.ZAPI.NetApp7Mode + - Models information about device (serial_no, system_id, system_model, ontap_version) + - Models information about components: + - Aggregates (name, state, mount_state, raid_size, raid_status, disk_count, volume_count, plex_count, total_bytes) + - Disks (name, disk_uid, node, raid_state, raid_type, bay, byte_per_sector, disk_type, rpm, model, serialnr, firmware, poweron_hours, grown_defect_list_count, total_bytes) + - Plexes (name, state) + - RAID Groups (name) + - Spare Disks (name, node, disk_uid, raid_state, raid_type, bay, byte_per_sector, disk_type, rpm, model, serialnr, firmware, poweron_hours, grown_defect_list_count, total_bytes) + - Volumes (name, type, block_type, volume_state, mirror_status, inconsistent, unrecoverable, invalid, total_bytes) +- Configuration Properties set on class /Storage/NetApp/7Mode + - zDeviceTemplates - value: NetApp7Mode_Device + - zPythonClass - value: ZenPacks.CS.NetApp.SevenMode.NetAppDevice + - zIcon - value: /zport/dmd/++resource++netapp/img/icon.png + - zSnmpMonitorIgnore - value: true +- New Configuration Properties + - zNetAppFiler - default: [empty] (if empty, device.manageIp is used) + - zNetAppTransport - default: HTTPS + - zNetAppUser - default: root + - zNetAppPassword - default: [empty] +- Monitoring Template + - Python datasource_plugin: NetAppDeviceDSP + - Data Points collected and Graph Definitions: + - Graph "CPU Utilization" - cpu_pct + - Graph "Protocol Ops" - nfs_ops, cifs_ops, http_ops, fcp_ops, iscsi_ops + - Graph "Read-Write Ops" - read_ops, write_ops, total_ops + - Graph "Latency" - sys_read_latency, sys_write_latency, sys_avg_latency + - Graph "Network data" - net_data_recv, net_data_sent + - Graph "Disk data" - disk_data_read, disk_data_written + - Not displayed on any graph - sysUpTime + - Thresholds: + - high CPU utilization + - Type: MinMaxThreshold + - Condition: cpu_pct > 50 + - Triggers: Critical severity event in Event Class /Storage/NetApp + +### Component: Aggregates + +- Monitoring Template + - Python datasource_plugin: NetAppAggregateDSP + - Data Points collected and Graph Definitions: + - Graph "Space Usage" - size_used, size_available + - Graph "Percent Used" - percentage_used + - Graph "Read-Write Data" - user_reads, user_writes + - Thresholds: + - high aggregate usage + - Type: MinMaxThreshold + - Condition: percentage_used > 90 + - Triggers: Critical severity event in Event Class /Storage/NetApp + +### Component: Disks + +- Monitoring Template + - Python datasource_plugin: NetAppDiskDSP + - Data Points collected and Graph Definitions: + - Graph "Space Usage" - size_used, size_available + - Graph "Percent Used" - percentage_used + - Graph "Read-Write Data" - user_reads, user_writes + - Thresholds: + - high disk usage + - Type: MinMaxThreshold + - Condition: percentage_used > 98 + - Triggers: Critical severity event in Event Class /Storage/NetApp + +### Component: Plexes + +- No Monitoring Template available as no usable data is provided through ZAPI +- Only "Plex State" collected by modelling the device + +### Component: RAID Groups + +- No Monitoring Template available as no usable data is provided through ZAPI + +### Component: Spare Disks + +- Monitoring Template + - Python datasource_plugin: NetAppSpareDiskDSP + - Data Points collected and Graph Definitions: + - Graph "Space Usage" - size_used, size_available + - Graph "Percent Used" - percentage_used + - Thresholds: + - high disk usage + - Type: MinMaxThreshold + - Condition: percentage_used > 98 + - Triggers: Critical severity event in Event Class /Storage/NetApp + +### Component: Volumes + +- Monitoring Template + - Python datasource_plugin: NetAppVolumeDSP + - Data Points collected and Graph Definitions: + - Graph "Space Usage" - size_used, size_available + - Graph "Percent Used" - percentage_used + - Graph "Latency" - read_latency, write_latency, avg_latency + - Graph "Read-Write Data" - read_data, write_data + - Thresholds: + - high volume usage + - Type: MinMaxThreshold + - Condition: percentage_used > 70 + - Triggers: Critical severity event in Event Class /Storage/NetApp + +## Usage + +First make sure you are using supported Zenoss version and have ZenPack dependencies on right version installed. Then proceed to download and install this ZenPack using a standard procedure for your version of Zenoss. + +This ZenPack monitors NetApp storage devices running only ONTAP 7-Mode. It is tested against NetApp Release 8.2.3 7-Mode. NetApp C-Mode is not supported with this ZenPack and it will not work. + +After installation the device class /Storage/NetApp/7Mode is created. Go ahead and modify Configuration Properties for this device class. Look for properties that have name starting with zNetApp. + +- zNetAppFiler: This is IP address where ZAPI listens for API requests. Leave this empty if IP address you enter when adding device is the same as IP address of NetApp Controller management interface (this is where ZAPI usually listens). If you ever need to change this property, change it per device of course. +- zNetAppTransport: This will either be HTTP (if ZAPI listens on port TCP/80) or HTTPS (if ZAPI listens on port TCP/443). Check your network configuration and firewall rules so Zenoss can reach Filer on either HTTP or HTTPS. +- zNetAppUser: This defaults to root. If you have user prepared especially for Zenoss monitoring then use that user. The user must have privilege to make queries to ZAPI. +- zNetAppPassword: Enter a password related to user that you use in zNetAppUser property. + +Go ahead, add your devices to /Storage/NetApp/7Mode and wait for modelling to finish. If everything goes well, you should see components showing up on device details page. In a couple of minutes the graph data should start populating too. + +## Changelog + +Version 1.0.0 + +- Initial release \ No newline at end of file diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..6352e25 --- /dev/null +++ b/README.txt @@ -0,0 +1,164 @@ +# ZenPack Template +This README describes the structure of the ZenPack template that gets +automatically created by Zenoss when you add a ZenPack through the web +interface. + +## Files +At the top-level a ZenPack must have a setup.py. Almost always a MANIFEST.in +file should exist, and in cases where external dependencies must be built for +inclusion in the ZenPack, a GNUmakefile. Examples of these files with inline +comments are included in this template. + +Also included in the ZenPackTemplate is a configure.zcml. As more of Zenoss' +extensibility moves to using ZCA (Zope Component Architecture) this file +becomes crucial to hooking into various aspects of Zenoss. + +## Files and Subdirectories +The following sections describe the purpose and use for each of the default +subdirectories. Note that if the described functionality is not of use in your +ZenPack it is safe to remove any of the default directories. + +### src/ +The src/ top-level directory in ZenPacks is the conventional place to add +third-party dependencies to your ZenPack. It should only be used as a staging +area to do any build work necessary for the dependency. + +See GNUmakefile (or GNUmakefile.example) for examples of how to have +your third-party dependencies automatically compiled and installed at the right +time and into the right location. + +### ZenPacks/NAMESPACE/PACKNAME/ +The following sections describe the directories contained within the +namespaced ZenPacks/NAMESPACE/PACKNAME/ subdirectories. + +#### bin/ +Any general tools delivered by your ZenPack that would be used by the Zenoss +administrator at the command line should go into this directory by convention. +When the ZenPack is installed all files in this directory will be made +executable. + +#### browser/ +The browser subdirectory should contain all code and configuration that's +specific to the Zenoss web interface. The provided configure.zcml will +automatically load the example browser/configure.zcml and register the +browser/resources/ subdirectory to serve static web content. + +#### daemons/ +All files in the daemons/ subdirectory get special handling. Upon installing +the ZenPack, the following actions will occur. + + 1. The file will be made executable (chmod 0755) + 2. A symlink to the file will be created in $ZENHOME/bin/ + 3. An configuration file will be generated at $ZENHOME/etc/DAEMON_NAME.conf + +Assuming that you don't have a $ZENHOME/etc/DAEMONS_TXT_ONLY file this daemon +will also become part of the normal zenoss start and stop processes. + +You can find an example daemon control script in daemons/zenexample. For most +purposes this file can be renamed to the name of the daemon you want to create +and modified to change the DAEMON_NAME. No other modifications are typically +needed. Note that this example control script does expect to launch the real +daemon code which should be located at ../DAEMON_NAME.py. + +#### datasources/ +Any new datasource types you want to add must be added as classes into the +datasources/ subdirectory. When Zenoss is building the list of available +datasources it will scan the datasources/ subdirectory for all installed +ZenPacks. + +An example datasource at datasources/ExampleDataSource.py.example. + +#### lib/ +The lib/ directory should be the installation target for any third-party +libraries that are built by the GNUmakefile. It can also be used as the +conventional location to drop Python-only libraries that don't require +any compilation or special installation. + +#### libexec/ +Any scripts executed by COMMAND datasources in your ZenPack go in this +directory by convention. When the ZenPack is installed all files in this +directory will be made executable. + +#### migrate/ +ZenPacks can include migrate scripts that allow you to run custom code to +handle any tasks that are needed to upgrade your ZenPack from one version to +another. All .py files in this migrate/ subdirectory will be evaluated when the +ZenPack is installed. + +You can find an example migrate script at migrate/ExampleMigration.py. + +#### modeler/ +Any modeler plugins distributed with your ZenPack must be located under the +plugins/ subdirectory. The directory structure and filenames under plugins/ +map directly to the plugins' name in the user interface. For example, if you +wanted to create a modeler plugin called "community.snmp.ExampleMap" you would +create the following directory structure. + +It is recommended that the first portion of the namespace be a short lowercase +form of your name, or organization's name. Alternatively you can choose to use +"community" if you plan to publish the ZenPack and are open to outside +contributions. Zenoss, Inc. will always use "zenoss." The second portion of the +namespace can be the protocol that is used to collect the data. If you are not +using a common protocol it is acceptable to skip the second portion of the +namespace and have something like "community.MongoDB" instead. + +plugins/ + __init__.py + community/ + __init__.py + snmp/ + __init__.py + ExampleMap.py + +Note that the __init__.py files must exist and should be empty files. Otherwise +your modeler plugins won't be imported and usable within Zenoss. + +#### objects/ +All .xml files in this objects/ directory will be loaded into the object +database when the ZenPack installs. All of the objects defined in the XML files +will be automatically associated with the ZenPack. + +When you export the ZenPack from the user interface all objects associated with +the ZenPack will be exported into a file called "objects.xml" specifically. For +this reason it is recommended to let Zenoss manage the objects.xml file and to +never manually create or modify any .xml files in this directory unless you +know what you're doing. + +When a ZenPack is removed, any objects associated with the ZenPack will be +recursively removed from Zenoss. For example, if you associated the /Server +device class with your ZenPack and removed the ZenPack, the /Server device +class, and all devices within it would also be deleted. + +When a ZenPack is upgraded, or re-installed on top of itself, all objects in +the XML files are overlaid on the existing object database. This results in a +merge of the existing objects and what are defined in the XML files with the +XML file properties and relationships winning any conflicts. + +#### reports/ +Custom reports will be loaded from this directory when the ZenPack is +installed. Subdirectories (with the exception of plugins/) will be mapped +directly to the report folders in the web interface. So if you add a .rpt file +into a subdirectory named "Performance Reports" you will find your report in +the Performance Reports folder in the web interface after installing the +ZenPack. + +The plugins/ subdirectory should include any Python plugins your custom reports +call. So if your .rpt file contains a line such as the following.. + +objects python:here.ReportServer.plugin('myplugin', tableState); + +There should be a corresponding myplugin.py file in the plugins/ subdirectory. + +You can find an example report at Example Reports/Example Report.rpt.example +that uses a plugin which can be found at plugins/example_plugin.py. + +#### services/ +ZenHub services will be loaded from the services/ directory. These services +run inside the zenhub daemon and are responsible from all interaction with +collector daemons. + +You can find an example service at services/ExampleConfigService.py. + +#### tests/ +All unit tests for your ZenPack should live in this directory. You can find an +example test suite at tests/testExample.py. diff --git a/ZenPacks/CS/NetApp/SevenMode/Aggregate.py b/ZenPacks/CS/NetApp/SevenMode/Aggregate.py new file mode 100644 index 0000000..740ec0f --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/Aggregate.py @@ -0,0 +1,68 @@ +from Products.ZenModel.DeviceComponent import DeviceComponent +from Products.ZenModel.ManagedEntity import ManagedEntity +from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE, ZEN_VIEW +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class Aggregate(DeviceComponent, ManagedEntity): + meta_type = portal_type = 'NetAppAggregate' + + aggr_name = None + aggr_state = None + mount_state = None + raid_size = None + raid_status = None + disk_count = None + volume_count = None + plex_count = None + total_bytes = None + + _properties = ManagedEntity._properties + ( + {'id': 'aggr_name', 'type': 'string'}, + {'id': 'aggr_state', 'type': 'string'}, + {'id': 'mount_state', 'type': 'string'}, + {'id': 'raid_size', 'type': 'int'}, + {'id': 'raid_status', 'type': 'string'}, + {'id': 'disk_count', 'type': 'int'}, + {'id': 'volume_count', 'type': 'int'}, + {'id': 'plex_count', 'type': 'int'}, + {'id': 'total_bytes', 'type': 'long'}, + ) + + _relations = ManagedEntity._relations + ( + ('netapp_device', + ToOne(ToManyCont, + 'ZenPacks.CS.NetApp.SevenMode.NetAppDevice', + 'aggregates') + ), + ('plexes', + ToManyCont(ToOne, + 'ZenPacks.CS.NetApp.SevenMode.Plex', + 'aggregate') + ), + ('volumes', + ToManyCont(ToOne, + 'ZenPacks.CS.NetApp.SevenMode.Volume', + 'aggregate') + ), + ('spare_disks', + ToManyCont(ToOne, + 'ZenPacks.CS.NetApp.SevenMode.SpareDisk', + 'aggregate') + ), + ) + + factory_type_information = ({ + 'actions': ({ + 'id': 'perfConf', + 'name': 'Template', + 'action': 'objTemplates', + 'permissions': (ZEN_CHANGE_DEVICE,), + },), + },) + + def device(self): + return self.netapp_device() + + def getRRDTemplateName(self): + return 'NetApp7Mode_Aggregate' diff --git a/ZenPacks/CS/NetApp/SevenMode/COPYRIGHT.txt b/ZenPacks/CS/NetApp/SevenMode/COPYRIGHT.txt new file mode 100644 index 0000000..3db8f6c --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/COPYRIGHT.txt @@ -0,0 +1,16 @@ +# Copyright 2019 CS Computer Systems, Croatia (htolic@cs.hr) +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 or (at your +# option) any later version as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. +# diff --git a/ZenPacks/CS/NetApp/SevenMode/Disk.py b/ZenPacks/CS/NetApp/SevenMode/Disk.py new file mode 100644 index 0000000..f7d8072 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/Disk.py @@ -0,0 +1,65 @@ +from Products.ZenModel.DeviceComponent import DeviceComponent +from Products.ZenModel.ManagedEntity import ManagedEntity +from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE, ZEN_VIEW +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class Disk(DeviceComponent, ManagedEntity): + meta_type = portal_type = 'NetAppDisk' + + disk_name = None + disk_uid = None + node = None + raid_state = None + raid_type = None + bay = None + byte_per_sector = None + disk_type = None + rpm = None + model = None + serialnr = None + firmware = None + poweron_hours = None + grown_defect_list_count = None + total_bytes = None + + _properties = ManagedEntity._properties + ( + {'id': 'disk_name', 'type': 'string'}, + {'id': 'disk_uid', 'type': 'string'}, + {'id': 'node', 'type': 'string'}, + {'id': 'raid_state', 'type': 'string'}, + {'id': 'raid_type', 'type': 'string'}, + {'id': 'bay', 'type': 'int'}, + {'id': 'byte_per_sector', 'type': 'int'}, + {'id': 'disk_type', 'type': 'string'}, + {'id': 'rpm', 'type': 'int'}, + {'id': 'model', 'type': 'string'}, + {'id': 'serialnr', 'type': 'string'}, + {'id': 'firmware', 'type': 'string'}, + {'id': 'poweron_hours', 'type': 'int'}, + {'id': 'grown_defect_list_count', 'type': 'int'}, + {'id': 'total_bytes', 'type': 'long'}, + ) + + _relations = ManagedEntity._relations + ( + ('raid_group', + ToOne(ToManyCont, + 'ZenPacks.CS.NetApp.SevenMode.RaidGroup', + 'disks') + ), + ) + + factory_type_information = ({ + 'actions': ({ + 'id': 'perfConf', + 'name': 'Template', + 'action': 'objTemplates', + 'permissions': (ZEN_CHANGE_DEVICE,), + },), + },) + + def device(self): + return self.raid_group().plex().aggregate().netapp_device() + + def getRRDTemplateName(self): + return 'NetApp7Mode_Disk' diff --git a/ZenPacks/CS/NetApp/SevenMode/LICENSE.txt b/ZenPacks/CS/NetApp/SevenMode/LICENSE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/LICENSE.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ZenPacks/CS/NetApp/SevenMode/NetAppDevice.py b/ZenPacks/CS/NetApp/SevenMode/NetAppDevice.py new file mode 100644 index 0000000..89e5b96 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/NetAppDevice.py @@ -0,0 +1,15 @@ +from Products.ZenModel.Device import Device +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class NetAppDevice(Device): + """NetApp Device""" + meta_type = portal_type = 'NetAppDevice' + + _relations = Device._relations + ( + ('aggregates', + ToManyCont(ToOne, + 'ZenPacks.CS.NetApp.SevenMode.Aggregate', + 'netapp_device') + ), + ) diff --git a/ZenPacks/CS/NetApp/SevenMode/Plex.py b/ZenPacks/CS/NetApp/SevenMode/Plex.py new file mode 100644 index 0000000..1880881 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/Plex.py @@ -0,0 +1,44 @@ +from Products.ZenModel.DeviceComponent import DeviceComponent +from Products.ZenModel.ManagedEntity import ManagedEntity +from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class Plex(DeviceComponent, ManagedEntity): + meta_type = portal_type = 'NetAppPlex' + + plex_name = None + plex_state = None + + _properties = ManagedEntity._properties + ( + {'id': 'plex_name', 'type': 'string'}, + {'id': 'plex_state', 'type': 'boolean'}, + ) + + _relations = ManagedEntity._relations + ( + ('aggregate', + ToOne(ToManyCont, + 'ZenPacks.CS.NetApp.SevenMode.Aggregate', + 'plexes') + ), + ('raid_groups', + ToManyCont(ToOne, + 'ZenPacks.CS.NetApp.SevenMode.RaidGroup', + 'plex') + ), + ) + + factory_type_information = ({ + 'actions': ({ + 'id': 'perfConf', + 'name': 'Template', + 'action': 'objTemplates', + 'permissions': (ZEN_CHANGE_DEVICE,), + },), + },) + + def device(self): + return self.aggregate().netapp_device() + + def getRRDTemplateName(self): + return 'NetApp7Mode_Plex' diff --git a/ZenPacks/CS/NetApp/SevenMode/RaidGroup.py b/ZenPacks/CS/NetApp/SevenMode/RaidGroup.py new file mode 100644 index 0000000..2385eb8 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/RaidGroup.py @@ -0,0 +1,42 @@ +from Products.ZenModel.DeviceComponent import DeviceComponent +from Products.ZenModel.ManagedEntity import ManagedEntity +from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class RaidGroup(DeviceComponent, ManagedEntity): + meta_type = portal_type = 'NetAppRaidGroup' + + rg_name = None + + _properties = ManagedEntity._properties + ( + {'id': 'rg_name', 'type': 'string'}, + ) + + _relations = ManagedEntity._relations + ( + ('plex', + ToOne(ToManyCont, + 'ZenPacks.CS.NetApp.SevenMode.Plex', + 'raid_groups') + ), + ('disks', + ToManyCont(ToOne, + 'ZenPacks.CS.NetApp.SevenMode.Disk', + 'raid_group') + ), + ) + + factory_type_information = ({ + 'actions': ({ + 'id': 'perfConf', + 'name': 'Template', + 'action': 'objTemplates', + 'permissions': (ZEN_CHANGE_DEVICE,), + },), + },) + + def device(self): + return self.plex().aggregate().netapp_device() + + def getRRDTemplateName(self): + return 'NetApp7Mode_RaidGroup' diff --git a/ZenPacks/CS/NetApp/SevenMode/SpareDisk.py b/ZenPacks/CS/NetApp/SevenMode/SpareDisk.py new file mode 100644 index 0000000..6388ccb --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/SpareDisk.py @@ -0,0 +1,65 @@ +from Products.ZenModel.DeviceComponent import DeviceComponent +from Products.ZenModel.ManagedEntity import ManagedEntity +from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE, ZEN_VIEW +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class SpareDisk(DeviceComponent, ManagedEntity): + meta_type = portal_type = 'NetAppSpareDisk' + + sparedisk_name = None + disk_uid = None + node = None + raid_state = None + raid_type = None + bay = None + byte_per_sector = None + disk_type = None + rpm = None + model = None + serialnr = None + firmware = None + poweron_hours = None + grown_defect_list_count = None + total_bytes = None + + _properties = ManagedEntity._properties + ( + {'id': 'sparedisk_name', 'type': 'string'}, + {'id': 'disk_uid', 'type': 'string'}, + {'id': 'node', 'type': 'string'}, + {'id': 'raid_state', 'type': 'string'}, + {'id': 'raid_type', 'type': 'string'}, + {'id': 'bay', 'type': 'int'}, + {'id': 'byte_per_sector', 'type': 'int'}, + {'id': 'disk_type', 'type': 'string'}, + {'id': 'rpm', 'type': 'int'}, + {'id': 'model', 'type': 'string'}, + {'id': 'serialnr', 'type': 'string'}, + {'id': 'firmware', 'type': 'string'}, + {'id': 'poweron_hours', 'type': 'int'}, + {'id': 'grown_defect_list_count', 'type': 'int'}, + {'id': 'total_bytes', 'type': 'long'}, + ) + + _relations = ManagedEntity._relations + ( + ('aggregate', + ToOne(ToManyCont, + 'ZenPacks.CS.NetApp.SevenMode.Aggregate', + 'spare_disks') + ), + ) + + factory_type_information = ({ + 'actions': ({ + 'id': 'perfConf', + 'name': 'Template', + 'action': 'objTemplates', + 'permissions': (ZEN_CHANGE_DEVICE,), + },), + },) + + def device(self): + return self.aggregate().netapp_device() + + def getRRDTemplateName(self): + return 'NetApp7Mode_SpareDisk' diff --git a/ZenPacks/CS/NetApp/SevenMode/Utils.py b/ZenPacks/CS/NetApp/SevenMode/Utils.py new file mode 100644 index 0000000..83a1a50 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/Utils.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + + +class Utils(object): + + def _delta(self, a2, a1): + return a2 - a1 + + def _rate(self, a2, a1, t2, t1): + if (t2 == t1): + return 0. + return self._delta(a2, a1) / self._delta(t2, t1) + + def _average(self, a2, a1, b2, b1): + return self._rate(a2, a1, b2, b1) + + def _percent(self, a2, a1, b2, b1): + return 100 * self._average(a2, a1, b2, b1) diff --git a/ZenPacks/CS/NetApp/SevenMode/Volume.py b/ZenPacks/CS/NetApp/SevenMode/Volume.py new file mode 100644 index 0000000..5e9dd4d --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/Volume.py @@ -0,0 +1,53 @@ +from Products.ZenModel.DeviceComponent import DeviceComponent +from Products.ZenModel.ManagedEntity import ManagedEntity +from Products.ZenModel.ZenossSecurity import ZEN_CHANGE_DEVICE, ZEN_VIEW +from Products.ZenRelations.RelSchema import ToManyCont, ToOne + + +class Volume(DeviceComponent, ManagedEntity): + meta_type = portal_type = 'NetAppVolume' + + volume_name = None + volume_type = None + block_type = None + volume_state = None + mirror_status = None + inconsistent = None + unrecoverable = None + invalid = None + total_bytes = None + + _properties = ManagedEntity._properties + ( + {'id': 'volume_name', 'type': 'string'}, + {'id': 'volume_type', 'type': 'string'}, + {'id': 'block_type', 'type': 'string'}, + {'id': 'volume_state', 'type': 'string'}, + {'id': 'mirror_status', 'type': 'string'}, + {'id': 'inconsistent', 'type': 'string'}, + {'id': 'unrecoverable', 'type': 'string'}, + {'id': 'invalid', 'type': 'string'}, + {'id': 'total_bytes', 'type': 'long'}, + ) + + _relations = ManagedEntity._relations + ( + ('aggregate', + ToOne(ToManyCont, + 'ZenPacks.CS.NetApp.SevenMode.Aggregate', + 'volumes') + ), + ) + + factory_type_information = ({ + 'actions': ({ + 'id': 'perfConf', + 'name': 'Template', + 'action': 'objTemplates', + 'permissions': (ZEN_CHANGE_DEVICE,), + },), + },) + + def device(self): + return self.aggregate().netapp_device() + + def getRRDTemplateName(self): + return 'NetApp7Mode_Volume' diff --git a/ZenPacks/CS/NetApp/SevenMode/__init__.py b/ZenPacks/CS/NetApp/SevenMode/__init__.py new file mode 100644 index 0000000..bc85668 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/__init__.py @@ -0,0 +1,40 @@ +import Globals +import os.path + +from Products.ZenModel.ZenPack import ZenPackBase +from Products.CMFCore.DirectoryView import registerDirectory + +skinsDir = os.path.join(os.path.dirname(__file__), 'skins') +if os.path.isdir(skinsDir): + registerDirectory(skinsDir, globals()) + + +class ZenPack(ZenPackBase): + packZProperties = [ + ('zNetAppFiler', '', 'string'), + ('zNetAppUser', 'root', 'string'), + ('zNetAppPassword', '', 'password'), + ('zNetAppTransport', 'HTTPS', 'string'), + ] + + def install(self, app): + sevenMode = app.getDmdRoot( + 'Devices').createOrganizer('Storage/NetApp/7Mode') + + super(ZenPack, self).install(app) + + plugins = [ + 'CS.ZAPI.NetApp7Mode', + ] + + templates = [ + 'NetApp7Mode_Device', + ] + + sevenMode.setZenProperty('zCollectorPlugins', plugins) + sevenMode.setZenProperty('zDeviceTemplates', templates) + sevenMode.setZenProperty( + 'zPythonClass', 'ZenPacks.CS.NetApp.SevenMode.NetAppDevice') + sevenMode.setZenProperty('zSnmpMonitorIgnore', 'true') + sevenMode.setZenProperty( + 'zIcon', '/zport/dmd/++resource++netapp/img/icon.png') diff --git a/ZenPacks/CS/NetApp/SevenMode/browser/__init__.py b/ZenPacks/CS/NetApp/SevenMode/browser/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks/CS/NetApp/SevenMode/browser/configure.zcml b/ZenPacks/CS/NetApp/SevenMode/browser/configure.zcml new file mode 100644 index 0000000..1ecc5a3 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/browser/configure.zcml @@ -0,0 +1,36 @@ + + + + + + + + + + diff --git a/ZenPacks/CS/NetApp/SevenMode/browser/resources/img/icon.png b/ZenPacks/CS/NetApp/SevenMode/browser/resources/img/icon.png new file mode 100644 index 0000000..8e26dc3 Binary files /dev/null and b/ZenPacks/CS/NetApp/SevenMode/browser/resources/img/icon.png differ diff --git a/ZenPacks/CS/NetApp/SevenMode/browser/resources/js/NetAppDevice.js b/ZenPacks/CS/NetApp/SevenMode/browser/resources/js/NetAppDevice.js new file mode 100644 index 0000000..8741adc --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/browser/resources/js/NetAppDevice.js @@ -0,0 +1,693 @@ +Ext.onReady(function() { + var DEVICE_OVERVIEW_ID = 'deviceoverviewpanel_summary'; + Ext.ComponentMgr.onAvailable(DEVICE_OVERVIEW_ID, function(){ + var overview = Ext.getCmp(DEVICE_OVERVIEW_ID); + overview.removeField('memory'); + }); +}); + + +(function(){ + +var ZC = Ext.ns('Zenoss.component'); + +ZC.registerName( + 'NetAppAggregate', + _t('Aggregate'), + _t('Aggregates')); + +ZC.NetAppAggregatePanel = Ext.extend(ZC.ComponentGridPanel, { + constructor: function(config) { + config = Ext.applyIf(config||{}, { + componentType: 'NetAppAggregate', + autoExpandColumn: 'aggr_name', + sortInfo: { + field: 'aggr_name', + direction: 'ASC' + }, + fields: [ + {name: 'uid'}, + {name: 'name'}, + {name: 'status'}, + {name: 'severity'}, + {name: 'usesMonitorAttribute'}, + {name: 'monitor'}, + {name: 'monitored'}, + {name: 'locking'}, + + {name: 'aggr_name'}, + {name: 'aggr_state'}, + {name: 'mount_state'}, + {name: 'raid_size'}, + {name: 'raid_status'}, + {name: 'disk_count'}, + {name: 'volume_count'}, + {name: 'plex_count'}, + {name: 'total_bytes'} + ], + columns: [{ + id: 'severity', + dataIndex: 'severity', + header: _t('Events'), + renderer: Zenoss.render.severity, + sortable: true, + width: 50 + },{ + id: 'aggr_name', + dataIndex: 'aggr_name', + header: _t('Aggregate Name'), + sortable: true + },{ + id: 'aggr_state', + dataIndex: 'aggr_state', + header: _t('Aggregate State'), + sortable: true, + width: 120 + },{ + id: 'mount_state', + dataIndex: 'mount_state', + header: _t('Mount State'), + sortable: true, + width: 120 + },{ + id: 'raid_size', + dataIndex: 'raid_size', + header: _t('RAID Size'), + sortable: true, + width: 120 + },{ + id: 'raid_status', + dataIndex: 'raid_status', + header: _t('RAID Status'), + sortable: true, + width: 120 + },{ + id: 'disk_count', + dataIndex: 'disk_count', + header: _t('Disk Count'), + sortable: true, + width: 120 + },{ + id: 'volume_count', + dataIndex: 'volume_count', + header: _t('Volume Count'), + sortable: true, + width: 120 + },{ + id: 'plex_count', + dataIndex: 'plex_count', + header: _t('Plex Count'), + sortable: true, + width: 120 + },{ + id: 'total_bytes', + dataIndex: 'total_bytes', + header: _t('Total Bytes'), + renderer: Zenoss.render.bytesString, + sortable: true, + width: 120 + },{ + id: 'monitored', + dataIndex: 'monitored', + header: _t('Monitored'), + renderer: Zenoss.render.checkbox, + sortable: true, + width: 70 + },{ + id: 'locking', + dataIndex: 'locking', + header: _t('Locking'), + renderer: Zenoss.render.locking_icons, + width: 65 + }] + }); + + ZC.NetAppAggregatePanel.superclass.constructor.call( + this, config); + } +}); + +Ext.reg('NetAppAggregatePanel', ZC.NetAppAggregatePanel); + + +ZC.registerName( + 'NetAppPlex', + _t('Plex'), + _t('Plexes')); + +ZC.NetAppPlexPanel = Ext.extend(ZC.ComponentGridPanel, { + constructor: function(config) { + config = Ext.applyIf(config||{}, { + componentType: 'NetAppPlex', + autoExpandColumn: 'plex_name', + sortInfo: { + field: 'plex_name', + direction: 'ASC' + }, + fields: [ + {name: 'uid'}, + {name: 'name'}, + {name: 'status'}, + {name: 'severity'}, + {name: 'usesMonitorAttribute'}, + {name: 'monitor'}, + {name: 'monitored'}, + {name: 'locking'}, + + {name: 'plex_name'}, + {name: 'plex_state'} + ], + columns: [{ + id: 'severity', + dataIndex: 'severity', + header: _t('Events'), + renderer: Zenoss.render.severity, + sortable: true, + width: 50 + },{ + id: 'plex_name', + dataIndex: 'plex_name', + header: _t('Plex Name'), + sortable: true + },{ + id: 'plex_state', + dataIndex: 'plex_state', + header: _t('Plex State'), + renderer: Zenoss.render.pingStatus, + sortable: true, + width: 120 + },{ + id: 'monitored', + dataIndex: 'monitored', + header: _t('Monitored'), + renderer: Zenoss.render.checkbox, + sortable: true, + width: 70 + },{ + id: 'locking', + dataIndex: 'locking', + header: _t('Locking'), + renderer: Zenoss.render.locking_icons, + width: 65 + }] + }); + + ZC.NetAppPlexPanel.superclass.constructor.call( + this, config); + } +}); + +Ext.reg('NetAppPlexPanel', ZC.NetAppPlexPanel); + + +ZC.registerName( + 'NetAppRaidGroup', + _t('RAID Group'), + _t('RAID Groups')); + +ZC.NetAppRaidGroupPanel = Ext.extend(ZC.ComponentGridPanel, { + constructor: function(config) { + config = Ext.applyIf(config||{}, { + componentType: 'NetAppRaidGroup', + autoExpandColumn: 'rg_name', + sortInfo: { + field: 'rg_name', + direction: 'ASC' + }, + fields: [ + {name: 'uid'}, + {name: 'name'}, + {name: 'status'}, + {name: 'severity'}, + {name: 'usesMonitorAttribute'}, + {name: 'monitor'}, + {name: 'monitored'}, + {name: 'locking'}, + + {name: 'rg_name'} + ], + columns: [{ + id: 'severity', + dataIndex: 'severity', + header: _t('Events'), + renderer: Zenoss.render.severity, + sortable: true, + width: 50 + },{ + id: 'rg_name', + dataIndex: 'rg_name', + header: _t('RAID Group Name'), + sortable: true + },{ + id: 'monitored', + dataIndex: 'monitored', + header: _t('Monitored'), + renderer: Zenoss.render.checkbox, + sortable: true, + width: 70 + },{ + id: 'locking', + dataIndex: 'locking', + header: _t('Locking'), + renderer: Zenoss.render.locking_icons, + width: 65 + }] + }); + + ZC.NetAppRaidGroupPanel.superclass.constructor.call( + this, config); + } +}); + +Ext.reg('NetAppRaidGroupPanel', ZC.NetAppRaidGroupPanel); + + +ZC.registerName( + 'NetAppDisk', + _t('Disk'), + _t('Disks')); + +ZC.NetAppDiskPanel = Ext.extend(ZC.ComponentGridPanel, { + constructor: function(config) { + config = Ext.applyIf(config||{}, { + componentType: 'NetAppDisk', + autoExpandColumn: 'severity', + sortInfo: { + field: 'disk_name', + direction: 'ASC' + }, + fields: [ + {name: 'uid'}, + {name: 'name'}, + {name: 'status'}, + {name: 'severity'}, + {name: 'usesMonitorAttribute'}, + {name: 'monitor'}, + {name: 'monitored'}, + {name: 'locking'}, + + {name: 'disk_name'}, + {name: 'node'}, + {name: 'raid_state'}, + {name: 'raid_type'}, + {name: 'bay'}, + {name: 'byte_per_sector'}, + {name: 'disk_type'}, + {name: 'rpm'}, + {name: 'model'}, + {name: 'serialnr'}, + {name: 'firmware'}, + {name: 'poweron_hours'}, + {name: 'grown_defect_list_count'}, + {name: 'total_bytes'} + ], + columns: [{ + id: 'severity', + dataIndex: 'severity', + header: _t('Events'), + renderer: Zenoss.render.severity, + sortable: true, + width: 50 + },{ + id: 'disk_name', + dataIndex: 'disk_name', + header: _t('Disk Name'), + sortable: true, + width: 80 + },{ + id: 'node', + dataIndex: 'node', + header: _t('Node'), + sortable: true, + width: 110 + },{ + id: 'raid_state', + dataIndex: 'raid_state', + header: _t('RAID State'), + sortable: true, + width: 90 + },{ + id: 'raid_type', + dataIndex: 'raid_type', + header: _t('RAID Type'), + sortable: true, + width: 90 + },{ + id: 'bay', + dataIndex: 'bay', + header: _t('Bay'), + sortable: true, + width: 50 + },{ + id: 'byte_per_sector', + dataIndex: 'byte_per_sector', + header: _t('Byte Per Sector'), + sortable: true, + width: 100 + },{ + id: 'disk_type', + dataIndex: 'disk_type', + header: _t('Disk Type'), + sortable: true, + width: 80 + },{ + id: 'rpm', + dataIndex: 'rpm', + header: _t('RPMs'), + sortable: true, + width: 70 + },{ + id: 'model', + dataIndex: 'model', + header: _t('Model'), + sortable: true, + width: 130 + },{ + id: 'serialnr', + dataIndex: 'serialnr', + header: _t('Serial Number'), + sortable: true, + width: 100 + },{ + id: 'firmware', + dataIndex: 'firmware', + header: _t('Firmware'), + sortable: true, + width: 80 + },{ + id: 'poweron_hours', + dataIndex: 'poweron_hours', + header: _t('Poweron Hours'), + sortable: true, + width: 95 + },{ + id: 'grown_defect_list_count', + dataIndex: 'grown_defect_list_count', + header: _t('Grown Defect List Count'), + sortable: true, + width: 130 + },{ + id: 'total_bytes', + dataIndex: 'total_bytes', + header: _t('Total Bytes'), + renderer: Zenoss.render.bytesString, + sortable: true, + width: 80 + },{ + id: 'monitored', + dataIndex: 'monitored', + header: _t('Monitored'), + renderer: Zenoss.render.checkbox, + sortable: true, + width: 70 + },{ + id: 'locking', + dataIndex: 'locking', + header: _t('Locking'), + renderer: Zenoss.render.locking_icons, + width: 65 + }] + }); + + ZC.NetAppDiskPanel.superclass.constructor.call( + this, config); + } +}); + +Ext.reg('NetAppDiskPanel', ZC.NetAppDiskPanel); + + +ZC.registerName( + 'NetAppVolume', + _t('Volume'), + _t('Volumes')); + +ZC.NetAppVolumePanel = Ext.extend(ZC.ComponentGridPanel, { + constructor: function(config) { + config = Ext.applyIf(config||{}, { + componentType: 'NetAppVolume', + autoExpandColumn: 'volume_name', + sortInfo: { + field: 'volume_name', + direction: 'ASC' + }, + fields: [ + {name: 'uid'}, + {name: 'name'}, + {name: 'status'}, + {name: 'severity'}, + {name: 'usesMonitorAttribute'}, + {name: 'monitor'}, + {name: 'monitored'}, + {name: 'locking'}, + + {name: 'volume_name'}, + {name: 'volume_type'}, + {name: 'block_type'}, + {name: 'volume_state'}, + {name: 'mirror_status'}, + {name: 'inconsistent'}, + {name: 'unrecoverable'}, + {name: 'invalid'}, + {name: 'total_bytes'} + ], + columns: [{ + id: 'severity', + dataIndex: 'severity', + header: _t('Events'), + renderer: Zenoss.render.severity, + sortable: true, + width: 50 + },{ + id: 'volume_name', + dataIndex: 'volume_name', + header: _t('Volume Name'), + sortable: true + },{ + id: 'volume_type', + dataIndex: 'volume_type', + header: _t('Volume Type'), + sortable: true, + width: 120 + },{ + id: 'block_type', + dataIndex: 'block_type', + header: _t('Block Type'), + sortable: true, + width: 120 + },{ + id: 'volume_state', + dataIndex: 'volume_state', + header: _t('Volume State'), + sortable: true, + width: 120 + },{ + id: 'mirror_status', + dataIndex: 'mirror_status', + header: _t('Mirror Status'), + sortable: true, + width: 120 + },{ + id: 'inconsistent', + dataIndex: 'inconsistent', + header: _t('Inconsistent'), + sortable: true, + width: 120 + },{ + id: 'unrecoverable', + dataIndex: 'unrecoverable', + header: _t('Unrecoverable'), + sortable: true, + width: 120 + },{ + id: 'invalid', + dataIndex: 'invalid', + header: _t('Invalid'), + sortable: true, + width: 120 + },{ + id: 'total_bytes', + dataIndex: 'total_bytes', + header: _t('Total Bytes'), + renderer: Zenoss.render.bytesString, + sortable: true, + width: 120 + },{ + id: 'monitored', + dataIndex: 'monitored', + header: _t('Monitored'), + renderer: Zenoss.render.checkbox, + sortable: true, + width: 70 + },{ + id: 'locking', + dataIndex: 'locking', + header: _t('Locking'), + renderer: Zenoss.render.locking_icons, + width: 65 + }] + }); + + ZC.NetAppVolumePanel.superclass.constructor.call( + this, config); + } +}); + +Ext.reg('NetAppVolumePanel', ZC.NetAppVolumePanel); + + +ZC.registerName( + 'NetAppSpareDisk', + _t('Spare Disk'), + _t('Spare Disks')); + +ZC.NetAppSpareDiskPanel = Ext.extend(ZC.ComponentGridPanel, { + constructor: function(config) { + config = Ext.applyIf(config||{}, { + componentType: 'NetAppSpareDisk', + autoExpandColumn: 'severity', + sortInfo: { + field: 'sparedisk_name', + direction: 'ASC' + }, + fields: [ + {name: 'uid'}, + {name: 'name'}, + {name: 'status'}, + {name: 'severity'}, + {name: 'usesMonitorAttribute'}, + {name: 'monitor'}, + {name: 'monitored'}, + {name: 'locking'}, + + {name: 'sparedisk_name'}, + {name: 'node'}, + {name: 'raid_state'}, + {name: 'raid_type'}, + {name: 'bay'}, + {name: 'byte_per_sector'}, + {name: 'disk_type'}, + {name: 'rpm'}, + {name: 'model'}, + {name: 'serialnr'}, + {name: 'firmware'}, + {name: 'poweron_hours'}, + {name: 'grown_defect_list_count'}, + {name: 'total_bytes'} + ], + columns: [{ + id: 'severity', + dataIndex: 'severity', + header: _t('Events'), + renderer: Zenoss.render.severity, + sortable: true, + width: 50 + },{ + id: 'sparedisk_name', + dataIndex: 'sparedisk_name', + header: _t('Spare Disk Name'), + sortable: true, + width: 100 + },{ + id: 'node', + dataIndex: 'node', + header: _t('Node'), + sortable: true, + width: 110 + },{ + id: 'raid_state', + dataIndex: 'raid_state', + header: _t('RAID State'), + sortable: true, + width: 90 + },{ + id: 'raid_type', + dataIndex: 'raid_type', + header: _t('RAID Type'), + sortable: true, + width: 90 + },{ + id: 'bay', + dataIndex: 'bay', + header: _t('Bay'), + sortable: true, + width: 50 + },{ + id: 'byte_per_sector', + dataIndex: 'byte_per_sector', + header: _t('Byte Per Sector'), + sortable: true, + width: 100 + },{ + id: 'disk_type', + dataIndex: 'disk_type', + header: _t('Disk Type'), + sortable: true, + width: 80 + },{ + id: 'rpm', + dataIndex: 'rpm', + header: _t('RPMs'), + sortable: true, + width: 70 + },{ + id: 'model', + dataIndex: 'model', + header: _t('Model'), + sortable: true, + width: 130 + },{ + id: 'serialnr', + dataIndex: 'serialnr', + header: _t('Serial Number'), + sortable: true, + width: 100 + },{ + id: 'firmware', + dataIndex: 'firmware', + header: _t('Firmware'), + sortable: true, + width: 80 + },{ + id: 'poweron_hours', + dataIndex: 'poweron_hours', + header: _t('Poweron Hours'), + sortable: true, + width: 95 + },{ + id: 'grown_defect_list_count', + dataIndex: 'grown_defect_list_count', + header: _t('Grown Defect List Count'), + sortable: true, + width: 130 + },{ + id: 'total_bytes', + dataIndex: 'total_bytes', + header: _t('Total Bytes'), + renderer: Zenoss.render.bytesString, + sortable: true, + width: 80 + },{ + id: 'monitored', + dataIndex: 'monitored', + header: _t('Monitored'), + renderer: Zenoss.render.checkbox, + sortable: true, + width: 70 + },{ + id: 'locking', + dataIndex: 'locking', + header: _t('Locking'), + renderer: Zenoss.render.locking_icons, + width: 65 + }] + }); + + ZC.NetAppSpareDiskPanel.superclass.constructor.call( + this, config); + } +}); + +Ext.reg('NetAppSpareDiskPanel', ZC.NetAppSpareDiskPanel); + +})(); diff --git a/ZenPacks/CS/NetApp/SevenMode/configure.zcml b/ZenPacks/CS/NetApp/SevenMode/configure.zcml new file mode 100644 index 0000000..0c95afc --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/configure.zcml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppAggregateDSP.py b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppAggregateDSP.py new file mode 100644 index 0000000..729c9b0 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppAggregateDSP.py @@ -0,0 +1,204 @@ +import time +import logging +log = logging.getLogger('zen.netAppAggregateDSP') + +from xml.etree import ElementTree +from twisted.internet.defer import inlineCallbacks, returnValue, DeferredList +from Products.ZenEvents import ZenEventClasses +from ZenPacks.zenoss.PythonCollector.datasources.PythonDataSource \ + import PythonDataSourcePlugin +from ZenPacks.CS.NetApp.SevenMode.lib.ZenOntap import * +from ZenPacks.CS.NetApp.SevenMode.Utils import Utils + +class NetAppAggregateDSP(PythonDataSourcePlugin, Utils): + """Python Datasource Plugin to collect graph data for NetApp device.""" + + proxy_attributes = ( + 'zNetAppFiler', + 'zNetAppUser', + 'zNetAppPassword', + 'zNetAppTransport', + ) + + def _generate_request(self, perfGet): + request = NaElement('perf-object-get-instances') + for perf, instances in perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter[0]) + try: + reqcnts.child_add_string('counter', counter[2]) + except: + pass + request.child_add(reqcnts) + request.child_add(reqinst) + return request + + def _get_elements(self, defs): + naElements = [] + for success, result in defs: + if success: + status = result.results_status() + if status == 'passed': + naElements.append(result) + elif status == 'failed': + log.error('%s', result.results_reason()) + else: + log.error(result.printTraceback()) + return None + return naElements + + def _get_nodes(self, naElements): + nodes = {} + for element in naElements: + if element.child_get('instances') is not None: + ts = int(element.child_get_string('timestamp')) + nodes[ts] = {} + for instance in element.child_get('instances').children_get(): + nameEl, perfEl = instance.children_get() + name = instance.child_get_string('name') + nodes[ts][name] = perfEl.children_get() + return nodes + + @inlineCallbacks + def collect(self, config): + ds0 = config.datasources[0] + if ds0.zNetAppFiler == '': + ds0.zNetAppFiler = ds0.manageIp + + server = ZenOntap(ds0.zNetAppFiler, + ds0.zNetAppUser, + ds0.zNetAppPassword, + ds0.zNetAppTransport) + + perfGet = { + 'aggregate': + dict.fromkeys( + [ds.component for ds in config.datasources], + [ + ('user_reads', 'RATE'), + ('user_writes', 'RATE'), + ] + ) + } + + results = {} + request = self._generate_request(perfGet) + + ############## + response1 = server.invoke_elem_async(request) + deferreds = [response1] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes1 = self._get_nodes(naElements) + + for ts, components in tsnodes1.iteritems(): + results[ts] = {} + for component, nodes in components.iteritems(): + results[ts][component] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][component][dkey] = float(dvalue) + ############### + time.sleep(1) + ############### + response2 = server.invoke_elem_async(request) + deferreds = [response2] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes2 = self._get_nodes(naElements) + + for ts, components in tsnodes2.iteritems(): + results[ts] = {} + for component, nodes in components.iteritems(): + results[ts][component] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][component][dkey] = float(dvalue) + ############### + + request = NaElement('aggr-list-info') + request.child_add_string('verbose', 'true') + response = server.invoke_elem_async(request) + deferreds = [response] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + aggregates = naElements[0].child_get('aggregates') + for aggregate in aggregates.children_get(): + component = aggregate.child_get_string('name') + results[ts][component]['size_used'] = aggregate.child_get_int('size-used') + results[ts][component]['size_available'] = aggregate.child_get_int('size-available') + results[ts][component]['percentage_used'] = aggregate.child_get_int('size-percentage-used') + + log.debug('%s', results) + returnValue(results) + + def onResult(self, result, config): + """ + Called first for success and error. + """ + + if result is None: + return False + + t1, t2 = sorted(result.keys()) + components = [ds.component for ds in config.datasources] + + for component in components: + result[component] = {} + result[component]['user_reads'] = self._rate( + result[t2][component]['user_reads'], result[t1][component]['user_reads'], + t2, t1) + result[component]['user_writes'] = self._rate( + result[t2][component]['user_writes'], result[t1][component]['user_writes'], + t2, t1) + + result[component]['size_used'] = result[t2][component]['size_used'] + result[component]['size_available'] = result[t2][component]['size_available'] + result[component]['percentage_used'] = result[t2][component]['percentage_used'] + + return result + + def onSuccess(self, result, config): + """ + Called only on success. After onResult, before onComplete. + """ + data = self.new_data() + ts = time.time() + components = [ds.component for ds in config.datasources] + + for component in components: + graphPoints = data['values'][component] + graphPoints['aggregate_user_reads'] = (result[component]['user_reads'], ts) + graphPoints['aggregate_user_writes'] = (result[component]['user_writes'], ts) + graphPoints['aggregate_size_used'] = (result[component]['size_used'], ts) + graphPoints['aggregate_size_available'] = (result[component]['size_available'], ts) + graphPoints['aggregate_percentage_used'] = (result[component]['percentage_used'], ts) + + return data + + def onError(self, result, config): + """ + Called only on error. After onResult, before onComplete. + """ + return { + 'events': [{ + 'summary': 'error: %s' % result, + 'eventKey': 'netappaggregate_datasource_result', + 'severity': 4, + }], + } diff --git a/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppDeviceDSP.py b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppDeviceDSP.py new file mode 100644 index 0000000..80a16c1 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppDeviceDSP.py @@ -0,0 +1,246 @@ +import time +import logging +log = logging.getLogger('zen.netAppDeviceDSP') + +from xml.etree import ElementTree +from twisted.internet.defer import inlineCallbacks, returnValue, DeferredList +from Products.ZenEvents import ZenEventClasses +from ZenPacks.zenoss.PythonCollector.datasources.PythonDataSource \ + import PythonDataSourcePlugin +from ZenPacks.CS.NetApp.SevenMode.lib.ZenOntap import * +from ZenPacks.CS.NetApp.SevenMode.Utils import Utils + +class NetAppDeviceDSP(PythonDataSourcePlugin, Utils): + """Python Datasource Plugin to collect graph data for NetApp device.""" + + proxy_attributes = ( + 'zNetAppFiler', + 'zNetAppUser', + 'zNetAppPassword', + 'zNetAppTransport', + ) + + def _generate_request(self, perfGet): + request = NaElement('perf-object-get-instances') + for perf, instances in perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter[0]) + try: + reqcnts.child_add_string('counter', counter[2]) + except: + pass + request.child_add(reqcnts) + request.child_add(reqinst) + return request + + def _get_elements(self, defs): + naElements = [] + for success, result in defs: + if success: + status = result.results_status() + if status == 'passed': + naElements.append(result) + elif status == 'failed': + log.error('%s', result.results_reason()) + else: + log.error(result.printTraceback()) + return None + return naElements + + def _get_nodes(self, naElements): + nodes = {} + for result in naElements: + if result.child_get('instances') is not None: + ts = int(result.child_get_string('timestamp')) + nodes[ts] = result \ + .child_get('instances') \ + .child_get('instance-data') \ + .child_get('counters') \ + .children_get() + return nodes + + @inlineCallbacks + def collect(self, config): + ds0 = config.datasources[0] + if ds0.zNetAppFiler == '': + ds0.zNetAppFiler = ds0.manageIp + + server = ZenOntap(ds0.zNetAppFiler, + ds0.zNetAppUser, + ds0.zNetAppPassword, + ds0.zNetAppTransport) + + perfGet = { + # object names + 'system': { + # instances + 'system': + # counters + [('avg_processor_busy', 'PERCT', 'cpu_elapsed_time1'), + ('nfs_ops', 'RATE'), + ('cifs_ops', 'RATE'), + ('http_ops', 'RATE'), + ('fcp_ops', 'RATE'), + ('iscsi_ops', 'RATE'), + ('sys_read_latency', 'AVERAGE', 'read_ops'), + ('sys_write_latency', 'AVERAGE', 'write_ops'), + ('sys_avg_latency', 'AVERAGE', 'total_ops'), + ('net_data_recv', 'RATE'), + ('net_data_sent', 'RATE'), + ('disk_data_read', 'RATE'), + ('disk_data_written', 'RATE'), + ('uptime', 'RAW'), + ], + }, + } + + results = {} + request = self._generate_request(perfGet) + + ############## + response1 = server.invoke_elem_async(request) + deferreds = [response1] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes1 = self._get_nodes(naElements) + + for ts, nodes in tsnodes1.iteritems(): + results[ts] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][dkey] = float(dvalue) + ############### + time.sleep(1) + ############### + response2 = server.invoke_elem_async(request) + deferreds = [response2] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes2 = self._get_nodes(naElements) + + for ts, nodes in tsnodes2.iteritems(): + results[ts] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][dkey] = float(dvalue) + ############### + + log.debug('RAW: %s', results) + returnValue(results) + + def onResult(self, result, config): + """ + Called first for success and error. + """ + + if result is None: + return False + + t1, t2 = sorted(result.keys()) + log.debug('TIME: %s %s', t1, t2) + + result['cpu_pct'] = self._percent( + result[t2]['avg_processor_busy'], result[t1]['avg_processor_busy'], + result[t2]['cpu_elapsed_time1'], result[t1]['cpu_elapsed_time1']) + result['nfs_ops'] = self._rate( + result[t2]['nfs_ops'], result[t1]['nfs_ops'], + t2, t1) + result['cifs_ops'] = self._rate( + result[t2]['cifs_ops'], result[t1]['cifs_ops'], + t2, t1) + result['http_ops'] = self._rate( + result[t2]['http_ops'], result[t1]['http_ops'], + t2, t1) + result['fcp_ops'] = self._rate( + result[t2]['fcp_ops'], result[t1]['fcp_ops'], + t2, t1) + result['iscsi_ops'] = self._rate( + result[t2]['iscsi_ops'], result[t1]['iscsi_ops'], + t2, t1) + result['read_ops'] = self._rate( + result[t2]['read_ops'], result[t1]['read_ops'], + t2, t1) + result['write_ops'] = self._rate( + result[t2]['write_ops'], result[t1]['write_ops'], + t2, t1) + result['total_ops'] = self._rate( + result[t2]['total_ops'], result[t1]['total_ops'], + t2, t1) + result['sys_read_latency'] = self._average( + result[t2]['sys_read_latency'], result[t1]['sys_read_latency'], + result[t2]['read_ops'], result[t1]['read_ops']) + result['sys_write_latency'] = self._average( + result[t2]['sys_write_latency'], result[t1]['sys_write_latency'], + result[t2]['write_ops'], result[t1]['write_ops']) + result['sys_avg_latency'] = self._average( + result[t2]['sys_avg_latency'], result[t1]['sys_avg_latency'], + result[t2]['total_ops'], result[t1]['total_ops']) + result['net_data_recv'] = (1024./8) * self._rate( + result[t2]['net_data_recv'], result[t1]['net_data_recv'], + t2, t1) + result['net_data_sent'] = (1024./8) * self._rate( + result[t2]['net_data_sent'], result[t1]['net_data_sent'], + t2, t1) + result['disk_data_read'] = (1024./8) * self._rate( + result[t2]['disk_data_read'], result[t1]['disk_data_read'], + t2, t1) + result['disk_data_written'] = (1024./8) * self._rate( + result[t2]['disk_data_written'], result[t1]['disk_data_written'], + t2, t1) + result['uptime'] = result[t2]['uptime'] * 100 + + log.debug('ON RESULT: %s', result) + return result + + def onSuccess(self, result, config): + """ + Called only on success. After onResult, before onComplete. + """ + data = self.new_data() + ts = time.time() + + graphPoints = data['values'][None] + graphPoints['device_cpu_pct'] = (result['cpu_pct'], ts) + graphPoints['device_nfs_ops'] = (result['nfs_ops'], ts) + graphPoints['device_cifs_ops'] = (result['cifs_ops'], ts) + graphPoints['device_http_ops'] = (result['http_ops'], ts) + graphPoints['device_fcp_ops'] = (result['fcp_ops'], ts) + graphPoints['device_iscsi_ops'] = (result['iscsi_ops'], ts) + graphPoints['device_read_ops'] = (result['read_ops'], ts) + graphPoints['device_write_ops'] = (result['write_ops'], ts) + graphPoints['device_total_ops'] = (result['total_ops'], ts) + graphPoints['device_sys_read_latency'] = (result['sys_read_latency'], ts) + graphPoints['device_sys_write_latency'] = (result['sys_write_latency'], ts) + graphPoints['device_sys_avg_latency'] = (result['sys_avg_latency'], ts) + graphPoints['device_net_data_recv'] = (result['net_data_recv'], ts) + graphPoints['device_net_data_sent'] = (result['net_data_sent'], ts) + graphPoints['device_disk_data_read'] = (result['disk_data_read'], ts) + graphPoints['device_disk_data_written'] = (result['disk_data_written'], ts) + graphPoints['device_sysUpTime'] = (result['uptime'], ts) + + return data + + def onError(self, result, config): + """ + Called only on error. After onResult, before onComplete. + """ + return { + 'events': [{ + 'summary': 'error: %s' % result, + 'eventKey': 'netappdevice_datasource_result', + 'severity': 4, + }], + } diff --git a/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppDiskDSP.py b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppDiskDSP.py new file mode 100644 index 0000000..10c4484 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppDiskDSP.py @@ -0,0 +1,211 @@ +import time +import logging +log = logging.getLogger('zen.netAppDiskDSP') + +from xml.etree import ElementTree +from twisted.internet.defer import inlineCallbacks, returnValue, DeferredList +from Products.ZenEvents import ZenEventClasses +from ZenPacks.zenoss.PythonCollector.datasources.PythonDataSource \ + import PythonDataSourcePlugin +from ZenPacks.CS.NetApp.SevenMode.lib.ZenOntap import * +from ZenPacks.CS.NetApp.SevenMode.Utils import Utils + +class NetAppDiskDSP(PythonDataSourcePlugin, Utils): + """Python Datasource Plugin to collect graph data for NetApp device.""" + + proxy_attributes = ( + 'zNetAppFiler', + 'zNetAppUser', + 'zNetAppPassword', + 'zNetAppTransport', + ) + + @classmethod + def params(cls, datasource, context): + return {'diskUID': context.disk_uid} + + def _generate_request(self, perfGet): + request = NaElement('perf-object-get-instances') + for perf, instances in perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter[0]) + try: + reqcnts.child_add_string('counter', counter[2]) + except: + pass + request.child_add(reqcnts) + request.child_add(reqinst) + return request + + def _get_elements(self, defs): + naElements = [] + for success, result in defs: + if success: + status = result.results_status() + if status == 'passed': + naElements.append(result) + elif status == 'failed': + log.error('%s', result.results_reason()) + else: + log.error(result.printTraceback()) + return None + return naElements + + def _get_nodes(self, naElements): + nodes = {} + for element in naElements: + if element.child_get('instances') is not None: + ts = int(element.child_get_string('timestamp')) + nodes[ts] = {} + for instance in element.child_get('instances').children_get(): + nameEl, perfEl = instance.children_get() + name = instance.child_get_string('name') + nodes[ts][name] = perfEl.children_get() + return nodes + + @inlineCallbacks + def collect(self, config): + ds0 = config.datasources[0] + if ds0.zNetAppFiler == '': + ds0.zNetAppFiler = ds0.manageIp + + server = ZenOntap(ds0.zNetAppFiler, + ds0.zNetAppUser, + ds0.zNetAppPassword, + ds0.zNetAppTransport) + + map = {} + for ds in config.datasources: + map[ds.params['diskUID']] = ds.component + + perfGet = { + 'disk': + dict.fromkeys( + [ds.params['diskUID'] for ds in config.datasources], + [ + ('user_reads', 'RATE'), + ('user_writes', 'RATE'), + ] + ) + } + + results = {} + request = self._generate_request(perfGet) + + ############## + response1 = server.invoke_elem_async(request) + deferreds = [response1] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes1 = self._get_nodes(naElements) + + for ts, components in tsnodes1.iteritems(): + results[ts] = {} + for component, nodes in components.iteritems(): + results[ts][map[component]] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][map[component]][dkey] = float(dvalue) + ############### + time.sleep(1) + ############### + response2 = server.invoke_elem_async(request) + deferreds = [response2] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes2 = self._get_nodes(naElements) + + for ts, components in tsnodes2.iteritems(): + results[ts] = {} + for component, nodes in components.iteritems(): + results[ts][map[component]] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][map[component]][dkey] = float(dvalue) + ############### + + request = NaElement('disk-list-info') + response = server.invoke_elem_async(request) + deferreds = [response] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + disks = naElements[0].child_get('disk-details') + for disk in disks.children_get(): + if disk.child_get_string('raid-state') == 'present': + component = disk.child_get_string('name') + results[ts][component]['size_total'] = disk.child_get_int('physical-space') + results[ts][component]['size_used'] = disk.child_get_int('used-space') + log.debug('%s', results) + returnValue(results) + + def onResult(self, result, config): + """ + Called first for success and error. + """ + + if result is None: + return False + + t1, t2 = sorted(result.keys()) + components = [ds.component for ds in config.datasources] + + for component in components: + result[component] = {} + result[component]['user_reads'] = self._rate( + result[t2][component]['user_reads'], result[t1][component]['user_reads'], + t2, t1) + result[component]['user_writes'] = self._rate( + result[t2][component]['user_writes'], result[t1][component]['user_writes'], + t2, t1) + + result[component]['size_used'] = result[t2][component]['size_used'] + result[component]['size_available'] = result[t2][component]['size_total'] - result[t2][component]['size_used'] + result[component]['percentage_used'] = int(100. * result[t2][component]['size_used'] / result[t2][component]['size_total']) + #log.debug('%s', result) + return result + + def onSuccess(self, result, config): + """ + Called only on success. After onResult, before onComplete. + """ + + data = self.new_data() + ts = time.time() + components = [ds.component for ds in config.datasources] + + for component in components: + graphPoints = data['values'][component] + graphPoints['disk_user_reads'] = (result[component]['user_reads'], ts) + graphPoints['disk_user_writes'] = (result[component]['user_writes'], ts) + graphPoints['disk_size_used'] = (result[component]['size_used'], ts) + graphPoints['disk_size_available'] = (result[component]['size_available'], ts) + graphPoints['disk_percentage_used'] = (result[component]['percentage_used'], ts) + + return data + + def onError(self, result, config): + """ + Called only on error. After onResult, before onComplete. + """ + return { + 'events': [{ + 'summary': 'error: %s' % result, + 'eventKey': 'netappdisk_datasource_result', + 'severity': 4, + }], + } diff --git a/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppSpareDiskDSP.py b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppSpareDiskDSP.py new file mode 100644 index 0000000..0b8ad9a --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppSpareDiskDSP.py @@ -0,0 +1,149 @@ +import time +import logging +log = logging.getLogger('zen.netAppSpareDiskDSP') + +from xml.etree import ElementTree +from twisted.internet.defer import inlineCallbacks, returnValue, DeferredList +from Products.ZenEvents import ZenEventClasses +from ZenPacks.zenoss.PythonCollector.datasources.PythonDataSource \ + import PythonDataSourcePlugin +from ZenPacks.CS.NetApp.SevenMode.lib.ZenOntap import * +from ZenPacks.CS.NetApp.SevenMode.Utils import Utils + +class NetAppSpareDiskDSP(PythonDataSourcePlugin, Utils): + """Python Datasource Plugin to collect graph data for NetApp device.""" + + proxy_attributes = ( + 'zNetAppFiler', + 'zNetAppUser', + 'zNetAppPassword', + 'zNetAppTransport', + ) + + @classmethod + def params(cls, datasource, context): + return {'diskUID': context.disk_uid} + + def _generate_request(self, perfGet): + request = NaElement('perf-object-get-instances') + for perf, instances in perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter[0]) + try: + reqcnts.child_add_string('counter', counter[2]) + except: + pass + request.child_add(reqcnts) + request.child_add(reqinst) + return request + + def _get_elements(self, defs): + naElements = [] + for success, result in defs: + if success: + status = result.results_status() + if status == 'passed': + naElements.append(result) + elif status == 'failed': + log.error('%s', result.results_reason()) + else: + log.error(result.printTraceback()) + return None + return naElements + + def _get_nodes(self, naElements): + nodes = {} + for element in naElements: + if element.child_get('instances') is not None: + ts = int(element.child_get_string('timestamp')) + nodes[ts] = {} + for instance in element.child_get('instances').children_get(): + nameEl, perfEl = instance.children_get() + name = instance.child_get_string('name') + nodes[ts][name] = perfEl.children_get() + return nodes + + @inlineCallbacks + def collect(self, config): + ds0 = config.datasources[0] + if ds0.zNetAppFiler == '': + ds0.zNetAppFiler = ds0.manageIp + + server = ZenOntap(ds0.zNetAppFiler, + ds0.zNetAppUser, + ds0.zNetAppPassword, + ds0.zNetAppTransport) + + results = {} + ts = 0 + results[ts] = {} + + request = NaElement('disk-list-info') + response = server.invoke_elem_async(request) + deferreds = [response] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + disks = naElements[0].child_get('disk-details') + for disk in disks.children_get(): + if disk.child_get_string('raid-state') != 'present': + component = disk.child_get_string('name') + results[ts][component] = {} + results[ts][component]['size_total'] = disk.child_get_int('physical-space') + results[ts][component]['size_used'] = disk.child_get_int('used-space') + log.debug('%s', results) + returnValue(results) + + def onResult(self, result, config): + """ + Called first for success and error. + """ + + if result is None: + return False + + ts, = result.keys() + components = [ds.component for ds in config.datasources] + + for component in components: + result[component] = {} + result[component]['size_used'] = result[ts][component]['size_used'] + result[component]['size_available'] = result[ts][component]['size_total'] - result[ts][component]['size_used'] + result[component]['percentage_used'] = int(100. * result[ts][component]['size_used'] / result[ts][component]['size_total']) + #log.debug('%s', result) + return result + + def onSuccess(self, result, config): + """ + Called only on success. After onResult, before onComplete. + """ + + data = self.new_data() + ts = time.time() + components = [ds.component for ds in config.datasources] + + for component in components: + graphPoints = data['values'][component] + graphPoints['sparedisk_size_used'] = (result[component]['size_used'], ts) + graphPoints['sparedisk_size_available'] = (result[component]['size_available'], ts) + graphPoints['sparedisk_percentage_used'] = (result[component]['percentage_used'], ts) + + return data + + def onError(self, result, config): + """ + Called only on error. After onResult, before onComplete. + """ + return { + 'events': [{ + 'summary': 'error: %s' % result, + 'eventKey': 'netappsparedisk_datasource_result', + 'severity': 4, + }], + } diff --git a/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppVolumeDSP.py b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppVolumeDSP.py new file mode 100644 index 0000000..47a6893 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/NetAppVolumeDSP.py @@ -0,0 +1,218 @@ +import time +import logging +log = logging.getLogger('zen.netAppVolumeDSP') + +from xml.etree import ElementTree +from twisted.internet.defer import inlineCallbacks, returnValue, DeferredList +from Products.ZenEvents import ZenEventClasses +from ZenPacks.zenoss.PythonCollector.datasources.PythonDataSource \ + import PythonDataSourcePlugin +from ZenPacks.CS.NetApp.SevenMode.lib.ZenOntap import * +from ZenPacks.CS.NetApp.SevenMode.Utils import Utils + +class NetAppVolumeDSP(PythonDataSourcePlugin, Utils): + """Python Datasource Plugin to collect graph data for NetApp device.""" + + proxy_attributes = ( + 'zNetAppFiler', + 'zNetAppUser', + 'zNetAppPassword', + 'zNetAppTransport', + ) + + def _generate_request(self, perfGet): + request = NaElement('perf-object-get-instances') + for perf, instances in perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter[0]) + try: + reqcnts.child_add_string('counter', counter[2]) + except: + pass + request.child_add(reqcnts) + request.child_add(reqinst) + return request + + def _get_elements(self, defs): + naElements = [] + for success, result in defs: + if success: + status = result.results_status() + if status == 'passed': + naElements.append(result) + elif status == 'failed': + log.error('%s', result.results_reason()) + else: + log.error(result.printTraceback()) + return None + return naElements + + def _get_nodes(self, naElements): + nodes = {} + for element in naElements: + if element.child_get('instances') is not None: + ts = int(element.child_get_string('timestamp')) + nodes[ts] = {} + for instance in element.child_get('instances').children_get(): + nameEl, perfEl = instance.children_get() + name = instance.child_get_string('name') + nodes[ts][name] = perfEl.children_get() + return nodes + + @inlineCallbacks + def collect(self, config): + ds0 = config.datasources[0] + if ds0.zNetAppFiler == '': + ds0.zNetAppFiler = ds0.manageIp + + server = ZenOntap(ds0.zNetAppFiler, + ds0.zNetAppUser, + ds0.zNetAppPassword, + ds0.zNetAppTransport) + + perfGet = { + 'volume': + dict.fromkeys( + [ds.component for ds in config.datasources], + [ + ('avg_latency', 'AVERAGE', 'total_ops'), + ('read_latency', 'AVERAGE', 'read_ops'), + ('write_latency', 'AVERAGE', 'write_ops'), + ('read_data', 'RATE'), + ('write_data', 'RATE'), + ] + ) + } + + results = {} + request = self._generate_request(perfGet) + + ############## + response1 = server.invoke_elem_async(request) + deferreds = [response1] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes1 = self._get_nodes(naElements) + + for ts, components in tsnodes1.iteritems(): + results[ts] = {} + for component, nodes in components.iteritems(): + results[ts][component] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][component][dkey] = float(dvalue) + ############### + time.sleep(1) + ############### + response2 = server.invoke_elem_async(request) + deferreds = [response2] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + tsnodes2 = self._get_nodes(naElements) + + for ts, components in tsnodes2.iteritems(): + results[ts] = {} + for component, nodes in components.iteritems(): + results[ts][component] = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[ts][component][dkey] = float(dvalue) + ############### + + request = NaElement('volume-list-info') + response = server.invoke_elem_async(request) + deferreds = [response] + defs = yield DeferredList(deferreds, consumeErrors=True) + naElements = self._get_elements(defs) + if naElements is None: + returnValue(None) + volumes = naElements[0].child_get('volumes') + for volume in volumes.children_get(): + component = volume.child_get_string('name') + results[ts][component]['size_used'] = volume.child_get_int('size-used') + results[ts][component]['size_available'] = volume.child_get_int('size-available') + results[ts][component]['percentage_used'] = volume.child_get_int('percentage-used') + + log.debug('%s', results) + returnValue(results) + + def onResult(self, result, config): + """ + Called first for success and error. + """ + + if result is None: + return False + + t1, t2 = sorted(result.keys()) + components = [ds.component for ds in config.datasources] + + for component in components: + result[component] = {} + result[component]['avg_latency'] = self._average( + result[t2][component]['avg_latency'], result[t1][component]['avg_latency'], + result[t2][component]['total_ops'], result[t1][component]['total_ops']) + result[component]['read_latency'] = self._average( + result[t2][component]['read_latency'], result[t1][component]['read_latency'], + result[t2][component]['read_ops'], result[t1][component]['read_ops']) + result[component]['write_latency'] = self._average( + result[t2][component]['write_latency'], result[t1][component]['write_latency'], + result[t2][component]['write_ops'], result[t1][component]['write_ops']) + result[component]['read_data'] = (1./8) * self._rate( + result[t2][component]['read_data'], result[t1][component]['read_data'], + t2, t1) + result[component]['write_data'] = (1./8) * self._rate( + result[t2][component]['write_data'], result[t1][component]['write_data'], + t2, t1) + + result[component]['size_used'] = result[t2][component]['size_used'] + result[component]['size_available'] = result[t2][component]['size_available'] + result[component]['percentage_used'] = result[t2][component]['percentage_used'] + + return result + + def onSuccess(self, result, config): + """ + Called only on success. After onResult, before onComplete. + """ + data = self.new_data() + ts = time.time() + components = [ds.component for ds in config.datasources] + + for component in components: + graphPoints = data['values'][component] + graphPoints['volume_avg_latency'] = (result[component]['avg_latency'], ts) + graphPoints['volume_read_latency'] = (result[component]['read_latency'], ts) + graphPoints['volume_write_latency'] = (result[component]['write_latency'], ts) + graphPoints['volume_read_data'] = (result[component]['read_data'], ts) + graphPoints['volume_write_data'] = (result[component]['write_data'], ts) + graphPoints['volume_size_used'] = (result[component]['size_used'], ts) + graphPoints['volume_size_available'] = (result[component]['size_available'], ts) + graphPoints['volume_percentage_used'] = (result[component]['percentage_used'], ts) + + return data + + def onError(self, result, config): + """ + Called only on error. After onResult, before onComplete. + """ + return { + 'events': [{ + 'summary': 'error: %s' % result, + 'eventKey': 'netappvolume_datasource_result', + 'severity': 4, + }], + } diff --git a/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/__init__.py b/ZenPacks/CS/NetApp/SevenMode/datasource_plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks/CS/NetApp/SevenMode/info.py b/ZenPacks/CS/NetApp/SevenMode/info.py new file mode 100644 index 0000000..0a218a8 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/info.py @@ -0,0 +1,100 @@ +from zope.interface import implements + +from Products.Zuul.infos import ProxyProperty +from Products.Zuul.infos.device import DeviceInfo +from Products.Zuul.infos.component import ComponentInfo + +from ZenPacks.CS.NetApp.SevenMode.interfaces import ( + INetAppDeviceInfo, + IAggregateInfo, + IPlexInfo, + IRaidGroupInfo, + IDiskInfo, + IVolumeInfo, + ISpareDiskInfo, +) + + +class NetAppDeviceInfo(DeviceInfo): + implements(INetAppDeviceInfo) + + +class AggregateInfo(ComponentInfo): + implements(IAggregateInfo) + + aggr_name = ProxyProperty('aggr_name') + aggr_state = ProxyProperty('aggr_state') + mount_state = ProxyProperty('mount_state') + raid_size = ProxyProperty('raid_size') + raid_status = ProxyProperty('raid_status') + disk_count = ProxyProperty('disk_count') + volume_count = ProxyProperty('volume_count') + plex_count = ProxyProperty('plex_count') + total_bytes = ProxyProperty('total_bytes') + + +class PlexInfo(ComponentInfo): + implements(IPlexInfo) + + plex_name = ProxyProperty('plex_name') + plex_state = ProxyProperty('plex_state') + + +class RaidGroupInfo(ComponentInfo): + implements(IRaidGroupInfo) + + rg_name = ProxyProperty('rg_name') + + +class DiskInfo(ComponentInfo): + implements(IDiskInfo) + + disk_name = ProxyProperty('disk_name') + disk_uid = ProxyProperty('disk_uid') + node = ProxyProperty('node') + raid_state = ProxyProperty('raid_state') + raid_type = ProxyProperty('raid_type') + bay = ProxyProperty('bay') + byte_per_sector = ProxyProperty('byte_per_sector') + disk_type = ProxyProperty('disk_type') + rpm = ProxyProperty('rpm') + model = ProxyProperty('model') + serialnr = ProxyProperty('serialnr') + firmware = ProxyProperty('firmware') + poweron_hours = ProxyProperty('poweron_hours') + grown_defect_list_count = ProxyProperty('grown_defect_list_count') + total_bytes = ProxyProperty('total_bytes') + + +class VolumeInfo(ComponentInfo): + implements(IVolumeInfo) + + volume_name = ProxyProperty('volume_name') + volume_type = ProxyProperty('volume_type') + block_type = ProxyProperty('block_type') + volume_state = ProxyProperty('volume_state') + mirror_status = ProxyProperty('mirror_status') + inconsistent = ProxyProperty('inconsistent') + unrecoverable = ProxyProperty('unrecoverable') + invalid = ProxyProperty('invalid') + total_bytes = ProxyProperty('total_bytes') + + +class SpareDiskInfo(ComponentInfo): + implements(ISpareDiskInfo) + + sparedisk_name = ProxyProperty('sparedisk_name') + disk_uid = ProxyProperty('disk_uid') + node = ProxyProperty('node') + raid_state = ProxyProperty('raid_state') + raid_type = ProxyProperty('raid_type') + bay = ProxyProperty('bay') + byte_per_sector = ProxyProperty('byte_per_sector') + disk_type = ProxyProperty('disk_type') + rpm = ProxyProperty('rpm') + model = ProxyProperty('model') + serialnr = ProxyProperty('serialnr') + firmware = ProxyProperty('firmware') + poweron_hours = ProxyProperty('poweron_hours') + grown_defect_list_count = ProxyProperty('grown_defect_list_count') + total_bytes = ProxyProperty('total_bytes') diff --git a/ZenPacks/CS/NetApp/SevenMode/interfaces.py b/ZenPacks/CS/NetApp/SevenMode/interfaces.py new file mode 100644 index 0000000..40cae2b --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/interfaces.py @@ -0,0 +1,77 @@ +from Products.Zuul.form import schema +from Products.Zuul.interfaces.device import IDeviceInfo +from Products.Zuul.interfaces.component import IComponentInfo +from Products.Zuul.utils import ZuulMessageFactory as _t + + +class INetAppDeviceInfo(IDeviceInfo): + """Info""" + + +class IAggregateInfo(IComponentInfo): + aggr_name = schema.TextLine(title=_t('Aggregate Name')) + aggr_state = schema.TextLine(title=_t('Aggregate State')) + mount_state = schema.TextLine(title=_t('Mount State')) + raid_size = schema.Int(title=_t('RAID Size')) + raid_status = schema.TextLine(title=_t('RAID Status')) + disk_count = schema.Int(title=_t('Disk Count')) + volume_count = schema.Int(title=_t('Volume Count')) + plex_count = schema.Int(title=_t('Plex Count')) + total_bytes = schema.Int(title=_t('Total Bytes')) + + +class IPlexInfo(IComponentInfo): + plex_name = schema.TextLine(title=_t('Plex Name')) + plex_state = schema.Bool(title=_t('Plex State')) + + +class IRaidGroupInfo(IComponentInfo): + rg_name = schema.TextLine(title=_t('RAID Group Name')) + + +class IDiskInfo(IComponentInfo): + disk_name = schema.TextLine(title=_t('Disk Name')) + disk_uid = schema.TextLine(title=_t('Disk UID')) + node = schema.TextLine(title=_t('Node')) + raid_state = schema.TextLine(title=_t('RAID State')) + raid_type = schema.TextLine(title=_t('RAID Type')) + bay = schema.Int(title=_t('Bay')) + byte_per_sector = schema.Int(title=_t('Byte Per Sector')) + disk_type = schema.TextLine(title=_t('Disk Type')) + rpm = schema.Int(title=_t('RPMs')) + model = schema.TextLine(title=_t('Model')) + serialnr = schema.TextLine(title=_t('Serial Number')) + firmware = schema.TextLine(title=_t('Firmware')) + poweron_hours = schema.Int(title=_t('Poweron Hours')) + grown_defect_list_count = schema.Int(title=_t('Grown Defect List Count')) + total_bytes = schema.Int(title=_t('Total Bytes')) + + +class IVolumeInfo(IComponentInfo): + volume_name = schema.TextLine(title=_t('Volume Name')) + volume_type = schema.TextLine(title=_t('Volume Type')) + block_type = schema.TextLine(title=_t('Block Type')) + volume_state = schema.TextLine(title=_t('Volume State')) + mirror_status = schema.TextLine(title=_t('Mirror Status')) + inconsistent = schema.TextLine(title=_t('Inconsistent')) + unrecoverable = schema.TextLine(title=_t('Unrecoverable')) + invalid = schema.TextLine(title=_t('Invalid')) + total_bytes = schema.Int(title=_t('Total Bytes')) + + +class ISpareDiskInfo(IComponentInfo): + sparedisk_name = schema.TextLine(title=_t('Spare Disk Name')) + disk_uid = schema.TextLine(title=_t('Disk UID')) + node = schema.TextLine(title=_t('Node')) + raid_state = schema.TextLine(title=_t('RAID State')) + raid_type = schema.TextLine(title=_t('RAID Type')) + bay = schema.Int(title=_t('Bay')) + byte_per_sector = schema.Int(title=_t('Byte Per Sector')) + disk_type = schema.TextLine(title=_t('Disk Type')) + rpm = schema.Int(title=_t('RPMs')) + model = schema.TextLine(title=_t('Model')) + serialnr = schema.TextLine(title=_t('Serial Number')) + firmware = schema.TextLine(title=_t('Firmware')) + poweron_hours = schema.Int(title=_t('Poweron Hours')) + grown_defect_list_count = schema.Int(title=_t('Grown Defect List Count')) + total_bytes = schema.Int(title=_t('Total Bytes')) diff --git a/ZenPacks/CS/NetApp/SevenMode/lib/NaElement.py b/ZenPacks/CS/NetApp/SevenMode/lib/NaElement.py new file mode 100644 index 0000000..205f8f4 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/lib/NaElement.py @@ -0,0 +1,418 @@ +#============================================================# +# # +# $ID$ # +# # +# NaElement.py # +# # +# Operations on ONTAPI and DataFabric Manager elements # +# # +# Copyright (c) 2011 NetApp, Inc. All rights reserved. # +# Specifications subject to change without notice. # +# # +#============================================================# + +__version__ = 1.0 + + +import re +import sys + +class NaElement : + """Class encapsulating Netapp XML request elements. + + An NaElement encapsulates one level of an XML element. + Elements can be arbitrarily nested. They have names, + corresponding to XML tags, attributes (only used for + results), values (always strings) and possibly children, + corresponding to nested tagged items. See NaServer for + instructions on using NaElements to invoke ONTAPI API calls. + + The following routines are available for constructing and + accessing the contents of NaElements. + """ + + + #Global Variables + DEFAULT_KEY = "#u82fyi8S5\017pPemw" + MAX_CHUNK_SIZE = 256 + + + def __init__(self, name, value=None): + """Construct a new NaElement. The 'value' parameter is + optional for top level elements. + """ + + self.element = {'name':name,'content':"",'children':[],'attrkeys':[],'attrvals':[]} + if (value != None) : + self.element['content'] = value + + + def results_status(self) : + """Indicates success or failure of API call. + Returns either 'passed' or 'failed'. + """ + r = self.attr_get("status") + + if(r == "passed"): + return "passed" + + else : + return "failed" + + + def results_reason(self): + """Human-readable string describing a failure. + Only present if results_status does not return 'passed'. + """ + + r = self.attr_get("status") + if(r == "passed"): + return None + + r = self.attr_get("reason") + if not r: + return "No reason given" + + return str(r) + + + def results_errno(self): + """Returns an error number, 0 on success. + """ + + r = self.attr_get("status") + + if (r == "passed"): + return 0 + + r = self.attr_get("errno") + + if not r: + r = -1 + + return r + + + def child_get(self, name): + """Get a named child of an element, which is also an + element. Elements can be nested arbitrarily, so + the element you get with this could also have other + children. The return is either an NaElement named + 'name', or None if none is found. + """ + + arr = self.element['children'] + + for i in arr : + + if(name == i.element['name']): + return i + + return None + + + def set_content(self, content): + """Set the element's value to 'content'. This is + not needed in normal development. + """ + + self.element['content'] = content + + + def add_content(self, content): + """Add the element's value to 'content'. This is + not needed in normal development. + """ + + self.element['content'] = self.element['content']+content + return + + + + def has_children(self): + """Returns 1 if the element has any children, 0 otherwise + """ + + arr = self.element['children'] + + if(len(arr)>0): + return 1 + + else : + return 0 + + + + def child_add(self, child): + """Add the element 'child' to the children list of + the current object, which is also an element. + """ + + arr = self.element['children'] + arr.append(child) + self.element['children'] = arr + + + + def child_add_string(self, name, value): + """Construct an element with name 'name' and contents + 'value', and add it to the current object, which + is also an element. + """ + + elt = NaElement(name,value) + self.child_add(elt) + + + + def child_get_string(self, name): + """Gets the child named 'name' from the current object + and returns its value. If no child named 'name' is + found, returns None. + """ + + elts = self.element['children'] + + for elt in elts: + if (name == elt.element['name']): + return elt.element['content'] + + return None + + + + def child_get_int(self, child): + """Gets the child named 'name' from the current object + and returns its value as an integer. If no child + named 'name' is found, returns None. + """ + + temp = self.child_get_string(child) + return int(temp) + + + + def children_get(self): + """Returns the list of children as an array. + """ + + elts = self.element['children'] + return elts + + + + def sprintf(self, indent=""): + """Sprintf pretty-prints the element and its children, + recursively, in XML-ish format. This is of use + mainly in exploratory and utility programs. Use + child_get_string() to dig values out of a top-level + element's children. + + Parameter 'indent' is optional. + """ + + name = self.element['name'] + s = indent+"<"+name + keys = self.element['attrkeys'] + vals = self.element['attrvals'] + j = 0 + + for i in keys: + s = s+" "+str(i)+"=\""+str(vals[j])+"\"" + j = j+1 + + s = s+">" + children = self.element['children'] + + if(len(children) > 0): + s = s+"\n" + + for i in children: + c = i + + if (not re.search('NaElement.NaElement', str(c.__class__), re.I)): + sys.exit("Unexpected reference found, expected NaElement.NaElement not "+ str(c.__class__)+"\n") + + s = s+c.sprintf(indent + "\t") + + s = s + str(self.element['content']) + + if(len(children) > 0): + s = s+indent + + s = s+"\n" + return s + + + + def child_add_string_encrypted(self, name, value, key=None): + """Same as child_add_string, but encrypts 'value' + with 'key' before adding the element to the current + object. This is only used at present for certain + key exchange operations. Both client and server + must know the value of 'key' and agree to use this + routine and its companion, child_get_string_encrypted(). + The default key will be used if the given key is None. + """ + + if(not name or not value): + sys.exit("Invalid input specified for name or value") + + if (key == None): + key = self.DEFAULT_KEY + + if (len(key) != 16): + sys.exit("Invalid key, key length sholud be 16") + + #encryption of key and others + encrypted_value = self.RC4(key,value) + self.child_add_string(name,unpack('H*',encrypted_value)) + + + + def child_get_string_encrypted(self, name, key=None): + """Get the value of child named 'name', and decrypt + it with 'key' before returning it. + The default key will be used if the given key is None. + """ + + if (key == None): + key = self.DEFAULT_KEY + + if (len(key) != 16): + sys.exit("Invalid key, key length sholud be 16") + + value = self.child_get_string(name) + plaintext = self.RC4(key,pack('H*',value)) + return plaintext + + + + def toEncodedString(self): + """Encodes string embedded with special chars like &,<,>. + This is mainly useful when passing string values embedded + with special chars like &,<,> to API. + + Example : + server.invoke("qtree-create","qtree","abc" + children = self.element['children'] + + for i in children : + c = i + + if (not re.search("NaElement.NaElement",str(c.__class__),re.I)): + sys.exit("Unexpected reference found, expected NaElement.NaElement not "+ str(c.__class__)+"\n") + + s = s+c.toEncodedString() + + cont = str(self.element['content']) + re.sub(r'&','&',cont,count=0) + re.sub(r'<','<',cont,count=0) + re.sub(r'>','>',cont,count=0) + re.sub(r"'",''',cont,count=0) + re.sub(r'"','"',cont,count=0) + s = s+cont + s = s+"" + return s + + + +#------------------------------------------------------------# +# +# routines beyond this point are "private" +# +#------------------------------------------------------------# + + def RC4(self, key, value): + """This is a private function, not to be called from outside NaElement. + """ + + box = self.prepare_key(key) + x,y = 0,0 + plaintext = value + num = len(plaintext)/self.MAX_CHUNK_SIZE + + integer = int(num) + + if(integer == num): + num_pieces = integer + + else : + num_pieces = integer+1 + + for piece in range(0,num_pieces-1): + plaintext = unpack("C*",plaintext[piece * self.MAX_CHUNK_SIZE:(piece*self.MAX_CHUNK_SIZE)+self.MAX_CHUNK_SIZE]) + + for i in plaintext: + + if ((x+1) > 255 ): + x = 0 + + y = y+box[x] + + if(y > 255): + y = -256 + + box[x],box[y] = box[y],box[x] + plain_text.append(chr(ord(char) ^ box[(box[x] + box[y]) % 256])) + + return plain_text + + + + def prepare_key(self, key): + """This is a private function, not to be called from outside NaElement. + """ + + k = unpack('C*',key) + box = range(255) + y = 0 + + for x in range(255): + y = (k[x % k]+ box[x] + y) % 256 + box[x],box[y] = box[y],box[x] + + return box + + + + def attr_set(self, key, value): + """This is a private function, not to be called from outside NaElement. + """ + + arr = self.element['attrkeys'] + arr.append(key) + self.element['attrkeys'] = arr + arr = self.element['attrvals'] + arr.append(value) + self.element['attrvals'] = arr + + + + def attr_get(self, key): + """This is a private function, not to be called from outside NaElement. + """ + + keys = self.element['attrkeys'] + vals = self.element['attrvals'] + j = 0 + + for i in keys: + if(i == key): + return vals[j] + + j = j+1 + + return None diff --git a/ZenPacks/CS/NetApp/SevenMode/lib/NaServer.py b/ZenPacks/CS/NetApp/SevenMode/lib/NaServer.py new file mode 100644 index 0000000..b9dfe94 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/lib/NaServer.py @@ -0,0 +1,755 @@ +#============================================================# +# # +# $ID:$ # +# # +# NaServer.py # +# # +# Client-side interface to ONTAP and DataFabric Manager APIs.# +# # +# Copyright (c) 2011 NetApp, Inc. All rights reserved. # +# Specifications subject to change without notice. # +# # +#============================================================# + +__version__ = "1.0" + +from NaElement import * + +import base64 +import xml.parsers.expat +import socket + +ssl_import = True +try: + import ssl +except ImportError: + ssl_import = False + pass + + +python_version = float(str(sys.version_info[0]) + "." + str(sys.version_info[1])) + +socket_ssl_attr = True +if(python_version < 3.0): + import httplib + if(hasattr(socket, 'ssl') != True): + socket_ssl_attr = False +else : + import http.client + httplib = http.client + +#dtd files +FILER_dtd = "file:/etc/netapp_filer.dtd" +DFM_dtd = "file:/etc/netapp_dfm.dtd" +AGENT_dtd = "file:/etc/netapp_agent.dtd" + +#URLs +AGENT_URL = "/apis/XMLrequest" +FILER_URL = "/servlets/netapp.servlets.admin.XMLrequest_filer" +NETCACHE_URL = "/servlets/netapp.servlets.admin.XMLrequest" +DFM_URL = "/apis/XMLrequest" + +ZAPI_xmlns = "http://www.netapp.com/filer/admin" + + +class NaServer(object): + """Class for managing Network Appliance(r) Storage System + using ONTAPI(tm) and DataFabric Manager API(tm). + + An NaServer encapsulates an administrative connection to + a NetApp Storage Systems running Data ONTAP 6.4 or later. + NaServer can also be used to establish connection with + DataFabric Manager (DFM). You construct NaElement objects + that represent queries or commands, and use invoke_elem() + to send them to the storage systems or DFM server. Also, + a convenience routine called invoke() can be used to bypass + the element construction step. The return from the call is + another NaElement which either has children containing the + command results, or an error indication. + + The following routines are available for setting up + administrative connections to a storage system or DFM server. + """ + + + + def __init__(self, server, major_version, minor_version): + """Create a new connection to server 'server'. Before use, + you either need to set the style to "hosts.equiv" or set + the username (always "root" at present) and password with + set_admin_user(). + """ + + self.server = server + self.major_version = major_version + self.minor_version = minor_version + self.transport_type = "HTTP" + self.port = 80 + self.user = "root" + self.password = "" + self.style = "LOGIN" + self.timeout = None + self.vfiler = "" + self.server_type = "FILER" + self.debug_style = "" + self.xml = "" + self.originator_id = "" + self.cert_file = None + self.key_file = None + self.ca_file = None + self.need_cba = False; + self.need_server_auth = False + self.need_cn_verification = False + self.url = FILER_URL + self.dtd = FILER_dtd + self.ZAPI_stack = [] + self.ZAPI_atts = {} + + + + def set_style(self, style): + """Pass in 'LOGIN' to cause the server to use HTTP simple + authentication with a username and password. Pass in 'HOSTS' + to use the hosts.equiv file on the filer to determine access + rights (the username must be root in that case). Pass in + 'CERTIFICATE' to use certificate based authentication with the + DataFabric Manager server. + If style = CERTIFICATE, you can use certificates to authenticate + clients who attempt to connect to a server without the need of + username and password. This style will internally set the transport + type to HTTPS. Verification of the server's certificate is required + in order to properly authenticate the identity of the server. + Server certificate verification will be enabled by default using this + style and Server certificate verification will always enable hostname + verification. You can disable server certificate (with hostname) + verification using set_server_cert_verification(). + """ + + if(style != "HOSTS" and style != "LOGIN" and style != "CERTIFICATE"): + return self.fail_response(13001,"in NaServer::set_style: bad style \""+style+"\"") + + if (style == "CERTIFICATE") : + if (ssl_import == False): + return self.fail_response(13001,"in NaServer::set_style: \""+style+"\" cannot be used as 'ssl' module is not imported.") + if (socket_ssl_attr == False): + return self.fail_response(13001,"in NaServer::set_style: \""+style+"\" cannot be used as 'socket' module is not compiled with SSL support.") + ret = self.set_transport_type("HTTPS") + if (ret): + return ret + self.need_cba = True + self.set_server_cert_verification(True) + else : + self.need_cba = False + self.set_server_cert_verification(False) + self.style = style + return None + + + + def get_style(self): + """Get the authentication style + """ + + return self.style + + + + def set_admin_user(self, user, password): + """Set the admin username and password. At present 'user' must + always be 'root'. + """ + + self.user = user + self.password = password + + + + def set_server_type(self, server_type): + """Pass in one of these keywords: 'FILER' or 'DFM' to indicate + whether the server is a storage system (filer) or a DFM server. + + If you also use set_port(), call set_port() AFTER calling this routine. + + The default is 'FILER'. + """ + + if (server_type.lower() == 'filer'): + self.url = FILER_URL + self.dtd = FILER_dtd + + elif (server_type.lower() == 'netcache'): + self.url = NETCACHE_URL + self.port = 80 + + elif (server_type.lower() == 'agent'): + self.url = AGENT_URL + self.port = 4092 + self.dtd = AGENT_dtd + + elif (server_type.lower() == 'dfm'): + self.url = DFM_URL + self.port = 8088 + self.dtd = DFM_dtd + + if(self.transport_type == "HTTPS") : + self.port = 8488 + + else : + return self.fail_response(13001,"in NaServer::set_server_type: bad type \""+server_type+"\"") + + self.servertype = server_type + return None + + + + def get_server_type(self): + """Get the type of server this server connection applies to. + """ + + return self.servertype + + + + def set_vserver(self, vserver): + """Sets the vserver name. This function is added for vserver-tunneling. + However, vserver tunneling actually uses vfiler-tunneling. Hence this + function internally sets the vfiler name. + """ + + if(self.major_version >= 1 and self.minor_version >= 15): + self.vfiler = vserver + return 1 + + print("\nONTAPI version must be at least 1.15 to send API to a vserver\n") + return 0 + + + def get_vserver(self): + """Gets the vserver name. This function is added for vserver-tunneling. + However, vserver tunneling actually uses vfiler-tunneling. Hence this + function actually returns the vfiler name. + """ + + return self.vfiler + + + + def set_originator_id(self, originator_id): + """Function to set the originator_id before executing any ONTAP API. + """ + + self.originator_id = originator_id + return 1 + + + def get_originator_id(self): + """Gets the originator_id for the given server context on which the + ONTAP API commands get invoked. + """ + + return self.originator_id + + + + def set_transport_type(self, scheme): + """Override the default transport type. The valid transport + type are currently 'HTTP' and 'HTTPS'. + """ + + if(scheme != "HTTP" and scheme != "HTTPS"): + return self.fail_response(13001,"in NaServer::set_transport_type: bad type \" "+scheme+"\"") + + if(scheme == "HTTP"): + self.transport_type = "HTTP" + + if(self.server_type == "DFM"): + self.port = 8088 + + else : + self.port = 80 + + + if(scheme == "HTTPS"): + if (socket_ssl_attr == False): + return self.fail_response(13001,"in NaServer::set_transport_type: \""+scheme+"\" transport cannot be used as 'socket' module is not compiled with SSL support.") + + self.transport_type = "HTTPS" + + if(self.server_type == "DFM"): + self.port = 8488 + + else : + self.port = 443 + + return None + + + + def get_transport_type(self): + """Retrieve the transport used for this connection. + """ + + return self.transport_type + + + + def set_debug_style(self, debug_style): + """Set the style of debug. + """ + + if(debug_style != "NA_PRINT_DONT_PARSE"): + return self.fail_response(13001,"in NaServer::set_debug_style: bad style \""+debug_style+"\"") + + else : + self.debug_style = debug_style + return + + + + def set_port(self, port): + """Override the default port for this server. If you + also call set_server_type(), you must call it before + calling set_port(). + """ + + self.port = port + + + + def get_port(self): + """Retrieve the port used for the remote server. + """ + + return self.port + + + + def is_debugging(self): + """Check the type of debug style and return the + value for different needs. Return 1 if debug style + is NA_PRINT_DONT_PARSE, else return 0. + """ + + if(self.debug_style == "NA_PRINT_DONT_PARSE"): + return 1 + + else : + return 0 + + + + def get_raw_xml_output(self): + """Return the raw XML output. + """ + + return self.xml + + + + def set_raw_xml_output(self, xml): + """Save the raw XML output. + """ + + self.xml = xml + + + + def use_https(self): + """Determines whether https is enabled. + """ + + if(self.transport_type == "HTTPS"): + return 1 + + else : + return 0 + + + + def invoke_elem(self, req): + """Submit an XML request already encapsulated as + an NaElement and return the result in another + NaElement. + """ + + server = self.server + user = self.user + password = self.password + debug_style = self.debug_style + vfiler = self.vfiler + originator_id = self.originator_id + server_type = self.server_type + xmlrequest = req.toEncodedString() + url = self.url + vfiler_req = "" + originator_id_req = "" + + try: + + if(self.transport_type == "HTTP"): + if(python_version < 2.6): # python versions prior to 2.6 do not support 'timeout' + connection = httplib.HTTPConnection(server, port=self.port) + else : + connection = httplib.HTTPConnection(server, port=self.port, timeout=self.timeout) + + else : # for HTTPS + + if (self.need_cba == True or self.need_server_auth == True): + if (python_version < 2.6): + cba_err = "certificate based authentication is not supported with Python " + str(python_version) + "." + return self.fail_response(13001, cba_err) + connection = CustomHTTPSConnection(server, self.port, key_file=self.key_file, + cert_file=self.cert_file, ca_file=self.ca_file, + need_server_auth=self.need_server_auth, + need_cn_verification=self.need_cn_verification, + timeout=self.timeout) + connection.connect() + if (self.need_cn_verification == True): + cn_name = connection.get_commonName() + if (cn_name.lower() != server.lower()) : + cert_err = "server certificate verification failed: server certificate name (CN=" + cn_name + "), hostname (" + server + ") mismatch." + connection.close() + return self.fail_response(13001, cert_err) + else : + if(python_version < 2.6): # python versions prior to 2.6 do not support 'timeout' + connection = httplib.HTTPSConnection(server, port=self.port) + else : + connection = httplib.HTTPSConnection(server, port=self.port, timeout=self.timeout) + + connection.putrequest("POST", self.url) + connection.putheader("Content-type", "text/xml; charset=\"UTF-8\"") + + if(self.get_style() != "HOSTS"): + + if(python_version < 3.0): + base64string = base64.encodestring("%s:%s" %(user,password))[:-1] + authheader = "Basic %s" %base64string + elif(python_version == 3.0): + base64string = base64.encodestring(('%s:%s' %( user, password)).encode()) + authheader = "Basic %s" % base64string.decode().strip() + else: + base64string = base64.encodebytes(('%s:%s' %( user, password)).encode()) + authheader = "Basic %s" % base64string.decode().strip() + + connection.putheader("Authorization", authheader) + + if(vfiler != ""): + vfiler_req = " vfiler=\"" + vfiler + "\"" + + if(originator_id != ""): + originator_id_req = " originator_id=\"" + originator_id + "\"" + + + content = ''\ + +'\n'+\ + '' \ + ''\ + + xmlrequest + '' + + if(debug_style == "NA_PRINT_DONT_PARSE"): + print(("INPUT \n" +content)) + + if(python_version < 3.0): + connection.putheader("Content-length", len(content)) + connection.endheaders() + connection.send(content) + else : + connection.putheader("Content-length", str(len(content))) + connection.endheaders() + connection.send(content.encode()) + + + except socket.error : + message = sys.exc_info() + return (self.fail_response(13001, message[1])) + + response = connection.getresponse() + + if not response : + connection.close() + return self.fail_response(13001,"No response received") + + if(response.status == 401): + connection.close() + return self.fail_response(13002,"Authorization failed") + + xml_response = response.read() + + if(self.is_debugging() > 0): + + if(debug_style != "NA_PRINT_DONT_PARSE"): + self.set_raw_xml_output(xml_response) + print(("\nOUTPUT :",xml_response,"\n")) + connection.close() + return self.fail_response(13001, "debugging bypassed xml parsing") + + connection.close() + return self.parse_xml(xml_response) + + + + def invoke(self, api, *arg): + """A convenience routine which wraps invoke_elem(). + It constructs an NaElement with name $api, and for + each argument name/value pair, adds a child element + to it. It's an error to have an even number of + arguments to this function. + + Example: myserver->invoke('snapshot-create', + 'snapshot', 'mysnapshot', + 'volume', 'vol0'); + """ + + num_parms = len(arg) + + if ((num_parms & 1)!= 0): + return self.fail_response(13001,"in Zapi::invoke, invalid number of parameters") + + xi = NaElement(api) + i = 0 + + while(i < num_parms): + key = arg[i] + i = i+1 + value = arg[i] + i = i+1 + xi.child_add(NaElement(key, value)) + + return self.invoke_elem(xi) + + + + def set_vfiler(self, vfiler_name): + """Sets the vfiler name. This function is used + for vfiler-tunneling. + """ + + if(self.major_version >= 1 and self.minor_version >= 7 ): + self.vfiler = vfiler_name + return 1 + + return 0 + + + def set_timeout(self, timeout): + """Sets the connection timeout value, in seconds, + for the given server context. + """ + + if (python_version < 2.6): + print("\nPython versions prior to 2.6 do not support timeout.\n") + return + self.timeout = timeout + + + + def get_timeout(self): + """Retrieves the connection timeout value (in seconds) + for the given server context. + """ + + return self.timeout + + def set_client_cert_and_key(self, cert_file, key_file): + """ Sets the client certificate and key files that are required for client authentication + by the server using certificates. If key file is not defined, then the certificate file + will be used as the key file. + """ + + self.cert_file = cert_file + if (key_file != None): + self.key_file = key_file + else: + self.key_file = cert_file + + def set_ca_certs(self, ca_file): + """ Specifies the certificates of the Certificate Authorities (CAs) that are + trusted by this application and that will be used to verify the server certificate. + """ + + self.ca_file = ca_file + + def set_server_cert_verification(self, enable): + """ Enables or disables server certificate verification by the client. + Server certificate verification is enabled by default when style + is set to CERTIFICATE. Hostname (CN) verification is enabled + during server certificate verification. Hostname verification can be + disabled using set_hostname_verification() API. + """ + + if (enable != True and enable != False): + return self.fail_response(13001, "NaServer::set_server_cert_verification: invalid argument " + str(enable) + " specified"); + if (not self.use_https()): + return self.fail_response(13001,"in NaServer::set_server_cert_verification: server certificate verification can only be enabled or disabled for HTTPS transport") + if (enable == True and ssl_import == False): + return self.fail_response(13001,"in NaServer::set_server_cert_verification: server certificate verification cannot be used as 'ssl' module is not imported.") + self.need_server_auth = enable + self.need_cn_verification = enable + return None + + def is_server_cert_verification_enabled(self): + """ Determines whether server certificate verification is enabled or not. + Returns True if it is enabled, else returns False + """ + + return self.need_server_auth + + def set_hostname_verification(self, enable): + """ Enables or disables hostname verification during server certificate verification. + Hostname (CN) verification is enabled by default during server certificate verification. + """ + + if (enable != True and enable != False): + return self.fail_response(13001, "NaServer::set_hostname_verification: invalid argument " + str(enable) + " specified") + if (self.need_server_auth == False): + return self.fail_response(13001, "in NaServer::set_hostname_verification: server certificate verification is not enabled") + self.need_cn_verification = enable + return None; + + def is_hostname_verification_enabled(self): + """ Determines whether hostname verification is enabled or not. + Returns True if it is enabled, else returns False + """ + + return self.need_cn_verification; + + ## "private" subroutines for use by the public routines + + + ## This is used when the transmission path fails, and we don't actually + ## get back any XML from the server. + def fail_response(self, errno, reason): + """This is a private function, not to be called from outside NaElement + """ + n = NaElement("results") + n.attr_set("status","failed") + n.attr_set("reason",reason) + n.attr_set("errno",errno) + return n + + + + def start_element(self, name, attrs): + """This is a private function, not to be called from outside NaElement + """ + + n = NaElement(name) + self.ZAPI_stack.append(n) + self.ZAPI_atts = {} + attr_name = list(attrs.keys()) + attr_value = list(attrs.values()) + i = 0 + for att in attr_name : + val = attr_value[i] + i = i+1 + self.ZAPI_atts[att] = val + n.attr_set(att,val) + + + + def end_element(self, name): + """This is a private function, not to be called from outside NaElement + """ + + stack_len = len(self.ZAPI_stack) + + if (stack_len > 1): + n = self.ZAPI_stack.pop(stack_len - 1) + i = len(self.ZAPI_stack) + + if(i != stack_len - 1): + print("pop did not work!!!!\n") + + self.ZAPI_stack[i-1].child_add(n) + + + + def char_data(self, data): + """This is a private function, not to be called from outside NaElement + """ + + i = len(self.ZAPI_stack) + self.ZAPI_stack[i-1].add_content(data) + + + + def parse_xml(self, xmlresponse): + """This is a private function, not to be called from outside NaElement + """ + p = xml.parsers.expat.ParserCreate() + p.StartElementHandler = self.start_element + p.EndElementHandler = self.end_element + p.CharacterDataHandler = self.char_data + p.Parse(xmlresponse, 1) + stack_len = len(self.ZAPI_stack) + + if(stack_len <= 0): + return self.fail_response(13001,"Zapi::parse_xml-no elements on stack") + + r = self.ZAPI_stack.pop(stack_len - 1) + + if (r.element['name'] != "netapp") : + return self.fail_response(13001, "Zapi::parse_xml - Expected element but got " + r.element['name']) + + results = r.child_get("results") + + if (results == None) : + return self.fail_response(13001, "Zapi::parse_xml - No results element in output!") + + return results + + + + def parse_raw_xml(self, xmlrequest): + """This is a private function, not to be called from outside NaElement + """ + + p = xml.parsers.expat.ParserCreate() + p.StartElementHandler = self.start_element + p.EndElementHandler = self.end_element + p.CharacterDataHandler = self.char_data + p.Parse(xmlrequest,1) + stack_len = len(self.ZAPI_stack) + + if(stack_len <= 0): + return self.fail_response(13001,"Zapi::parse_xml-no elements on stack") + + r = self.ZAPI_stack.pop(stack_len - 1) + + return r + +try: + class CustomHTTPSConnection(httplib.HTTPSConnection): + """ Custom class to make a HTTPS connection, with support for Certificate Based Authentication""" + + def __init__(self, host, port, key_file, cert_file, ca_file, + need_server_auth, need_cn_verification, timeout=None): + httplib.HTTPSConnection.__init__(self, host, port=port, key_file=key_file, + cert_file=cert_file,timeout=timeout) + self.key_file = key_file + self.cert_file = cert_file + self.ca_file = ca_file + self.timeout = timeout + self.need_server_auth = need_server_auth + self.need_cn_verification = need_cn_verification + + def connect(self): + sock = socket.create_connection((self.host, self.port), self.timeout) + + if (self.need_server_auth == True): + self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ca_certs=self.ca_file, cert_reqs=ssl.CERT_REQUIRED) + else: + self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ca_certs=self.ca_file) + + def get_commonName(self): + cert = self.sock.getpeercert() + for x in cert['subject'] : + if (x[0][0].lower() == 'commonname') : + return x[0][1] + return "" +except AttributeError: + pass + diff --git a/ZenPacks/CS/NetApp/SevenMode/lib/ZenOntap.py b/ZenPacks/CS/NetApp/SevenMode/lib/ZenOntap.py new file mode 100644 index 0000000..f8f378d --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/lib/ZenOntap.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +import time, base64 +import twisted.web.client +from NaServer import * + +class FailResponse(Exception): + def __init__(self, value): + self.value = value + def __str__(self): + return repr(self.value) + +class ZenOntap(NaServer): + + def __init__(self, server, user, pwd, transport): + super(self.__class__, self).__init__(server, 1, 0) + self.set_admin_user(user, pwd) + self.set_transport_type(transport) + self._set_api_version() + + def _set_api_version(self): + api = self.invoke('system-get-ontapi-version') + self.major_version = api.child_get_string('major-version') + self.minor_version = min(17, api.child_get_string('minor-version')) + + def get_api_version(self): + return '{0}.{1}'.format(self.major_version, self.minor_version) + + def invoke_elem_async(self, req): + server = self.server + port = self.port + ttype = self.transport_type.lower() + url = self.url + xmlrequest = req.toEncodedString() + user = self.user + password = self.password + vf = self.vfiler + oid = self.originator_id + + vfiler = 'vfiler="{0}" '.format(vf) if vf != '' else '' + origid = 'originator_id="{0}" '.format(oid) if oid != '' else '' + + url = '{0}://{1}:{2}{3}'.format(ttype, server, port, url) + method = 'POST' + uname_pass = '{0}:{1}'.format(user, password) + base64auth = base64.encodestring(uname_pass)[:-1] + content = ( + '', + ''.format(self.dtd), + ''.format(ZAPI_xmlns), + xmlrequest, + '', + ) + content = '{0}{1}{2}{3}{4}{5}{6}'.format(*content) + headers = { + 'Content-type': 'text/xml; charset="UTF-8"', + 'Authorization': 'Basic {0}'.format(base64auth), + 'Content-length': len(content), + } + + def process_result(raw): + return self.parse_xml(raw) + + return twisted.web.client.getPage( + url, method = method, headers = headers, + postdata = content).addCallback(process_result) + + def get(self, element): + response = self.invoke_elem(element) + if response.results_status() == 'failed': + err = '[{0}] {1}' + err = err.format(response.results_errno(), response.results_reason()) + raise FailResponse(err) + else: + return response + + +if __name__ == '__main__': + from twisted.internet import reactor, defer + from NaElement import NaElement + + def callback(results): + reactor.stop() + naElements = [] + for success, result in results: + if success: + status = result.results_status() + if status == 'passed': + naElements.append(result) + elif status == 'failed': + print result.results_reason() + else: + print result.printTraceback() + return naElements + + perfGet = { + # object names + 'system': { + # instances + 'system': + # counters + ['serial_no', + 'system_id', + 'hostname', + 'ontap_version', + 'system_model' + ], + }, + } + + server = ZenOntap('8.8.8.8', 'un', 'pw', 'HTTPS') + + request = NaElement('perf-object-get-instances') + for perf, instances in perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter) + request.child_add(reqcnts) + request.child_add(reqinst) + + response = server.invoke_elem_async(request) + deferreds = [response] + naElements = defer.DeferredList(deferreds, consumeErrors=True).addCallback(callback) + reactor.run() + + nodes = [] + for result in naElements.__dict__['result']: + if result.child_get('instances') is not None: + print result.child_get_string('timestamp') + nodes.extend(result \ + .child_get('instances') \ + .child_get('instance-data') \ + .child_get('counters') \ + .children_get()) + + perf = {} + for node in nodes: + name, value = node.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + perf[dkey] = dvalue + + print perf diff --git a/ZenPacks/CS/NetApp/SevenMode/lib/__init__.py b/ZenPacks/CS/NetApp/SevenMode/lib/__init__.py new file mode 100644 index 0000000..143f486 --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/lib/__init__.py @@ -0,0 +1 @@ +# __init__.py diff --git a/ZenPacks/CS/NetApp/SevenMode/modeler/__init__.py b/ZenPacks/CS/NetApp/SevenMode/modeler/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/ZAPI/NetApp7Mode.py b/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/ZAPI/NetApp7Mode.py new file mode 100644 index 0000000..7efb39f --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/ZAPI/NetApp7Mode.py @@ -0,0 +1,438 @@ +import logging +log = logging.getLogger('zen.NetApp.SevenMode') + +from Products.DataCollector.plugins.CollectorPlugin import PythonPlugin +from Products.DataCollector.plugins.DataMaps import ObjectMap, RelationshipMap +from Products.ZenUtils.Utils import prepId + +from ZenPacks.CS.NetApp.SevenMode.lib.NaElement import NaElement +from ZenPacks.CS.NetApp.SevenMode.lib.ZenOntap import ZenOntap, FailResponse + +class NetApp7Mode(PythonPlugin): + deviceProperties = PythonPlugin.deviceProperties + ( + 'zNetAppFiler', + 'zNetAppUser', + 'zNetAppPassword', + 'zNetAppTransport', + ) + + perfGet = { + # object names + 'system': { + # instances + 'system': + # counters + ['serial_no', + 'system_id', + 'hostname', + 'ontap_version', + 'system_model' + ], + }, + } + + def collect(self, device, unused): + + if device.zNetAppFiler == '': + device.zNetAppFiler = device.manageIp + + server = ZenOntap( + device.zNetAppFiler, + device.zNetAppUser, + device.zNetAppPassword, + device.zNetAppTransport) + + ############################################### + # collect general system data + results = {} + + # prepare request + request = NaElement('perf-object-get-instances') + for perf, instances in self.perfGet.iteritems(): + request.child_add_string('objectname', perf) + reqinst = NaElement('instances') + for instance, counters in instances.iteritems(): + reqinst.child_add_string('instance', instance) + reqcnts = NaElement('counters') + for counter in counters: + reqcnts.child_add_string('counter', counter) + request.child_add(reqcnts) + request.child_add(reqinst) + + # request data + try: + response = server.get(request) + except FailResponse, e: + log.warning(e) + return + + # get data from response + if response.child_get('instances') is not None: + elements = response \ + .child_get('instances') \ + .child_get('instance-data') \ + .child_get('counters') \ + .children_get() + + # put data to results + for element in elements: + name, value = element.children_get() + dkey = name.element['content'] + dvalue = value.element['content'] + results[dkey] = dvalue + + ############################################# + # collect components data + + # request + request = NaElement('aggr-list-info') + request.child_add_string('verbose', 'true') + try: + response = server.get(request) + except FailResponse, e: + log.warning(e) + return + + ############################################## + # collect aggregates data + results['aggregates'] = {} + aggregates = response.child_get('aggregates') + for aggr in aggregates.children_get(): + agname = aggr.child_get_string('name') + results['aggregates'][agname] = { + 'name': agname, + 'state': aggr.child_get_string('state'), + 'mount_state': aggr.child_get_string('mount-state'), + 'raid_size': aggr.child_get_string('raid-size'), + 'raid_status': aggr.child_get_string('raid-status'), + 'disk_count': aggr.child_get_string('disk-count'), + 'volume_count': aggr.child_get_string('volume-count'), + 'plex_count': aggr.child_get_string('plex-count'), + 'total_bytes': aggr.child_get_int('size-total'), + } + + ############################################ + # collect plexes data + results['aggregates'][agname] \ + ['plexes'] = {} + + # get data from response + plexes = aggr.child_get('plexes') + for plex in plexes.children_get(): + plname = plex.child_get_string('name') + results['aggregates'][agname]['plexes'][plname] = { + 'name': plname, + 'state': plex.child_get_string('is-online'), + } + + ####################################### + # collect RAID groups data + results['aggregates'][agname] \ + ['plexes'][plname] \ + ['raid_groups'] = {} + + # get data from response + rgroups = plex.child_get('raid-groups') + for rgroup in rgroups.children_get(): + rgname = rgroup.child_get_string('name') + results['aggregates'][agname]['plexes'][plname]['raid_groups'][rgname] = { + 'name': rgname, + } + + ###################################### + # collect disks data + results['aggregates'][agname] \ + ['plexes'][plname] \ + ['raid_groups'][rgname] \ + ['disks']= {} + + # get data from response + rdisks = rgroup.child_get('disks') + for rdisk in rdisks.children_get(): + rdiskname = rdisk.child_get_string('name') + + # request + request = NaElement('disk-list-info') + request.child_add_string('disk', rdiskname) + response = server.get(request) + + disks = response.child_get('disk-details') + for disk in disks.children_get(): + results['aggregates'][agname]['plexes'][plname]['raid_groups'][rgname]['disks'][rdiskname] = { + 'name': rdiskname, + 'node': disk.child_get_string('node'), + 'disk_uid': disk.child_get_string('disk-uid'), + 'raid_state': disk.child_get_string('raid-state'), + 'raid_type': disk.child_get_string('raid-type'), + 'bay': disk.child_get_string('bay'), + 'byte_per_sector': disk.child_get_string('bytes-per-sector'), + 'disk_type': disk.child_get_string('disk-type'), + 'rpm': disk.child_get_string('rpm'), + 'model': disk.child_get_string('disk-model'), + 'serialnr': disk.child_get_string('serial-number'), + 'firmware': disk.child_get_string('firmware-revision'), + 'poweron_hours': disk.child_get_string('poweron-hours'), + 'grown_defect_list_count': disk.child_get_string('grown-defect-list-count'), + 'total_bytes': disk.child_get_int('physical-space'), + } + + ################################## + # collect volumes data + results['volumes'] = {} + + volumes = aggr.child_get('volumes') + for volume in volumes.children_get(): + volumename = volume.child_get_string('name') + + # request + request = NaElement('volume-list-info') + request.child_add_string('volume', volumename) + response = server.get(request) + + volumes = response.child_get('volumes') + for volume in volumes.children_get(): + results['volumes'][volumename] = { + 'name': volumename, + 'type': volume.child_get_string('type'), + 'block_type': volume.child_get_string('block-type'), + 'volume_state': volume.child_get_string('state'), + 'mirror_status': volume.child_get_string('mirror-status'), + 'inconsistent': volume.child_get_string('is-inconsistent'), + 'unrecoverable': volume.child_get_string('is-unrecoverable'), + 'invalid': volume.child_get_string('is-invalid'), + 'total_bytes': volume.child_get_int('size-total'), + } + + ################################## + # collect spare disks data + results['spare_disks'] = {} + + # request + request = NaElement('disk-list-info') + response = server.get(request) + + disks = response.child_get('disk-details') + for disk in disks.children_get(): + raid_state = disk.child_get_string('raid-state') + if raid_state != 'present': + diskname = disk.child_get_string('name') + results['spare_disks'][diskname] = { + 'name': diskname, + 'node': disk.child_get_string('node'), + 'disk_uid': disk.child_get_string('disk-uid'), + 'raid_state': raid_state, + 'raid_type': disk.child_get_string('raid-type'), + 'bay': disk.child_get_string('bay'), + 'byte_per_sector': disk.child_get_string('bytes-per-sector'), + 'disk_type': disk.child_get_string('disk-type'), + 'rpm': disk.child_get_string('rpm'), + 'model': disk.child_get_string('disk-model'), + 'serialnr': disk.child_get_string('serial-number'), + 'firmware': disk.child_get_string('firmware-revision'), + 'grown_defect_list_count': disk.child_get_string('grown-defect-list-count'), + 'total_bytes': disk.child_get_int('physical-space'), + } + if raid_state != 'partner': + results['spare_disks'][diskname]['poweron_hours'] = disk.child_get_string('poweron-hours') + else: + results['spare_disks'][diskname]['poweron_hours'] = '0' + + + #log.info(results) + return results + + def process(self, device, results, unused): + maps = [] + + # NetAppDevice + maps.append(self.objectMap(dict( + renameDevice = results['hostname'], + setHWSerialNumber = results['serial_no'], + setHWTag = results['system_id'], + setHWProductKey = results['system_model'], + setOSProductKey = results['ontap_version'].split(':')[0], + ))) + + # Aggregate Component + maps.extend(self.getAggsRelMaps( + results['aggregates'], + results['volumes'], + results['spare_disks'] + )) + + return maps + + def getAggsRelMaps(self, aggregates, volumes, spare_disks): + obj_maps = [] + rel_maps = [] + + for name, data in aggregates.iteritems(): + aggr_id = prepId(name) + obj_maps.append(ObjectMap(data=dict( + id = aggr_id, + aggr_name = name, + aggr_state = data['state'], + mount_state = data['mount_state'], + raid_size = data['raid_size'], + raid_status = data['raid_status'], + disk_count = data['disk_count'], + volume_count = data['volume_count'], + plex_count = data['plex_count'], + total_bytes = data['total_bytes'], + ))) + + # Plex Component + rel_maps.extend(self.getPlexesRelMaps( + aggregates[name]['plexes'], + 'aggregates/{0}'.format(aggr_id) + )) + + # Volume component + # TODO: put each volume to its aggregate only + # now it works only when one aggregate is configured + rel_maps.extend(self.getVolumesRelMaps( + volumes, + 'aggregates/{0}'.format(aggr_id) + )) + + # SpareDisk component + rel_maps.extend(self.getSpareDisksRelMaps( + spare_disks, + 'aggregates/{0}'.format(aggr_id) + )) + + return [RelationshipMap( + relname = 'aggregates', + modname = 'ZenPacks.CS.NetApp.SevenMode.Aggregate', + objmaps = obj_maps)] + rel_maps + + def getPlexesRelMaps(self, plexes, compname): + obj_maps = [] + rel_maps = [] + + for name, data in plexes.iteritems(): + plx_id = prepId(name) + obj_maps.append(ObjectMap(data=dict( + id = plx_id, + plex_name = name, + plex_state = bool(data['state']), + ))) + + # RaidGroup component + rel_maps.extend(self.getRaidGroupsRelMaps( + plexes[name]['raid_groups'], + '{0}/plexes/{1}'.format(compname, plx_id) + )) + + return [RelationshipMap( + compname = compname, + relname = 'plexes', + modname = 'ZenPacks.CS.NetApp.SevenMode.Plex', + objmaps = obj_maps)] + rel_maps + + def getRaidGroupsRelMaps(self, rgroups, compname): + obj_maps = [] + rel_maps = [] + + for name, data in rgroups.iteritems(): + rg_id = prepId(name) + obj_maps.append(ObjectMap(data=dict( + id = rg_id, + rg_name = name, + ))) + + # Disk component + rel_maps.extend(self.getDisksRelMaps( + rgroups[name]['disks'], + '{0}/raid_groups/{1}'.format(compname, rg_id) + )) + + return [RelationshipMap( + compname = compname, + relname = 'raid_groups', + modname = 'ZenPacks.CS.NetApp.SevenMode.RaidGroup', + objmaps = obj_maps)] + rel_maps + + def getDisksRelMaps(self, disks, compname): + obj_maps = [] + + for name, data in disks.iteritems(): + disk_id = prepId(name) + obj_maps.append(ObjectMap(data=dict( + id = disk_id, + disk_name = name, + disk_uid = data['disk_uid'], + node = data['node'], + raid_state = data['raid_state'], + raid_type = data['raid_type'], + bay = data['bay'], + byte_per_sector = data['byte_per_sector'], + disk_type = data['disk_type'], + rpm = data['rpm'], + model = data['model'], + serialnr = data['serialnr'], + firmware = data['firmware'], + poweron_hours = data['poweron_hours'], + grown_defect_list_count = data['grown_defect_list_count'], + total_bytes = data['total_bytes'], + ))) + + return [RelationshipMap( + compname = compname, + relname = 'disks', + modname = 'ZenPacks.CS.NetApp.SevenMode.Disk', + objmaps = obj_maps)] + + def getVolumesRelMaps(self, volumes, compname): + obj_maps = [] + + for name, data in volumes.iteritems(): + vol_id = prepId(name) + obj_maps.append(ObjectMap(data=dict( + id = vol_id, + volume_name = name, + volume_type = data['type'], + block_type = data['block_type'], + volume_state = data['volume_state'], + mirror_status = data['mirror_status'], + inconsistent = data['inconsistent'], + unrecoverable = data['unrecoverable'], + invalid = data['invalid'], + total_bytes = data['total_bytes'], + ))) + + return [RelationshipMap( + compname = compname, + relname = 'volumes', + modname = 'ZenPacks.CS.NetApp.SevenMode.Volume', + objmaps = obj_maps)] + + def getSpareDisksRelMaps(self, spares, compname): + obj_maps = [] + + for name, data in spares.iteritems(): + spare_id = prepId(name) + obj_maps.append(ObjectMap(data=dict( + id = spare_id, + sparedisk_name = name, + node = data['node'], + disk_uid = data['disk_uid'], + raid_state = data['raid_state'], + raid_type = data['raid_type'], + bay = data['bay'], + byte_per_sector = data['byte_per_sector'], + disk_type = data['disk_type'], + rpm = data['rpm'], + model = data['model'], + serialnr = data['serialnr'], + firmware = data['firmware'], + poweron_hours = data['poweron_hours'], + grown_defect_list_count = data['grown_defect_list_count'], + total_bytes = data['total_bytes'], + ))) + + return [RelationshipMap( + compname = compname, + relname = 'spare_disks', + modname = 'ZenPacks.CS.NetApp.SevenMode.SpareDisk', + objmaps = obj_maps)] diff --git a/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/ZAPI/__init__.py b/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/ZAPI/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/__init__.py b/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/CS/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/__init__.py b/ZenPacks/CS/NetApp/SevenMode/modeler/plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ZenPacks/CS/NetApp/SevenMode/objects/objects.xml b/ZenPacks/CS/NetApp/SevenMode/objects/objects.xml new file mode 100644 index 0000000..57090da --- /dev/null +++ b/ZenPacks/CS/NetApp/SevenMode/objects/objects.xml @@ -0,0 +1,2380 @@ + + + + + +['CS.ZAPI.NetApp7Mode'] + + +ZenPacks.CS.NetApp.SevenMode.NetAppDevice + + +True + + +/zport/dmd/++resource++netapp/img/icon.png + + +['NetApp7Mode_Device'] + + + + +ZenPacks.CS.NetApp.SevenMode.Aggregate + + + + +Python + + +True + + +${here/id} + + +/Storage/NetApp + + +netappaggregate + + +3 + + +300 + + +ZenPacks.CS.NetApp.SevenMode.datasource_plugins.NetAppAggregateDSP.NetAppAggregateDSP + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + + + + + +/Storage/NetApp + + +5 + + +['aggregate_percentage_used'] + + +True + + +90 + + +0 + + + + + + +100 + + +500 + + +% + + +False + + +False + + +0 + + +100 + + +True + + +1 + + + + +0 + + +high aggregate usage + + +${graphPoint/id} + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +aggregate_percentage_used + + +AVERAGE + + + + + + +100 + + +500 + + +per sec + + +False + + +False + + +0 + + +None + + +True + + +2 + + + + +0 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +aggregate_user_reads + + +AVERAGE + + + + +1 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +aggregate_user_writes + + +AVERAGE + + + + + + +100 + + +500 + + +Bytes + + +False + + +True + + +0 + + +None + + +True + + +0 + + + + +1 + + +00A000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +aggregate_size_available + + +AVERAGE + + + + +0 + + +E00000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +aggregate_size_used + + +AVERAGE + + + + + + + + +Products.ZenModel.Device + + + + +Python + + +True + + +${here/id} + + +/Storage/NetApp + + +netappdevice + + +3 + + +300 + + +ZenPacks.CS.NetApp.SevenMode.datasource_plugins.NetAppDeviceDSP.NetAppDeviceDSP + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + + + + + +/Storage/NetApp + + +5 + + +['device_cpu_pct'] + + +True + + +50 + + +0 + + + + + + +100 + + +500 + + +percent + + +False + + +False + + +0 + + +100 + + +True + + +0 + + + + +1 + + +AREA + + +1 + + +False + + +%6.2lf + + +${graphPoint/id} + + +-1 + + +device_cpu_pct + + +AVERAGE + + + + +0 + + +high CPU utilization + + +${graphPoint/id} + + + + + + +100 + + +500 + + +B/sec + + +False + + +True + + +0 + + +None + + +True + + +5 + + + + +0 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_disk_data_read + + +AVERAGE + + + + +1 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_disk_data_written + + +AVERAGE + + + + + + +100 + + +500 + + +milisec + + +False + + +False + + +0 + + +None + + +True + + +3 + + + + +2 + + +LINE + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +device_sys_avg_latency + + +AVERAGE + + + + +0 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +device_sys_read_latency + + +AVERAGE + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +device_sys_write_latency + + +AVERAGE + + + + + + +100 + + +500 + + +B/sec + + +False + + +True + + +0 + + +None + + +True + + +4 + + + + +0 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_net_data_recv + + +AVERAGE + + + + +1 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_net_data_sent + + +AVERAGE + + + + + + +100 + + +500 + + +ops/sec + + +False + + +False + + +0 + + +None + + +True + + +1 + + + + +1 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_cifs_ops + + +AVERAGE + + + + +3 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_fcp_ops + + +AVERAGE + + + + +2 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_http_ops + + +AVERAGE + + + + +4 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_iscsi_ops + + +AVERAGE + + + + +0 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_nfs_ops + + +AVERAGE + + + + + + +100 + + +500 + + +ops/sec + + +False + + +False + + +0 + + +None + + +True + + +2 + + + + +0 + + +AREA + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_read_ops + + +AVERAGE + + + + +2 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_total_ops + + +AVERAGE + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +device_write_ops + + +AVERAGE + + + + + + + + +ZenPacks.CS.NetApp.SevenMode.Disk + + + + +Python + + +True + + +${here/id} + + +/Storage/NetApp + + +netappdisk + + +3 + + +300 + + +ZenPacks.CS.NetApp.SevenMode.datasource_plugins.NetAppDiskDSP.NetAppDiskDSP + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + + + + + +/Storage/NetApp + + +5 + + +['disk_percentage_used'] + + +True + + +98 + + +0 + + + + + + +100 + + +500 + + +% + + +False + + +False + + +0 + + +100 + + +True + + +1 + + + + +0 + + +high disk usage + + +${graphPoint/id} + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +disk_percentage_used + + +AVERAGE + + + + + + +100 + + +500 + + +per sec + + +False + + +False + + +0 + + +None + + +True + + +2 + + + + +0 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +disk_user_reads + + +AVERAGE + + + + +1 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +disk_user_writes + + +AVERAGE + + + + + + +100 + + +500 + + +Bytes + + +False + + +True + + +0 + + +None + + +True + + +0 + + + + +1 + + +00A000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +disk_size_available + + +AVERAGE + + + + +0 + + +E00000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +disk_size_used + + +AVERAGE + + + + + + + + +ZenPacks.CS.NetApp.SevenMode.Plex + + + + +ZenPacks.CS.NetApp.SevenMode.RaidGroup + + + + +ZenPacks.CS.NetApp.SevenMode.SpareDisk + + + + +Python + + +True + + +${here/id} + + +/Storage/NetApp + + +netappsparedisk + + +3 + + +300 + + +ZenPacks.CS.NetApp.SevenMode.datasource_plugins.NetAppSpareDiskDSP.NetAppSpareDiskDSP + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + + + + + +/Storage/NetApp + + +5 + + +['sparedisk_percentage_used'] + + +True + + +98 + + +0 + + + + + + +100 + + +500 + + +% + + +False + + +False + + +0 + + +100 + + +True + + +1 + + + + +0 + + +high disk usage + + +${graphPoint/id} + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +sparedisk_percentage_used + + +AVERAGE + + + + + + +100 + + +500 + + +Bytes + + +False + + +True + + +0 + + +None + + +True + + +0 + + + + +1 + + +00A000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +sparedisk_size_available + + +AVERAGE + + + + +0 + + +E00000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +sparedisk_size_used + + +AVERAGE + + + + + + + + +ZenPacks.CS.NetApp.SevenMode.Volume + + + + +Python + + +True + + +${here/id} + + +/Storage/NetApp + + +netappvolume + + +3 + + +300 + + +ZenPacks.CS.NetApp.SevenMode.datasource_plugins.NetAppVolumeDSP.NetAppVolumeDSP + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + +GAUGE + + +True + + + + + + + + +/Storage/NetApp + + +5 + + +['volume_percentage_used'] + + +True + + +70 + + +0 + + + + + + +100 + + +500 + + +microsec + + +False + + +False + + +0 + + +None + + +True + + +2 + + + + +2 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +volume_avg_latency + + +AVERAGE + + + + +0 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +volume_read_latency + + +AVERAGE + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +volume_write_latency + + +AVERAGE + + + + + + +100 + + +500 + + +% + + +False + + +False + + +0 + + +100 + + +True + + +1 + + + + +0 + + +high volume usage + + +${graphPoint/id} + + + + +1 + + +AREA + + +1 + + +False + + +%5.2lf + + +${graphPoint/id} + + +-1 + + +volume_percentage_used + + +AVERAGE + + + + + + +100 + + +500 + + +B/sec + + +False + + +True + + +0 + + +None + + +True + + +3 + + + + +0 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +volume_read_data + + +AVERAGE + + + + +1 + + +LINE + + +1 + + +False + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +volume_write_data + + +AVERAGE + + + + + + +100 + + +500 + + +Bytes + + +False + + +True + + +0 + + +None + + +True + + +0 + + + + +1 + + +00A000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +volume_size_available + + +AVERAGE + + + + +0 + + +E00000 + + +AREA + + +1 + + +True + + +%5.2lf%s + + +${graphPoint/id} + + +-1 + + +volume_size_used + + +AVERAGE + + + + + + + + + + + + + + +http://www.netapp.com + + + + +() + + + + +FAS2240-2 + + +['FAS2240-2'] + + +False + + + + +NetApp Release 8.1.1RC1 7-Mode + + +['NetApp Release 8.1.1RC1 7-Mode'] + + +False + + + + + diff --git a/ZenPacks/CS/NetApp/__init__.py b/ZenPacks/CS/NetApp/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/ZenPacks/CS/NetApp/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/ZenPacks/CS/__init__.py b/ZenPacks/CS/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/ZenPacks/CS/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/ZenPacks/__init__.py b/ZenPacks/__init__.py new file mode 100644 index 0000000..de40ea7 --- /dev/null +++ b/ZenPacks/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/screenshots/ss-01.png b/screenshots/ss-01.png new file mode 100644 index 0000000..c42e98e Binary files /dev/null and b/screenshots/ss-01.png differ diff --git a/screenshots/ss-02.png b/screenshots/ss-02.png new file mode 100644 index 0000000..a56fbcd Binary files /dev/null and b/screenshots/ss-02.png differ diff --git a/screenshots/ss-03.png b/screenshots/ss-03.png new file mode 100644 index 0000000..3c09479 Binary files /dev/null and b/screenshots/ss-03.png differ diff --git a/screenshots/ss-04.png b/screenshots/ss-04.png new file mode 100644 index 0000000..003d24b Binary files /dev/null and b/screenshots/ss-04.png differ diff --git a/screenshots/ss-05.png b/screenshots/ss-05.png new file mode 100644 index 0000000..9cc29a0 Binary files /dev/null and b/screenshots/ss-05.png differ diff --git a/screenshots/ss-06.png b/screenshots/ss-06.png new file mode 100644 index 0000000..594412a Binary files /dev/null and b/screenshots/ss-06.png differ diff --git a/screenshots/ss-07.png b/screenshots/ss-07.png new file mode 100644 index 0000000..43282c7 Binary files /dev/null and b/screenshots/ss-07.png differ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4a2a96f --- /dev/null +++ b/setup.py @@ -0,0 +1,79 @@ +################################ +# These variables are overwritten by Zenoss when the ZenPack is exported +# or saved. Do not modify them directly here. +# NB: PACKAGES is deprecated +NAME = "ZenPacks.CS.NetApp.SevenMode" +VERSION = "1.0.0" +AUTHOR = "htolic" +LICENSE = "GPLv2" +NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.CS', 'ZenPacks.CS.NetApp'] +PACKAGES = ['ZenPacks', 'ZenPacks.CS', 'ZenPacks.CS.NetApp', 'ZenPacks.CS.NetApp.SevenMode'] +INSTALL_REQUIRES = ['ZenPacks.zenoss.PythonCollector>=1.10.1'] +COMPAT_ZENOSS_VERS = ">=4.2.5" +PREV_ZENPACK_NAME = "" +# STOP_REPLACEMENTS +################################ +# Zenoss will not overwrite any changes you make below here. + +import os +from subprocess import Popen, PIPE +from setuptools import setup, find_packages + +# Run "make build" if a GNUmakefile is present. +if os.path.isfile('GNUmakefile'): + print 'GNUmakefile found. Running "make build" ..' + p = Popen('make build', stdout=PIPE, stderr=PIPE, shell=True) + print p.communicate()[0] + if p.returncode != 0: + raise Exception('"make build" exited with an error: %s' % p.returncode) + +setup( + # This ZenPack metadata should usually be edited with the Zenoss + # ZenPack edit page. Whenever the edit page is submitted it will + # overwrite the values below (the ones it knows about) with new values. + name=NAME, + version=VERSION, + author=AUTHOR, + license=LICENSE, + + # This is the version spec which indicates what versions of Zenoss + # this ZenPack is compatible with + compatZenossVers=COMPAT_ZENOSS_VERS, + + # previousZenPackName is a facility for telling Zenoss that the name + # of this ZenPack has changed. If no ZenPack with the current name is + # installed then a zenpack of this name if installed will be upgraded. + prevZenPackName=PREV_ZENPACK_NAME, + + # Indicate to setuptools which namespace packages the zenpack + # participates in + namespace_packages=NAMESPACE_PACKAGES, + + # Tell setuptools what packages this zenpack provides. + packages=find_packages(), + + # Tell setuptools to figure out for itself which files to include + # in the binary egg when it is built. + include_package_data=True, + + # The MANIFEST.in file is the recommended way of including additional files + # in your ZenPack. package_data is another. + #package_data = {} + + # Indicate dependencies on other python modules or ZenPacks. This line + # is modified by zenoss when the ZenPack edit page is submitted. Zenoss + # tries to put add/delete the names it manages at the beginning of this + # list, so any manual additions should be added to the end. Things will + # go poorly if this line is broken into multiple lines or modified to + # dramatically. + install_requires=INSTALL_REQUIRES, + + # Every ZenPack egg must define exactly one zenoss.zenpacks entry point + # of this form. + entry_points={ + 'zenoss.zenpacks': '%s = %s' % (NAME, NAME), + }, + + # All ZenPack eggs must be installed in unzipped form. + zip_safe=False, +)