Change alert emails subject.
Moderators: Developers, Moderators
Change alert emails subject.
Hello,
Is there any way to change the subject of the alert emails. I want to have the meaningful name of the thold template, not the data source there. For instance i have this now:
Hostname -PIN2 [pin2] restored to normal threshold with value 25.9494
I have set a meaningful name for this template to Temperature and i want to have this in the subject:
Hostname - Temperature restored to normal threshold with value 25.9494
Is this possible?
Is there any way to change the subject of the alert emails. I want to have the meaningful name of the thold template, not the data source there. For instance i have this now:
Hostname -PIN2 [pin2] restored to normal threshold with value 25.9494
I have set a meaningful name for this template to Temperature and i want to have this in the subject:
Hostname - Temperature restored to normal threshold with value 25.9494
Is this possible?
[size=92][i]"Ubuntu" - an African word, meaning "Slackware is too hard for me".[/i][/size]
Re: Change alert emails subject.
I've given up waiting for this to be added as a feature, so I simply edited thold_mail() in thold_functions.php
In my case, we would like threadable alerts per host, so I simply regex out the unique data, i.e. $subject =~ s/threshold.*$/threshold/;
HTH
Edit: took me 30 seconds to figure out I wasnt editing Perl...ended up with this instead of the above example
$subject = preg_replace('/threshold.*$/','threshold',$subject);
$subject = preg_replace('\[.*?\]/','',$subject);
Since I use <SUBJECT> in the message, I can safely trim out unwanted data in the thold_mail function
In my case, we would like threadable alerts per host, so I simply regex out the unique data, i.e. $subject =~ s/threshold.*$/threshold/;
HTH
Edit: took me 30 seconds to figure out I wasnt editing Perl...ended up with this instead of the above example
$subject = preg_replace('/threshold.*$/','threshold',$subject);
$subject = preg_replace('\[.*?\]/','',$subject);
Since I use <SUBJECT> in the message, I can safely trim out unwanted data in the thold_mail function
Re: Change alert emails subject.
I have and love thold 0.4.4-43...
I searched but didn't find anything that would work for me yet. I don't program or understand much code but am looking for a way to change the subject for normal threshold alerts (not down alerts):
Instead of:
[hostname] - [graph template]
something more like:
[graph_title]
Thanks in advance...
I searched but didn't find anything that would work for me yet. I don't program or understand much code but am looking for a way to change the subject for normal threshold alerts (not down alerts):
Instead of:
[hostname] - [graph template]
something more like:
[graph_title]
Thanks in advance...
-willieb
Re: Change alert emails subject.
As like this post, try to modify 'plugins/thold/thold_functions.php'.willieb wrote: Instead of:
[hostname] - [graph template]
something more like:
[graph_title]
(I'm using thold-0.4.4-41)
At line 561, 592, 631, 649, 694, 622:
And at line about 503:$subject = $desc . ($thold_show_datasource ? " [$name]" : '') . ...
to
$subject = $graph_title . ...
Of course this is a provisional way.. At your own risk.$hostname = ...
$graph_title = db_fetch_cell('SELECT title_cache FROM graph_templates_graph WHERE local_graph_id = ' . $item['graph_id']);
$rows = ...
Re: Change alert emails subject.
Once again, thanks noname. It worked perfectly!
Geez I may have to add you to my Christmas list this year lol...
Would it be just as easy to do the same thing for the threshold list itself? Currently my list of thresholds show something like:
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
etc...
Geez I may have to add you to my Christmas list this year lol...
Would it be just as easy to do the same thing for the threshold list itself? Currently my list of thresholds show something like:
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
etc...
-willieb
Re: Change alert emails subject.
Perhaps default threshold name when created newly can be modified like this..
In 'plugins/thold/thold.php':
In 'plugins/thold/thold.php':
For existing thresholds, you can modify its name by hand.'name' => array(
'friendly_name' => 'Threshold Name',
'method' => 'textbox',
'max_length' => 100,
'default' => db_fetch_cell('SELECT title_cache FROM graph_templates_graph WHERE local_graph_id = ' . $graph),
'description' => 'Provide the THold a meaningful name',
'value' => isset($thold_item_data['name']) ? $thold_item_data['name'] : ''
),
Re: Change alert emails subject.
Edit: After more experimentation, your code does work when I create the threshold without a template, but when I use the template I still getnoname wrote:Perhaps default threshold name when created newly can be modified like this..
In 'plugins/thold/thold.php':'name' => array(
'friendly_name' => 'Threshold Name',
'method' => 'textbox',
'max_length' => 100,
'default' => db_fetch_cell('SELECT title_cache FROM graph_templates_graph WHERE local_graph_id = ' . $graph),
'description' => 'Provide the THold a meaningful name',
'value' => isset($thold_item_data['name']) ? $thold_item_data['name'] : ''
),
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
...
for each threshold instead of the graph title.
-willieb
Re: Change alert emails subject.
Okay, then try to modify as follows..willieb wrote: Edit: After more experimentation, your code does work when I create the threshold without a template, but when I use the template I still get
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
Arris CMTS - USx Modems [Online] ...
...
for each threshold instead of the graph title.
In 'plugins/thold/setup.php':
andfunction thold_data_source_action_execute($action) {
...
if ($graph) {
...
# $insert['name'] = $desc . ' [' . $data_source_name . ']';
$insert['name'] = db_fetch_cell('SELECT title_cache FROM graph_templates_graph WHERE local_graph_id = ' . $graph);
...
I tested this on thold-0.4.4-41. Also 'setup.php' in thold-0.4.4-43 is not different from this version.function thold_graphs_action_execute($action) {
...
if ($graph) {
...
# $insert['name'] = $desc . ' [' . $data_source_name . ']';
$insert['name'] = db_fetch_cell('SELECT title_cache FROM graph_templates_graph WHERE local_graph_id = ' . $graph);
...
Re: Change alert emails subject.
P.S.
If you had this error "Threshold(s) Already Exist - No Thresholds Created" when using "Create Threshold from Template",
try commenting out the below line in the above functions.
(Since 0.4.4-??, that field won't exist in "thold_data" table)
If you had this error "Threshold(s) Already Exist - No Thresholds Created" when using "Create Threshold from Template",
try commenting out the below line in the above functions.
Code: Select all
$insert['bl_ref_time'] = $template['bl_ref_time'];
Re: Change alert emails subject.
You know, sometimes I think I need to study php lol...
Ok here's what I did. I kind of went in a different direction. I went back and created a few "traffic" related tholds and realized that it uses the data source name for the thold name, so I went back to the Arris template I was working with and changed the suggestive names in the query to the same as the graph title. When I re-created the graphs it worked great!
With all the problems I've had with 1 minute polling I decided to scrap it and start with a clean install with the default 5 minute polling.
After the fresh Cacti install, I reinstalled thold 0.4.4-43 and everything worked great except for the create thresholds from template, was indeed giving me "Threshold(s) Already Exist - No Thresholds Created"!!
So I just commented out the 2 lines as you suggested in setup.php and everything now works great!
Thanks again noname, I appreciate all your time and effort to help a fellow Cacti user...
Ok here's what I did. I kind of went in a different direction. I went back and created a few "traffic" related tholds and realized that it uses the data source name for the thold name, so I went back to the Arris template I was working with and changed the suggestive names in the query to the same as the graph title. When I re-created the graphs it worked great!
With all the problems I've had with 1 minute polling I decided to scrap it and start with a clean install with the default 5 minute polling.
After the fresh Cacti install, I reinstalled thold 0.4.4-43 and everything worked great except for the create thresholds from template, was indeed giving me "Threshold(s) Already Exist - No Thresholds Created"!!
So I just commented out the 2 lines as you suggested in setup.php and everything now works great!
Thanks again noname, I appreciate all your time and effort to help a fellow Cacti user...
-willieb
Who is online
Users browsing this forum: No registered users and 0 guests