Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert: "Overlapping IP Addresses" missing #236

Open
SamKr opened this issue Sep 19, 2024 · 4 comments
Open

Alert: "Overlapping IP Addresses" missing #236

SamKr opened this issue Sep 19, 2024 · 4 comments

Comments

@SamKr
Copy link

SamKr commented Sep 19, 2024

Alarms and events are coming in perfectly through the API client. However, it appears one alarm is missing, that we do receive per email. I don't know if that's because UniFi triggers this at a later/different point in the process, so it never shows up in the regular alarmlist, or if perhaps some other function should be used. I've been unable to find it anywhere in the API browser.

This is the email in question:

Overlapping IP Addresses  

Multiple {redacted, sitename} devices are using the same IP address on {redacted}/24. 
Device Name:	{redacted} 
Time:	Sep 18, 2024 at 8:08 PM

When I go to the UniFi controller's webportal, the notification is there as well in System Log -> Critical:

Multiple devices are using the same IP address: {redacted}. Please check each device's configuration to ensure none are communicating with a rogue DHCP server.

Url:

https://{redacted}:8443/manage/{redacted}/syslog/systemCritical

Any idea on this?

@malle-pietje
Copy link
Collaborator

malle-pietje commented Sep 19, 2024

Adding routes for the syslogs in on the list of todo items. For now you can use the custom method to implement this.

It is a bit unclear to me what the difference and overlap exactly is between the syslogs and the alarms and events. If anyone has thoughts on this, please do share them here.

@SamKr
Copy link
Author

SamKr commented Sep 19, 2024

Thanks @malle-pietje, I'll run a syslog server for a while and see if any pattern comes up from that.

@SamKr
Copy link
Author

SamKr commented Sep 19, 2024

Custom API request is working like a charm as well in the meantime, great example script :)

For those who are looking for it (I use the script as scriptname.php $siteId):

<?php
/**
 * PHP API usage example
 *
 * contributed by: Art of WiFi
 * description:    example basic PHP script to execute a custom API request using the
 *                 custom_api_request() function/method
 */

/**
 * using the composer autoloader
 */
require_once 'vendor/autoload.php';

/**
 * include the config file (place your credentials etc. there if not already present)
 * see the config.template.php file for an example
 */
require_once 'config.php';

/**
 * The site to authorize the device with
 * https://github.com/Art-of-WiFi/UniFi-API-client#important-notes
 */
$site_id = isset($argv[1]) ? $argv[1] : 'default';

/**
 * Current timestamp in milliseconds
 */
$timestamp = round(microtime(true) * 1000);

/**
 * parameters
 */
$url            = '/v2/api/site/' . $site_id . '/system-log/system-critical-alert';
$request_method = 'POST';
$payload = [
            'timestampFrom'  => 0,
            'timestampTo' => $timestamp,
			'pageSize' => 100,
			'categories' => ["INTERNET","POWER","DEVICES","SYSTEM"],
			'pageNumber' => 0,
			'systemLogDeviceTypes' => ["GATEWAYS","SWITCHES","ACCESS_POINT","SMART_POWER","BUILDING_TO_BUILDING_BRIDGES","UNIFI_LTE","NON_NETWORK_DEVICES"]			
        ];
$return         = 'array';



/**
 * initialize the UniFi API connection class and log in to the controller and do our thing
 */
$unifi_connection = new UniFi_API\Client(
    $controlleruser,
    $controllerpassword,
    $controllerurl,
    $site_id,
    $controllerversion
);

$set_debug_mode = $unifi_connection->set_debug($debug);
$loginresults   = $unifi_connection->login();
$results        = $unifi_connection->custom_api_request($url, $request_method, $payload, $return);

/**
 * provide feedback in JSON format or as PHP Object
 */
echo json_encode($results, JSON_PRETTY_PRINT);
//print_r($results);

Edit: the script now fetches the current timestamp itself, since that's what you probably need.

@malle-pietje
Copy link
Collaborator

@SamKr thanks for sharing! Nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants