This is the third in a series of articles about writing an SSH-based ZenPack from scratch, the SSH ZenPack Development Tutorial Series. This series follows the development of the Mac OS X ZenPack.
The 0.3 release of this ZenPack adds support for modeling the software inventory for the Software tab with the zenoss.cmd.osx.software modeler plugin and tests to go with it. The software.py modeler has a process method that iterates over the command output (which tries reduce the amount of content across the wire and to strip out the '©' since it isn't an ascii symbol and makes parsing more difficult). There are 2 helper methods for parsing the date and manufacturer. The parse_date method would greatly take advantage of the datetime.strptime method, but this isn't supported until Python 2.5. The parse_manufacturer method makes some short-cut assumptions about matching to reduce the complexity of the rules, but essentially it has many special cases to cover to pull out the manufacturers.
The directory structure has been updated, with changes marked in green:
- setup.py
- contains build information for the .egg, updated version number to 0.3
- COPYRIGHT.txt
- standard copyright file, GPLv2
- MANIFEST.in
- used by build to include everything
- ZenPacks/__init__.py*
- ZenPacks/community/__init__.py*
- ZenPacks/community/OSX/__init__.py
- creates the /Server/SSH/OSX device class
- registers the collector plugins (cpu, memory, software, uname_a)
- ZenPacks/community/OSX/modeler/__init__.py*
- ZenPacks/community/OSX/modeler/plugins/__init__.py*
- ZenPacks/community/OSX/modeler/plugins/zenoss/__init__.py*
- ZenPacks/community/OSX/modeler/plugins/zenoss/cmd/__init__.py*
- ZenPacks/community/OSX/modeler/plugins/zenoss/cmd/osx/__init__.py*
- ZenPacks/community/OSX/modeler/plugins/zenoss/cmd/osx/cpu.py
- modeler plugin that parses the output of:
system_profiler -detailLevel mini SPHardwareDataType
- ZenPacks/community/OSX/modeler/plugins/zenoss/cmd/osx/memory.py
- modeler plugin that parses the output of:
system_profiler -detailLevel mini SPHardwareDataType | grep Memory
- ZenPacks/community/OSX/modeler/plugins/zenoss/cmd/osx/software.py
- modeler plugin that parses the output of:
system_profiler SPApplicationsDataType | sed '/Kind:/d' | sed '/64-Bit (Intel):/d' | sed '/^$/d' | sed 's/\©/\(c\)/g'
- ZenPacks/community/OSX/modeler/plugins/zenoss/cmd/osx/uname_a.py
- modeler plugin that parses the output of:
uname -a && system_profiler SPHardwareDataType | grep 'Serial Number (system)' && system_profiler -detailLevel mini | grep 'Model Identifier' && system_profiler -detailLevel mini SPSoftwareDataType | grep 'System Version'
- ZenPacks/community/OSX/objects/objects.xml
- adds the zCollectorPlugins (lines 5-7) (cpu, memory, uname_a, software)
- updates zFileSystemMapIgnoreTypes to ignore 'devfs' and 'map' filesystem types (lines 8-10), not used yet
- ZenPacks/community/OSX/tests/__init__.py*
- ZenPacks/community/OSX/tests/plugindata/__init__.py*
- ZenPacks/community/OSX/tests/plugindata/osx/__init__.py*
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/cpu
- shell command and output for a 10.6 machine's CPU
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/cpu.py
- results from the modeler plugin running against the CPU test data
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/memory
- shell command and output for a 10.6 machine's memory
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/memory.py
- results from the modeler plugin running against the memory test data
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/software
- shell command and output for a 10.6 machine's software
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/software.py
- results from the modeler plugin running against the software test data
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/uname_a
- shell command and output for a 10.6 machine's uname
- ZenPacks/community/OSX/tests/plugindata/osx/elzar/uname_a.py
- results from the modeler plugin running against the uname test data
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/cpu
- shell command and output for a 10.5 machine's CPU
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/cpu.py
- results from the modeler plugin running against the CPU test data
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/memory
- shell command and output for a 10.5 machine's memory
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/memory.py
- results from the modeler plugin running against the memory test data
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/software
- shell command and output for a 10.5 machine's software
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/software.py
- results from the modeler plugin running against the software test data
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/uname_a
- shell command and output for a 10.5 machine's uname
- ZenPacks/community/OSX/tests/plugindata/osx/ndnd/uname_a.py
- results from the modeler plugin running against the uname test data
- ZenPacks/community/OSX/tests/testPlugins.py
- loads and runs the cpu, memory, uname_a, software tests
*unless noted, the __init__.py files are empty |
For using this ZenPack:
- Download the ZenPack from the Mac OS X page or to build the ZenPack: make ZenPacks.community.OSX
- Install the ZenPack
- zopectl restart; zenhub restart
- Browse to the newly created /Server/SSH/OSX device class
- Click on the zProperties and the zCollectorPlugins
- You can run the unit tests against with: runtests ZenPacks.community.OSX
Add an OSX device to the /Server/SSH/OSX device class with the zCommandUsername and zCommandPassword set or the zKeyPath
- Model the device
- Navigate to the Software tab: