OPNsense Forum

English Forums => 25.1, 25.4 Production Series => Topic started by: r.vandijk on April 17, 2025, 09:12:19 AM

Title: OPNCentral host > status > Resources not working for 1 machine
Post by: r.vandijk on April 17, 2025, 09:12:19 AM
Hi,

I have 1 managed machine that can't display the metrics on the Status > Resources tab of OPNCentral.
The backend log on the affected machine creates the following log:
Script action failed with Command '/usr/local/opnsense/scripts/OPNcentral/collect_metrics ''' returned non-zero exit status 1. at Traceback (most recent call last): File "/usr/local/opnsense/service/modules/actions/script_output.py", line 78, in execute subprocess.check_call(script_command, env=self.config_environment, shell=True, File "/usr/local/lib/python3.11/subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '/usr/local/opnsense/scripts/OPNcentral/collect_metrics ''' returned non-zero exit status 1.

When manually running the /usr/local/opnsense/scripts/OPNcentral/collect_metrics script on the affected machine gives the following output:
Traceback (most recent call last):
  File "/usr/local/opnsense/scripts/OPNcentral/collect_metrics", line 24, in <module>
    print(ujson.dumps(metric_collector(2)))
                      ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/opnsense/scripts/OPNcentral/metrics/__init__.py", line 70, in metric_collector
    getattr(collector, action)()
  File "/usr/local/opnsense/scripts/OPNcentral/metrics/firewall.py", line 68, in pre
    self.pftop('pre')
  File "/usr/local/opnsense/scripts/OPNcentral/metrics/firewall.py", line 52, in pftop
    port = min([int(x.split('[')[-1].split(':')[-1].replace(']', '')) for x in addrs])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/opnsense/scripts/OPNcentral/metrics/firewall.py", line 52, in <listcomp>
    port = min([int(x.split('[')[-1].split(':')[-1].replace(']', '')) for x in addrs])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '4161)'


It seems that it returns a ")" somewhere, but I can't figure out what's wrong.
Running the script multiple times gives a different number but always with the ")" at the end.

I have taken the following steps in trying to solve the issue:
1. Run the Health, Security and Upgrade audits -> No issues found and not fixed
2. Rebooting the firewall -> For some reason the metrics were shown for a short while, but after a couple of minutes it stopped working again


Can someone help me troubleshooting this issue further?

Thanks in advance!
Title: Re: OPNCentral host > status > Resources not working for 1 machine
Post by: franco on April 17, 2025, 09:39:57 AM
Looking into it now, thanks!
Title: Re: OPNCentral host > status > Resources not working for 1 machine
Post by: r.vandijk on April 17, 2025, 09:51:20 AM
Hi Franco,

Thank you very much!
If you need anything, let me know.
Title: Re: OPNCentral host > status > Resources not working for 1 machine
Post by: franco on April 17, 2025, 01:44:07 PM
Can you install the latest os-OPNBEcore update that's now available and confirm it's solved?


Cheers,
Franco
Title: Re: OPNCentral host > status > Resources not working for 1 machine
Post by: r.vandijk on April 17, 2025, 03:57:11 PM
Hi Franco,

I just updated and so far it seems to be working!
Thanks a lot, I appreciate it!
Title: Re: OPNCentral host > status > Resources not working for 1 machine
Post by: franco on April 17, 2025, 04:08:56 PM
Nice to hear, thanks :)