Skip to content

Instantly share code, notes, and snippets.

@cluther
cluther / import-cisco-products
Created July 16, 2018 22:42
Import CISCO-PRODUCTS-MIB into Zenoss
#!/usr/bin/env python
import os
import re
import subprocess
import sys
import Globals
import transaction
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
@cluther
cluther / api.py
Last active May 22, 2018 18:52
Extending Zenoss JSON API
from Products.Zuul import getFacade
class ResolveSysRouter(DirectRouter):
"""
JSON API router.
This router is accessed via POST to a URL such as the following.
https://zenoss5.example.com/zport/dmd/resolvesys_router
@cluther
cluther / dsplugins.py
Created March 29, 2018 20:51
dsplugins.py
"""Monitors current conditions using the Weather Underground API."""
# Logging
import logging
LOG = logging.getLogger('zen.WeatherUnderground')
# stdlib Imports
import json
import random
import time
@cluther
cluther / NetBotzStatus.py
Last active March 29, 2018 16:41
NetBotzStatus.py
from twisted.spread import pb
from Products.ZenModel.ThresholdClass import ThresholdClass
from Products.ZenModel.ThresholdInstance import ThresholdContext
from Products.ZenModel.ThresholdInstance import MetricThresholdInstance
class NetBotzStatus(ThresholdClass):
meta_type = "NetBotz Status"
eventClass = "/Status"
#!/usr/bin/env python
#
# Example of using Python's csv module.
#
# Usage:
#
# python csv-example.py < input.csv
import csv
import sys
@cluther
cluther / l2-troubleshooting.py
Created April 28, 2017 14:46
Layer2 ZenPack Troubleshooting (>=1.3.4)
# Layer2 suppression troubleshootin in zendmd. (Layer2 >= 1.3.4)
import logging ; setLogLevel(logging.INFO)
from ZenPacks.zenoss.Layer2 import suppression
suppressor = suppression.get_suppressor(dmd)
device, settings = suppressor.get_device_and_settings("SERVER-DEVICE-ID")
# Can we get the device's immediate neighbors?
neighbors = suppressor.get_neighbors(device.getPrimaryId())
pprint(list(neighbors)) # list of neighbors
@cluther
cluther / datapoint-aggregator-example.markdown
Last active May 6, 2022 10:22
Datapoint Aggregator Example

Aggregating Network Throughput

The Calculated Performance (ZenPacks.zenoss.CalculatedPerformance) ZenPack adds two new datasources types to Zenoss: Calculated Performance, and Datapoint Aggregator.

The Calculated Performance datasource type allows datapoints to be collected that are derived from numeric model properties and the most recent value of other datapoints on the same device or component. This means that only model properties and datapoint values for the device or component the template is

@cluther
cluther / gist:a883fd71fb64a514b3f9
Created June 22, 2015 15:17
zenoss5-httpd-rproxy.conf
NameVirtualHost *:443
<VirtualHost *:443>
ServerName zen4
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key
SSLProxyEngine on
@cluther
cluther / devinate-template
Last active September 4, 2015 18:00
Zenoss: Make control center service definitions more appropriate for ZenPack development.
#!/usr/bin/env python
"""devinate-template (a.k.a. developinate-template)
This script can be used to take an existing Zenoss serviced service
definition and modify it to be more appropriate for a slimmed-down
ZenPack development environment. A compiled Zenoss serviced service
definition is expected on STDIN, and the modified service definition
will be written to STDOUT.
@cluther
cluther / show-webtx-datasources.py
Created January 30, 2015 15:34
Zenoss: Show WebTx datasource details.
#!/usr/bin/env zendmd
#
# Print details of all WebTx datasources.
from Products.Zuul.interfaces import ICatalogTool
from ZenPacks.zenoss.ZenWebTx.datasources.WebTxDataSource import WebTxDataSource
catalog = ICatalogTool(dmd.Devices)
for result in catalog.search(WebTxDataSource):