PHP code example of drakelid / interface-alert-policy-manager

1. Go to this page and download the library: Download drakelid/interface-alert-policy-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

drakelid / interface-alert-policy-manager example snippets

bash
cd /opt/librenms

# Record the plugin so LibreNMS updates cannot drop it.
# Merge this entry by hand if composer.plugins.json already exists.
sudo -u librenms tee composer.plugins.json >/dev/null <<'JSON'
{
    "e --force
sudo -u librenms ./lnms plugin:enable interface-alert-policy-manager
sudo -u librenms php artisan optimize:clear
sudo systemctl reload "php$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')-fpm"
bash
sudo -u librenms php artisan migrate --force          # IAPM tables + queue tables + scale indexes
sudo -u librenms ./lnms plugin:enable interface-alert-policy-manager    # if not already active
sudo -u librenms php artisan optimize:clear
sudo systemctl reload "php$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')-fpm"
sudo -u librenms php artisan iapm:install-check
bash
echo 'IAPM_QUEUE_CONNECTION=database' | sudo tee -a /opt/librenms/.env
cd /opt/librenms && sudo -u librenms php artisan config:clear
bash
echo 'IAPM_QUEUE_WORKERS=0' | sudo tee -a /opt/librenms/.env
# optional: keep queue load off MySQL at scale
# echo 'IAPM_QUEUE_CONNECTION=redis' | sudo tee -a /opt/librenms/.env
cd /opt/librenms && sudo -u librenms php artisan config:clear
sudo -u librenms bash -lc 'command -v php'    # note the php path for the unit below
bash
sudo -u librenms php artisan migrate --force
sudo -u librenms php artisan optimize:clear
sudo systemctl reload "php$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')-fpm"
sudo systemctl restart 'iapm-worker@*'        # or `php artisan queue:restart` for scheduler-managed workers
sudo -u librenms php artisan iapm:install-check && sudo -u librenms php artisan iapm:health
bash
cd /opt/librenms
sudo -u librenms php composer.phar config repositories.iapm '{"type":"path","url":"../interface-alert-policy-manager","options":{"symlink":true}}'
sudo -u librenms env FORCE=1 ./scripts/composer_wrapper.php 
bash
sudo -u librenms php artisan tinker --execute="\$s=app(LibreNMS\Plugins\InterfaceAlertPolicyManager\Services\SettingStore::class); echo \$s->get('dispatch_mode','queue').PHP_EOL;"
sudo -u librenms php artisan tinker --execute="app(LibreNMS\Plugins\InterfaceAlertPolicyManager\Services\SettingStore::class)->put('dispatch_mode','queue');"
text
macros.device_up = 1 AND ports.ifAdminStatus = 'up' AND ports.ifOperStatus != 'up' AND ports.ignore = 0 AND ports.disabled = 0 AND ports.deleted = 0