Help customizing alert templates

I am trying to setup an alert template that will color code the Severity and add a graph to the email. I am sending the email as html and its working well except I cant seem to get the syntax for the color codeing or adding the graph. I used the example from florianbeer at the link below

For the severity I think I’m just missing what the state should be, I cant seem to find any number that works and if I enter ‘critical’ or ‘warning’ it doesn’t work at all.

For the graph I’m just getting a place holder for a picture no actual graph, like its not finding the image so I’m not sure the path is correct. I also did enter $config[‘allow_unauth_graphs’] = 1; into my config.php.

on a side note I did read in one of the posts about using an api to get the graph instead of using $config[‘allow_unauth_graphs’] = 1;. I just couldn’t find any info on how to do that.
This is currently what I have:

Sorry about the length but thanks in advance for the help.

Sorry about the image file I couldn’t figure out how to get the html code to show.

Is there anyone that can help me out with this?

Did you ever get this worked out? I am working on a similar toner page and there is some issue in the HTML that causes the entire alert to fail. I had problems with my graph in the e-mail until I went back to the config.php and corrected the single quotes… I had pasted them in and they were ` rather than ’ which happens a lot if you are pasting things in. (for the $config[‘allow_unauth_graphs’] = 1;)

I was able to get an Alert Template for Low Printer Toner working - this will show a graph of the last 30 days of toner level.

<div style="font-family:Helvetica;">
{if %state == 1}<span style="color:DarkOrchid;">%severity{/if}
{if %state == 2}<span style="color:goldenrod;">Low Toner Acknowledged{/if}
{if %state == 3}<span style="color:DarkKhaki;">Low Toner Recovering{/if}
{if %state == 0}<span style="color:green;">Toner Replaced{/if}
{if %faults}
{foreach %faults}
<b>Device:</b> {if %transport == mail} 
<a href="http://librenms/device/device=%hostname/">%hostname</a>
{/if} <br>
<b>Toner:</b> %value.toner_descr<br>
<b>Toner Level:</b> %value.toner_current<br>
{if %location}
<b>Location:</b> %location<br>
<b>Location:</b> LOCATION NOT DEFINED YET!!<br>
<b>Uptime:</b> %uptime_long<br>
<b>Duration:</b> %elapsed<br>
{if %description}
<b>Description:</b> %description<br>
{if %Features}
<b>Features:</b> %features<br>
{if %Purpose}
<b>Purpose:</b> %purpose<br>
{if %Notes}
<b>Notes:</b> %notes<br>
<b>Device: </b>%value.sysDescr<br><br>
<img src="http://librenms/graph.php?width=459&height=213&lazy_w=552&from=end-30d&device=%value.device_id&type=device_toner&legend=yes"><br><br>
<B>Alerts sent to:</b> {foreach %contacts}%value <%key> {/foreach} <br>

Sorry I did eventually get this to work here is my Printer Notification Template. It has a table to show which toner color is low and a percentage. I also add the toner type to the printer template so it adds that. The severity will change color based off Warning or Critical, and the table also has some color and it includes the graph for each alerted toner.


%notes <br>

Severity:<b>{if %severity == warning}<font color=orange>%severity</font>{else}<font color=red>%severity</font>{/if}<br></b>

{if %state == 0}
Time elapsed: %elapsed </b><br>
{/if}Timestamp: %timestamp <br>

Unique-ID: %uid <br>

Rule: {if %name}%name{else}%rule{/if} <br>

{if %faults}Faults:

Alert sent to: {foreach %contacts}%value <key> {/foreach} <br>

<table border="1" width="60%">
        <col style="width:40%">
	<col style="width:10%">
	<col style="width:10%">
		<th>Printer Name</th>
		<th><font color=orange>Toner</th>
		<th><font color=red>Toner Available</th>
        {foreach %faults} 
		<td align="center">%value.sysName</td>
		<td align="center"><font color=orange>%value.toner_descr</td>
		<td align="center"><font color=red>%value.toner_current%</td>

<br> {if %transport == mail}<a href="http://**_ServerName_**/device/device=%hostname/">%hostname</a>{else}%hostname{/if} </br>

{if %faults}
{foreach %faults}<br><br>
<img src="http://**_ServerName_**/graph.php?id=%value.toner_id&type=toner_usage&height=213&width=459&lazy_w=552&from=end-1w&device&legend=yes"><br><br>
1 Like