-
Notifications
You must be signed in to change notification settings - Fork 644
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
feat: Introduce xymon-client plugin #4260
base: master
Are you sure you want to change the base?
Conversation
@kumy You create an inc file for your plugin like this, if I remember correctly. It returns the services.
|
b33cde7
to
9d9929b
Compare
@Monviech Thanks! Added 🕺 |
Another question, the service is not automatically started after boot. Anything special to do? 🙏 EDIT: problably something related to
EDIT2: According to https://docs.opnsense.org/development/backend/overview.html#bootup, method 7 seems the new way. Trying… EDIT3: got it working. |
59695e0
to
a319db5
Compare
net-mgmt/xymon-client/src/etc/inc/plugins.inc.d/xymonclient.inc
Outdated
Show resolved
Hide resolved
'stop' => ['xymonclient stop'], | ||
], | ||
'name' => 'xymonclient', | ||
'pidfile' => "/usr/local/www/xymon/client/logs/clientlaunch.$fqdn.pid" |
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.
'pidfile' => "/usr/local/www/xymon/client/logs/clientlaunch.$fqdn.pid" | |
'pidfile' => "/var/run/xymonclient.pid" |
Two reasons, when making the pid dynamic, restart behavior might get flaky and the usual directory is /var/run
and not exposed via the webserver.
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.
@AdSchellevis
This is not my choice. It's defined in file /usr/local/etc/rc.d/xymon-client
from the package itself.
Excerpt:
#!/bin/sh
# PROVIDE: xymon_client
# REQUIRE: DAEMON
# KEYWORD: shutdown
. /etc/rc.subr
name=xymon_client
rcvar=xymon_client_enable
load_rc_config "$name"
: ${xymon_client_enable:=NO}
: ${xymon_client_user:=xymon}
pidfile="/usr/local/www/xymon/client/logs/clientlaunch.`hostname`.pid"
command=/usr/local/www/xymon/client/bin/xymonlaunch
command_args="--config=/usr/local/www/xymon/client/etc/clientlaunch.cfg --log=/usr/local/www/xymon/client/logs/clientlaunch.log --pidfile=${pidfile}"
start_precmd=xymon_precmd
[…]
The variable pidfile
is not overridable as it uses =
and not something like : ${pidfile:=...}
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 change the port rc.d script to better handle an external pid. Eventually we need to do something about the FreeBSD port itself though.
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.
Ok, done see latest commit and PR opnsense/ports#206
net-mgmt/xymon-client/src/etc/rc.syshook.d/start/50-xymon-client
Outdated
Show resolved
Hide resolved
...gmt/xymon-client/src/opnsense/mvc/app/controllers/Kumy/XymonClient/Api/ServiceController.php
Outdated
Show resolved
Hide resolved
...mt/xymon-client/src/opnsense/mvc/app/controllers/Kumy/XymonClient/Api/SettingsController.php
Outdated
Show resolved
Hide resolved
net-mgmt/xymon-client/src/opnsense/mvc/app/models/Kumy/XymonClient/Settings.xml
Outdated
Show resolved
Hide resolved
net-mgmt/xymon-client/src/opnsense/mvc/app/models/Kumy/XymonClient/Settings.xml
Outdated
Show resolved
Hide resolved
net-mgmt/xymon-client/src/opnsense/mvc/app/views/Kumy/XymonClient/index.volt
Outdated
Show resolved
Hide resolved
# to load values from our own template | ||
|
||
INCLUDE="include /usr/local/etc/xymon/xymonclient.cfg" | ||
FILE=/usr/local/www/xymon/client/etc/xymonclient.cfg |
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.
when possible, I would prevent saving settings in the www
directory, the post install script can be avoided by shipping the xymonclient.cfg
for this plugin and using the template directory to flush it to disk (probably in stead of /usr/local/etc/xymon/xymonclient.cfg
further below)
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.
@AdSchellevis like https://github.com/opnsense/plugins/pull/4260/files#r1835329433
I don't think this would be possible. The file /usr/local/www/xymon/client/etc/xymonclient.cfg
is statically coded from file /usr/local/www/xymon/client/etc/clientlaunch.cfg
# cat /usr/local/www/xymon/client/etc/clientlaunch.cfg
#
# The clientlaunch.cfg file is loaded by "xymonlaunch".
# It controls which of the Xymon client-side modules to run,
# (both the main client "xymonclient.sh" and any client-side
# extensions); how often, and with which parameters, options
# and environment variables.
#
# Note: On the Xymon *server* itself, this file is normally
# NOT used. Instead, both the client- and server-tasks
# are controlled by the tasks.cfg file.
#
# msgcache is used for passive clients, that cannot connect
# directly to the Xymon server. This is not the default
# setup, so this task is normally disabled.
[msgcache]
DISABLED
ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
CMD $XYMONCLIENTHOME/bin/msgcache --no-daemon --pidfile=$XYMONCLIENTLOGS/msgcache.pid
LOGFILE $XYMONCLIENTLOGS/msgcache.log
# The main client task
[client]
ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
CMD $XYMONCLIENTHOME/bin/xymonclient.sh
LOGFILE $XYMONCLIENTLOGS/xymonclient.log
INTERVAL 5m
Which is called by the /usr/local/etc/rc.d/xymon-client
from the non-overridable variable command_args="--config=/usr/local/www/xymon/client/etc/clientlaunch.cfg --log=/usr/local/www/xymon/client/logs/clientlaunch.log --pidfil e=${pidfile}"
Were you suggesting to completely overwrite the /usr/local/etc/rc.d/xymon-client
file from the package to pass our own arguments?
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 did some tests to override the /usr/local/etc/rc.d/xymon-client
and setting pidfile="/var/run/xymonclient.pid"
(as suggested here). This is preventing the service to start as /var/run/
is owned by root:wheel
and perms are 0755
and the service is started as user xymon
which don't have permission there.
EDIT: I circumvented this by patching the "forked" rc file and added the pid file creation and give it proper permission.
Next issue is giving execution bit to the /usr/local/etc/rc.d/xymon-client
now managed by the template 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.
Next issue is giving execution bit to the /usr/local/etc/rc.d/xymon-client now managed by the template system :(
Looks like I can't set it to executable
So I don't know how I can accomplish what you requested with this comment, neither how to change the pidfile 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.
File removed here in favor of ports update see PR opnsense/ports#206
@kumy did a very quick review and left some remarks/tips. |
@AdSchellevis thanks for the review. Except the 2 comments left open above, everything else has been adjusted. |
@kumy ok, maybe the better question is then if there's anything in |
The client does not publish any webservice. It collects status/metrics and send them to the Xymon Server(s).
So a dedicated/forked rc init script. @AdSchellevis Couldn't we do like Debian and just add one line to the Do you have any pointer/example to create a patch for https://github.com/opnsense/ports/tree/3c574e41e4e45df72cbb64c060a5637dd1d64f29/net-mgmt/xymon-client. We would need to patch a file coming from the Example from Debian:
|
Patching in ports should work similar to the change already in the Makefile (https://github.com/opnsense/ports/blob/3c574e41e4e45df72cbb64c060a5637dd1d64f29/net-mgmt/xymon-client/files/patch-Makefile). If I'm not mistaken (@fichtner usually handles these), you can drop a file there and build / install from the ports directory in the usuall way. |
sysutils/git-backup/src/opnsense/mvc/app/library/OPNsense/Backup/Git.php
Outdated
Show resolved
Hide resolved
net-mgmt/xymon-client/src/opnsense/service/conf/actions.d/actions_xymonclient.conf
Outdated
Show resolved
Hide resolved
@AdSchellevis / @fichtner This PR and opnsense/ports#206 should be ready for another review round 🙏 |
Closes #4259
Relates opnsense/tools#434