-
Notifications
You must be signed in to change notification settings - Fork 16
Feature - Resolve syslog IP against cacti Hosts #243
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
Conversation
Some devices dont send the device name as the hostname for syslog instead they send the IP This feature will allow for resolving the IP against the cacti host table as the device may not be in DNS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a feature to resolve syslog host identifiers (IPs or hostnames) against the Cacti host table, updating syslog device descriptions with Cacti's descriptions. This is particularly useful for devices that aren't in DNS but are monitored by Cacti, or devices that send IP addresses instead of hostnames in syslog messages.
Key changes:
- Added a new configuration option to enable Cacti host resolution for syslog messages
- Implemented host resolution logic that queries the Cacti database and updates syslog_incoming records
- Updated project documentation with agent configuration files and copilot instructions
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| setup.php | Adds configuration checkbox 'syslog_use_cacti_hosts' to enable the feature |
| functions.php | Implements syslog_check_cacti_hosts() function and integrates it into the syslog processing workflow |
| .gitignore | Removes .git* pattern from ignore list |
| .github/ISSUE_TEMPLATE/copilot-instructions.md | Adds documentation about syslog reception process |
| .github/ISSUE_TEMPLATE/agents/php-developer.agent.md | Adds PHP developer agent configuration |
| .github/ISSUE_TEMPLATE/agents/mysql-mariadb.agent.md | Adds MySQL/MariaDB DBA agent configuration |
| .github/ISSUE_TEMPLATE/agents/code-quality.agent.md | Adds code quality specialist agent configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/plugin_syslog into cacti_resolve_feature
Update the flow as follows 1) If we recive a host check DNS 2.) if the IP is not in DNS check the cacti host table 3.) Mark as invalid if we cant find it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
functions.php
Outdated
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is trailing whitespace on this line after the closing brace. Remove the trailing whitespace to maintain code cleanliness.
functions.php
Outdated
| } | ||
|
|
||
| // Check if hostname resolves via DNS | ||
| if ($host['host'] == gethostbyname($host['host'])) { |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DNS resolution check using gethostbyname() may produce incorrect results for valid IP addresses. When gethostbyname() is passed an IP address that doesn't have a reverse DNS entry, it returns the IP address itself. The condition $host['host'] == gethostbyname($host['host']) will be true for both unresolvable hostnames AND valid IP addresses without reverse DNS. This means valid IP addresses will incorrectly trigger the Cacti lookup or be marked as invalid. Consider using a more robust check that distinguishes between IP addresses and hostnames, or validating IP addresses separately using filter_var($host['host'], FILTER_VALIDATE_IP) before attempting DNS resolution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could add a forward lookup as well ?
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Dont just mark the device as invalid instead pass the original sent hostname/ip and log that it could not be resolved
1.) Provide a way to disable dns resolution if your hosts are not in DNS 2.) Prefix an invalid hostname with unresolved-original_hostname for better traceability
Allow for the check against cacti to continue
|
@bmfmancini, please update the documentation if you don't mind. I'll accept this now. |
|
@bmfmancini, we need a changelog.md update in a separate pull request please. |
|
Will do |
Syslog Hostname Validation Improvements:
syslog_check_cacti_hosts()infunctions.phpto resolve hostnames using the Cacti hosts table when DNS resolution fails, updatingsyslog_incomingrecords accordingly.syslog_update_reference_tables()to use DNS lookup first, then Cacti host resolution, and only mark asinvalid_hostif both fail, improving data accuracy and maintainability.setup.phpto reflect the new multi-step resolution logic.