-
Notifications
You must be signed in to change notification settings - Fork 647
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
net-mgmt/zabbix-agent: add Zabbix Agent to plugins #97
Conversation
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.
Added some comments to the code.
| $result['section'] = 'OPNsense.zabbixagent'; | ||
| $result['description'] = gettext('Enterprise-class open source distributed monitoring agent'); | ||
| return array($result); | ||
| } |
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.
Seems to be not final.
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.
yes, it's a warning to myself and others what should be considered before enabling sync :)
| # Default: | ||
| # TLSPSKFile= | ||
|
|
||
| {% endif %} |
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.
In a generated configuration file, documentation comments are bloat.
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.
| {% if OPNsense.ZabbixAgent.settings.features.enableActiveChecks == '1' and OPNsense.ZabbixAgent.settings.features.activeCheckServers|default("") != "" %} | ||
| ServerActive={{OPNsense.ZabbixAgent.settings.features.activeCheckServers}} | ||
| {% else %} | ||
| # NOTE: Active checks are disabled |
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.
useless control path
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.
Removed.
| $logfile = '/var/log/zabbix/zabbix_agentd.log'; | ||
| $logclog = false; | ||
|
|
||
| require_once 'diag_logs_template.inc'; |
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.
probably should be integrated into MVC, so the log can be downloaded via the API.
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 a PR open if anyone wants to touch that.....
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 think this is outside the scope of this plugin.
| <activeCheckServers type="CSVListField"> | ||
| <Required>N</Required> | ||
| <multiple>Y</multiple> | ||
| <mask>/^([a-zA-Z0-9\.:\[\]\s\-]*?,)*([a-zA-Z0-9\.:\[\]\s\-]*)$/</mask> |
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.
whitespace (\s) in host:port combinations?
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.
Removed \s.
| <val_2>2 - error information</val_2> | ||
| <val_3>3 - warnings [default]</val_3> | ||
| <val_4>4 - debugging</val_4> | ||
| <val_5>5 - extended debugging</val_5> |
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.
probably remove the numbers as the user receives the strings. It is probably better to use round brackets because it would fit better into the rest of the system.
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.
Well, in Zabbix the number is actually the debug level. The text is just a vague description. I'm not against removing it, it's just that this is the most precise information...
Regarding the brackets, do you have some examples? I've not seen other GUI elements where the default value was highlighted in any way.
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.
it is only one entry:
3 - warnings [default] -> 3 - warnings (default)
or even better:
warnings (default)
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 most readable is:
"Warnings (3, default)"
"Debugging (4)"
"Extended debugging (5)"
Numbers don't have to be omitted, but we can't assume users know / want to know what numbers correspond to what meaning. It also makes translations clearer.
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.
@fabianfrz Yes, I know what entry you mean... I just wanted to see some examples why round brackets would be better suited. I know at least one example where round brackets would look really strange. And since I couldn't find any other highlighting for default values I've started using this variation for my other plugins already.
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.
@fichtner Nice proposal, I'll change it accordingly.
| public function indexAction() | ||
| { | ||
| // set page title | ||
| $this->view->title = "Zabbix Agent Settings"; |
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.
gettext
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.
yessir!
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.
Fixed. And I will fix this for the "hello world" plugin too ;)
net-mgmt/zabbix-agent/Makefile
Outdated
| PLUGIN_VERSION= 0.1 | ||
| PLUGIN_COMMENT= Enterprise-class open source distributed monitoring agent | ||
| PLUGIN_DEPENDS= zabbix32-agent | ||
| PLUGIN_MAINTAINER= opnsense@moov.de |
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.
maybe align the values
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.
Fixed. Tabs are evil.
|
please add a package description (same directory as the makefile). This will be shown to the user in the future if he wants more information about the plugin. |
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.
good work, just being picky
net-mgmt/zabbix-agent/Makefile
Outdated
| PLUGIN_COMMENT= Enterprise-class open source distributed monitoring agent | ||
| PLUGIN_DEPENDS= zabbix32-agent | ||
| PLUGIN_MAINTAINER= opnsense@moov.de | ||
|
|
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.
PLUGIN_DEVEL=yes
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.
Added.
net-mgmt/zabbix-agent/Makefile
Outdated
| PLUGIN_NAME= zabbix-agent | ||
| PLUGIN_VERSION= 0.1 | ||
| PLUGIN_COMMENT= Enterprise-class open source distributed monitoring agent | ||
| PLUGIN_DEPENDS= zabbix32-agent |
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.
is this the actual package that we use? https://github.com/opnsense/tools/blob/master/config/17.1/ports.conf#L88
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's no point using such an outdated version anymore. I strongly suggest to use 3.2 (or at a minimum 3.0) by now.
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 misread 32 as 23... ok, will update tools.git
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 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.
Maybe also add a upgrade warning to the release notes, just in case someone is already using Zabbix Agent on OPNsense without a GUI.
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 package name changes, no problem until they install the plugin, but I'll try to think of something.
| */ | ||
|
|
||
| /** | ||
| XXX: needs investigation, hostname must be unique/replaced/excluded on secondary node(s) |
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.
yes, this is really bad for sync. why not use the system hostname instead to avoid the clash?
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.
We can't just use the hostname. It must match the hostname in the Zabbix Server, otherwise many checks will not work. That's why it must be configurable.
| $response = $backend->configdRun("zabbixagent status"); | ||
|
|
||
| if (strpos($response, "not running") > 0) { | ||
| if ($mdlAgent->settings->main->enabled->__toString() == 1) { |
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.
although just boilerplate, it's quirky: __toString() == "1"
| } | ||
| } elseif (strpos($response, "is running") > 0) { | ||
| $status = "running"; | ||
| } elseif ($mdlAgent->settings->main->enabled->__toString() == 0) { |
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.
"0"
| @@ -0,0 +1,11 @@ | |||
| #!/bin/sh | |||
|
|
|||
| AGENT_DIRS="/var/run/zabbix /var/log/zabbix /usr/local/etc/zabbix_agentd.d" | |||
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.
have you double checked with pkg-plist files? they can have other important dirs.
note this is also mostly for /var if MFS was enabled as /usr/local is persistent and likely created by the package install
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.
Well, in theory the package creates %%ETCDIR%%/zabbix_agentd.conf.d, but it doesn't work for me (it's not being created on package install). I've changed the code to use this (FreeBSD) default directory instead, but I let setup.sh create the directory.
| @@ -0,0 +1,34 @@ | |||
| [setup] | |||
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.
is this called separately? if not can zap
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.
Zapped.
| message:restarting zabbix_agentd | ||
|
|
||
| [status] | ||
| command:/usr/local/etc/rc.d/zabbix_agentd status || exit 0 |
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.
doesn't this return the status if you let it? not as script_output, then check for error
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.
Fixed. Was using this most likely because of an old bug (in HAProxy plugin).
| {% else %} | ||
| zabbix_agentd_enable=NO | ||
| {% endif %} | ||
| zabbix_agentd_config=/usr/local/etc/zabbix_agentd.conf |
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.
into enable block, setup invoke is also missing:
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.
Oh nice! I wasn't aware of this. Added.
| $logfile = '/var/log/zabbix/zabbix_agentd.log'; | ||
| $logclog = false; | ||
|
|
||
| require_once 'diag_logs_template.inc'; |
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 a PR open if anyone wants to touch that.....
|
@fabianfrz @fichtner Thanks for your feedback! I've incorporated all changes. Let me know if more should be changed/fixed. |
|
looks OK to me. |
|
@fraenki FYI, I had to do this opnsense/tools@54a0e5616337 due to the bump to 3.x |

From the authors of Zabbix:
This will add the Zabbix Agent to our growing list of plugins, effectively allowing OPNsense to be monitored with Zabbix.
This version of the plugin is ready for use, but not feature complete (from my point of view). Thus I've set the version to 0.1 for now.
The wishlist for version 1.0 (or later):