Allow new Column on Database

Hi Guys,

is there a way to allow a new column on the DB so that LibreNMS can alert from it?

====================================
Component | Version
--------- | -------
LibreNMS  | 1.57-89-ge1ede81d2
DB Schema | 2019_08_10_223200_add_enabled_to_users (147)
PHP       | 7.2.24-0ubuntu0.18.04.1
MySQL     | 10.1.43-MariaDB-0ubuntu0.18.04.1
RRDTool   | 1.7.0
SNMP      | NET-SNMP 5.7.3
====================================

[OK]    Composer Version: 1.9.1
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[FAIL]  Database: extra column (syslog/message)
[FAIL]  We have detected that your database schema may be wrong, please report the following to us on Discord (https://t.libren.ms/discord) or the community site (https://t.libren.ms/5gscd):
        [FIX]:
        Run the following SQL statements to fix.
        SQL Statements:
         ALTER TABLE `syslog` DROP `message`;

Hi @ionline
What would you like to do that is not possible with current DB ?

@PipoCanaja I created a new column and then I’m running a php script which is pulling data and saving it into that column, then I want to create a rule and let my alert template show the data in that column

{{ $value[‘message’] }}

The question was : why do you create a new column if the data is already in an existing column ? we already log syslog messages in the syslog table, that’s the all point of it …

Now, touching the DB of LibreNMS is not possible. You can indeed create a new DB aside (on the same server) and store your stuff there. But it won’t be easily available from a template.

Last solution, extend LibreNMS and send a pull request so we add your change to LibreNMS.

Ill Give you a example.

syslog.msg
from xx.xx.xx.xx ([127.0.0.1])\r\n\tby localhost (xx.xxx.xx.xx [127.0.0.1]) (amavisd- [...] (10445-05) rw_loop sent 52600> X-Virus-Scanned: at xx.xxx.xx.xx\\r\\nReceived: from xx.xx.xx.xx ([127.0.0.1])\\r\\n\\tby localhost (xx.xxx.xxx.xxx [127.0.0.1]) (amavisd- [...]

my script then runs and pulls specific words eg.
from xx.xx.xx.xx

This is then copied into syslog.message

as I don’t want to see that entire msg “message”

If you only want to keep the short version, you should do that before the syslog arrives in LibreNMS using some kind of filtering.
this can be configured in rsyslogd or other syslog daemon that collects the syslogs and gives them to LibreNMS.
If you want the big version but reduce the display in the template, then do the filtering in the template directly (using regexp for instance).

1 Like

How will one go about this?

{{$value[‘message’]\bword1\W+(?:\w+\W+){1,6}?word2\b}}

basically, this is php code you need to put between the {{ and }}. So have a look at the functions https://www.php.net/manual/fr/function.preg-match.php and https://www.php.net/manual/fr/function.preg-replace.php.