Icinga 2 Costum Module, Module Command Issue: Works in Console but Fails as a Service

Hi All

I am developing my own module in Icinga 2 for my needs and I have run into a problem (I took inspiration from the x509 module). My problem is that when I launch the command (as root) from the console it works, but when I try to run it as a service (i create a linux service that run that same command) it goes into error and does not recognize the same command. Can anyone help me and explain why it doesn’t work?

Kind Regards.

Well, tell us what the error message is?

Antony.

When serivce try to run log of serice is this

My command is icingacli mwp merjob run (right run when i run manually)

Mar 26 17:12:23 myhost.org systemd[1]: Started Icinga MWP Module Jobs Runner.
Mar 26 17:12:23 myhost.org icingacli[1662833]: ERROR: There is no such module or command: 'mwp'
Mar 26 17:12:23 myhost.org icingacli[1662833]: USAGE: icingacli [module] <command> [action] [options]
Mar 26 17:12:23 myhost.org icingacli[1662833]: Available commands:
Mar 26 17:12:23 myhost.org icingacli[1662833]:   help            Help for modules, commands and actions
Mar 26 17:12:23 myhost.org icingacli[1662833]:   module          List and handle modules
Mar 26 17:12:23 myhost.org icingacli[1662833]:   version         Shows version of Icinga Web 2, loaded modules and PHP
Mar 26 17:12:23 myhost.org icingacli[1662833]:   web
Mar 26 17:12:23 myhost.org icingacli[1662833]: Available modules:
Mar 26 17:12:23 myhost.org icingacli[1662833]:   setup
Mar 26 17:12:23 myhost.org icingacli[1662833]: Global options:
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --log [t]       Log to <t>, either stderr, file or syslog (default: stderr)
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --log-path <f>  Which file to log into in case of --log file
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --verbose       Be verbose
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --debug         Show debug output
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --help          Show help
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --benchmark     Show benchmark summary
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --watch [s]     Refresh output every <s> seconds (default: 5)
Mar 26 17:12:23 myhost.org icingacli[1662833]:   --version       Shows version of Icinga Web 2, loaded modules and PHP
Mar 26 17:12:23 myhost.org icingacli[1662833]: Show help on a specific command : icingacli help <command>
Mar 26 17:12:23 myhost.org icingacli[1662833]: Show help on a specific module  : icingacli help <module>
Mar 26 17:12:23 myhost.org systemd[1]: icinga-mwp.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Mar 26 17:12:23 myhost.org systemd[1]: icinga-mwp.service: Failed with result 'exit-code'.

can you upload the module on github?

some thoughts without knowing your code:

  • try to run the service as user www-data or whatever your webserver user is…
  • icingacli thinks the module is not there…

If i run sudo -u apache /usr/bin/icingacli mwp merjob run it work.

I cannot upload the project to GitHub because the rules of my company do not allow it

If you need some file i can upload a single file.

Kind Regards.

My problem is that when I launch the command (as root) from the console it works

If i run sudo -u apache /usr/bin/icingacli mwp merjob run it work.

If i run icingacli as normal user I get a different error which is totally ok:
ERROR: Cannot read enabled modules. Config directory "/etc/icingaweb2" is not readable

/etc/icingaweb2 should be readable for everyone

I need to run all my icingacli commands as root or www-data (ubuntu)

If your icingacli command works for root or apache use one of these users for your service, use www-data or leave blank to use root.