OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Profile of franciz »
  • Show Posts »
  • Topics
  • Profile Info
    • Summary
    • Show Stats
    • Show Posts...
      • Messages
      • Topics
      • Attachments

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

  • Messages
  • Topics
  • Attachments

Topics - franciz

Pages: [1]
1
24.7 Production Series / NUT problem
« on: August 23, 2024, 04:40:28 pm »
Hi everyone,
I installed the NUT package and everything is working fine on the command line (OPNsense v24.7.2).
Running "./bcmxcp_usb -a PW9120 -DDDDD" will return all the info from the UPS.
But on the web manager I get problems.

Diagnostics will not return anything, only showing a blank square.
On configuration when I try to start the service it will later show this message on the console:
Quote
Broadcast Message from root@OPNsense.localdomain
        (no tty) at 14:37 UTC...

UPS PW9120 is unavailable

This is my /api/nut/settings/get
Quote
{"nut":{"general":{"enable":"1","mode":{"standalone":{"value":"standalone","selected":1},"netclient":{"value":"netclient","selected":0}},"name":"PW9120","listen":{"127.0.0.1":{"value":"127.0.0.1","selected":1},"::1":{"value":"::1","selected":1}}},"account":{"admin_password":"Password","mon_password":"Password"},"usbhid":{"enable":"0","args":{"port=auto":{"value":"port=auto","selected":1}}},"apcsmart":{"enable":"0","args":{"port=auto":{"value":"port=auto","selected":1}}},"apcupsd":{"enable":"0","hostname":"localhost","port":""},"bcmxcpusb":{"enable":"1","args":{"port=auto":{"value":"port=auto","selected":1}}},"blazerusb":{"enable":"0","args":{"port=auto":{"value":"port=auto","selected":1}}},"blazerser":{"enable":"0","args":{"port=auto":{"value":"port=auto","selected":1}}},"netclient":{"enable":"0","address":"","port":"3493","user":"","password":""},"qx":{"enable":"0","args":{"port=auto":{"value":"port=auto","selected":1}}},"riello":{"enable":"0","args":{"port=auto":{"value":"port=auto","selected":1}}},"snmp":{"enable":"0","args":{"community=public":{"value":"community=public","selected":1}}}}}

What could be wrong?
Thanks!!

2
24.7 Production Series / SMART widget (needs corrections?)
« on: August 20, 2024, 05:33:13 pm »
EDIT: Corrected by AI

Code: [Select]
export default class Smart extends BaseTableWidget {
    constructor() {
        super();
        this.tickTimeout = 300;
        this.disks = null;
    }

    getMarkup() {
        const $container = $('<div></div>');
        const $smarttable = this.createTable('smart-table', {
            headerPosition: 'left',
        });
        $container.append($smarttable);
        return $container;
    }

    async onWidgetTick() {
        if (this.disks && this.disks.devices) {
            for (const device of this.disks.devices) {
                try {
                    const data = await ajaxCall("/api/smart/service/info", { type: "H", device });
                    const health = data.output.includes("PASSED");
                    $(`#${device}`).css({ color: health ? "green" : "red", fontSize: '150%' });
                    $(`#${device}`).text(health ? "OK" : "FAILED");
                } catch (error) {
                    super.updateTable('smart-table', [[["Error"], $(`<span>${this.translations.nosmart} ${device}: ${error}</span>`).prop('outerHTML')]]);
                }
            }
        }
    }

async onMarkupRendered() {
        try {
            this.disks = await ajaxCall("/api/smart/service/list", {});
            const rows = [];
            for (const device of this.disks.devices) {
                const field = $(`<span id="${device}">`).prop('outerHTML');
                rows.push([[device], field]);
            }
            super.updateTable('smart-table', rows);
        } catch (error) {
            super.updateTable('smart-table', [[["Error"], $(`<span>${this.translations.nodisk}: ${error}</span>`).prop('outerHTML')]]);
        }
    }
}

Code: [Select]
<metadata>
    <smart>
        <filename>Smart.js</filename>
        <endpoints>
            <endpoint>/api/smart/service/list</endpoint>
            <endpoint>/api/smart/service/info</endpoint>
        </endpoints>
        <translations>
            <title>SMART Status</title>
            <nodisk>Error fetching disk list</nodisk>
            <nosmart>Error fetching SMART info for device</nosmart>
        </translations>
    </smart>
</metadata>

PS: Some stuff that should be fixed in the documentation.
1) To import the base js I had to use its relative path.
2) tickTimeout is in seconds and not ms

3
Tutorials and FAQs / Convert PFsense DHCP static addresses via regex
« on: March 20, 2023, 05:03:43 pm »
1) Save PFsense config file
2) Go to https://regex101.com/
3) Select flavor "PCRE2" and function "List"
4) In "Test string" paste the contents of the backup file.
5) In "Regular Expression" paste the following:
Code: [Select]
<staticmap>\n\t+<mac>(.+)<\/mac>\n\t+(?:.*)\n\t+<ipaddr>(.+)<\/ipaddr>\n\t+<hostname>(.+)<\/hostname>\n\t+<descr><!\[CDATA\[(.+)\]\]><\/descr>6) In "Function" paste the following:
Code: [Select]
\t\t\t<staticmap>\n\t\t\t\t<mac>$1</mac>\n\t\t\t\t<ipaddr>$2</ipaddr>\n\t\t\t\t<hostname>$3</hostname>\n\t\t\t\t<descr>$4</descr>\n\t\t\t</staticmap>\n7) You will get the converted file below. You have to add the xml header and footer to this results:
Code: [Select]
<?xml version="1.0"?>
<opnsense>
<dhcpd>
    <lan>
********** The converted result*************
    </lan>
  </dhcpd>
</opnsense>

I hope this helps someone. I tried with uprt and got all the results mangled...

Pages: [1]
OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2