Port Utilization Alerts

Hello,

I’m trying to setup a port utilization over threshold alert on Libre. I’ve created the macro using (%macros.port_up = “1” && %macros.port = “1” && (%macros.port_out_usage_perc > “80” || %macros.port_in_usage_perc > “80”)) parameters. Problem is even thoug Libre itself sees the traffic being over the threshold, alert does not trigger. Any ideas why?

Also, when i create a template, i want to see which way(recieve or transmit) gets over the threshold. Which value should i use for this?

This might be a bug. Please paste this into mysql:

UPDATE `config` SET `config_value`='((%ports.ifInOctets_rate*8) / %ports.ifSpeed)*100', `config_default`='((%ports.ifInOctets_rate*8) / %ports.ifSpeed)*100' WHERE `config_name`='alert.macros.rule.port_in_usage_perc';
UPDATE `config` SET `config_value`='((%ports.ifOutOctets_rate*8) / %ports.ifSpeed)*100', `config_default`='((%ports.ifOutOctets_rate*8) / %ports.ifSpeed)*100' WHERE `config_name`='alert.macros.rule.port_out_usage_perc';

However your rule won’t work anyway, don’t use ||, separate the rules into two. That will then also solve your template issue as you can set a name to each one.

Then edit the rules and just hit save.

I know about the ||, i did macro the rule, that was just to give an idea. Separating the rule is a good idea, i’ll try that. If that doesn’t work then i’ll update the config.

Have you run the mysql queries I gave you above?

I haven’t. I seperated the rule, let it stay for the night. It still didn’t trigger any alert. I’ll update the db as next step,will let you know how it went.

Without you running those commands, the macros you are using will never work :slight_smile:

Why is that :slight_smile:

I’m not allowed the mess with the database, unfortunately :slight_smile: will this work as a rule?
%macros.port_up = “1” && %macros.port = “1” && %macros.port_utilization > “80”

%macros.port_utilization isn’t a macro unless you created it?

The fix will be merged shortly so if your install updates automatically then within a day it will be ok.

Yeah, it’s my macro :slight_smile: i confused it with %macros.port_usage_perc > “80”, which comes with default install. I confused the 2.

My install can update automatically, so it’ll be okay hopefully.

The fix has been merged, if your install auto-updates then you should have it within 24 hours.

Hey Laf, i’ve been testing this for almost a week now and it seems to work. Big thanks for your help.

I have an additional question tho: How would i see in the mail whether or not utilization in ingress or egress?

The macro i’ve created has 2 checks about utilization %macros.port_out_usage_perc > “80” and %macros.port_in_usage_perc > "80. Template is stating something like;

{if %faults}Faults:

{foreach %faults}
#%key:

Port: %value.ifName

Port Name: %value.ifAlias

{/foreach}

{/if}

What should i add here to see whether the the port receiving this traffic or transmitting this traffic?

Because you’ve combined them into one then this is difficult. It’s much easier to just split them out and use separate titles / names of rules.

I’ve guessed this would be the case. How about actual utilization in MBits? How would i include that?

You would need to do a calculation to work that out, I’ve never tried using our functions in the template but you could try:

formatRates(%value.ifInOctets_rate * 8)

This needs to be in the foreach loop for values - look at the example in the docs.

Unfortunately, formatRates doesn’t work for me. i need to do the calculation on the template it looks like, HTML doesn’t do any arithmetics AFAIK. Any idea?

I’ve dig through functions.inc.php and found a function called humanspeed that uses formatrates. It also didn’t work. I’m using HTML templates btw,

You’ll need to do the manual calculations then.

How and where? I can calculate using the ifInOctet_Rate value, however HTML doesn’t allow me to calculate in the template. Where would i do this calculation and how would i add it into the template?