Skip to content

Conversation

@bmfmancini
Copy link
Member

@bmfmancini bmfmancini commented Jan 2, 2026

Syslog Hostname Validation Improvements:

  • Added syslog_check_cacti_hosts() in functions.php to resolve hostnames using the Cacti hosts table when DNS resolution fails, updating syslog_incoming records accordingly.
  • Updated syslog_update_reference_tables() to use DNS lookup first, then Cacti host resolution, and only mark as invalid_host if both fail, improving data accuracy and maintainability.
  • Clarified the configuration description for hostname validation in setup.php to reflect the new multi-step resolution logic.

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
Copy link
Contributor

Copilot AI left a 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.

bmfmancini and others added 2 commits January 1, 2026 22:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bmfmancini bmfmancini closed this Jan 2, 2026
@bmfmancini bmfmancini reopened this Jan 2, 2026
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
Copy link
Contributor

Copilot AI left a 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
Comment on lines 1801 to 1805





Copy link

Copilot AI Jan 2, 2026

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.

Suggested change

Copilot uses AI. Check for mistakes.
functions.php Outdated
}

// Check if hostname resolves via DNS
if ($host['host'] == gethostbyname($host['host'])) {
Copy link

Copilot AI Jan 2, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

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 ?

bmfmancini and others added 9 commits January 1, 2026 23:25
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
@TheWitness
Copy link
Member

@bmfmancini, please update the documentation if you don't mind. I'll accept this now.

@TheWitness TheWitness merged commit 9510330 into Cacti:develop Jan 3, 2026
3 checks passed
@TheWitness
Copy link
Member

@bmfmancini, we need a changelog.md update in a separate pull request please.

@bmfmancini
Copy link
Member Author

Will do

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

Successfully merging this pull request may close these issues.

2 participants