8.2. Alert Modules

Alert scripts are located in the directory scripts/alerts in the git repository of your NetSpyGlass cluster.

├── scripts
│   ├── aggregation
│   │   ├── example.py
│   │   └── __init__.py
│   ├── alerts
│   │   ├── __init__.py
│   │   ├── nsg_bgp_session_down.py
│   │   ├── nsg_device_down.py
│   │   ├── nsg_high_cpu_util.py
│   │   ├── nsg_high_mem_util.py
│   │   ├── nsg_interface_down.py
│   │   └── nsg_snmp_timeout.py

A module in directory alerts might look like this (this is a file “alerts/alert_busy_cpu.py”):

import nw2rules
from nw2functions import *


def alert_busy_cpu(log):
    alert(
        name='busyCpuAlert',
        input=import_var('cpuUtil'),
        condition=lambda _, value: value > 75,
        description='CPU utilization is over 75% for 20% of time for the last 10 min',
        duration=600,
        percent_duration=20,
        notification_time=600,
        streams=['log'],
        fan_out=True
    )

NetSpyGlass monitors all python scripts in directory scripts and reloads them when they change. You do not need to restart the server for this. As usual, watch logs in the panel System/Logs/Python for errors when you modify and save one of these script files.