|
|
| Author |
Message |
imp
Joined: 30 May 2005 Posts: 5
|
Posted: Tue Mar 21, 2006 7:03 am Post subject: THold 2.1a: email subject? |
|
|
Hello,
I would like to change the subject of the email alerts. I modified check-thold.php, but it seems that that subject is not the one being used. I want subject to reflect the "description" column in "host" table instead of the hostname/IP.
Can someone give me some pointers?
Thanks. |
|
| Back to top |
|
 |
imp
Joined: 30 May 2005 Posts: 5
|
Posted: Tue Mar 21, 2006 7:47 am Post subject: |
|
|
Quick hack?
Above the:
| Code: | | /* if there is supposed to be an event generated, do it */ |
line in functions.php add:
| Code: | $sql = "SELECT hostname,description from host where id=$host_id";
$result = mysql_query($sql);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$name = $row['description'];
$ip = $row['hostname']; |
and below it, instead of:
| Code: | | $msg = "Host[$host_id]: " |
write something like:
| Code: | | $msg = "ALERT $name: " |
|
|
| Back to top |
|
 |
imp
Joined: 30 May 2005 Posts: 5
|
Posted: Tue Mar 21, 2006 7:49 am Post subject: |
|
|
| (thanks to anuraganuj for the hint) |
|
| Back to top |
|
 |
warnesj Cacti User
Joined: 29 May 2005 Posts: 163
|
Posted: Fri Mar 24, 2006 3:31 pm Post subject: |
|
|
If you're refering to the alerts you get when a host is down I had to modify the plugins/thold/setup.php file,
Find,
| Code: | if ($status != HOST_DOWN) {
$subject = "Host Notice : " . $hosts[$host_id]["hostname"] . " returned from DOWN state";
$msg= $subject;
thold_mail(read_config_option("alert_email"), '', $subject, $msg, '');
} else {
$subject = "Host Error : " . $hosts[$host_id]["hostname"] . " is DOWN";
$msg ="Host Error : " . $hosts[$host_id]["hostname"] . " is DOWN<br>Message : " . $hosts[$host_id]["status_last_error"];
thold_mail(read_config_option("alert_email"), '', $subject, $msg, '');
} | And change it to,
| Code: | if ($status != HOST_DOWN) {
$subject = "Host Notice : " . $hosts[$host_id]["description"] . "(" . $hosts[$host_id]["hostname"] . ") returned from DOWN state";
$msg= $subject;
thold_mail(read_config_option("alert_email"), '', $subject, $msg, '');
} else {
$subject = "Host Error : " . $hosts[$host_id]["description"] . "(" . $hosts[$host_id]["hostname"] . ") is DOWN";
$msg ="Host Error : " . $hosts[$host_id]["hostname"] . " is DOWN<br>Message : " . $hosts[$host_id]["status_last_error"];
thold_mail(read_config_option("alert_email"), '', $subject, $msg, '');
} |
This will change the subject of your alerts messages from "Host Error: [host ip address] is DOWN" to "Host Error: [host description] ([host ip address]) is DOWN". It will also change "Host Notice: [host ip address] returned from DOWN state" to "Host Notice: [host description] ([host ip address]) returned from DOWN state".
I hope this helps. |
|
| Back to top |
|
 |
Lazybones
Joined: 23 Aug 2006 Posts: 17
|
Posted: Fri Feb 09, 2007 1:13 am Post subject: |
|
|
It would be nice if this change was included in future versions... Although it is easy enough to do.
When you have a good number of systems being monitored and some of them are using an IP instead of a hostname it gets hard to figure out what is down just by the email. |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Wed Jun 20, 2007 6:55 am Post subject: |
|
|
Just to say thanks for the pointers - just changed one of ours after sifting through the code (I'm no coder! ) and this has helped me out no end!
Thanks,
Larry |
|
| Back to top |
|
 |
cigamit Developer
Joined: 07 Apr 2005 Posts: 978 Location: B/CS Texas
|
Posted: Wed Jul 04, 2007 10:18 am Post subject: |
|
|
| Actually, the SVN version has done this for a while now. Also, the alert email itself is completely customizable. In Settings, you fill out exactly how the email show look like and just include some simple code words to output the appropriate data where you want it (or the URL, graph image, etc...) |
|
| Back to top |
|
 |
lard Cacti User
Joined: 20 Jul 2005 Posts: 157 Location: UK - Cambridge
|
Posted: Thu Jul 05, 2007 4:42 am Post subject: |
|
|
that's a great new feature - I'll grab a copy and take a look through it, will certainly be nice to add links to our helpdesk e.t.c into the mail,
Many thanks!
Larry |
|
| Back to top |
|
 |
|