THold 2.1a: email subject?

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
imp
Posts: 5
Joined: Mon May 30, 2005 11:49 am
Contact:

THold 2.1a: email subject?

Post by imp »

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.
imp
Posts: 5
Joined: Mon May 30, 2005 11:49 am
Contact:

Post by imp »

Quick hack?

Above the:

Code: Select all

/* if there is supposed to be an event generated, do it */
line in functions.php add:

Code: Select all

$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: Select all

$msg = "Host[$host_id]: "
write something like:

Code: Select all

$msg = "ALERT $name: "
imp
Posts: 5
Joined: Mon May 30, 2005 11:49 am
Contact:

Post by imp »

(thanks to anuraganuj for the hint)
warnesj
Cacti User
Posts: 173
Joined: Sun May 29, 2005 7:34 pm

Post by warnesj »

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: Select all

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: Select all

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.
Lazybones
Posts: 40
Joined: Wed Aug 23, 2006 9:47 am

Post by Lazybones »

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.
User avatar
lard
Cacti User
Posts: 165
Joined: Wed Jul 20, 2005 10:48 am
Location: UK - Cambridge

Post by lard »

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
---- lard007skype ----
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

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...)
User avatar
lard
Cacti User
Posts: 165
Joined: Wed Jul 20, 2005 10:48 am
Location: UK - Cambridge

Post by lard »

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
---- lard007skype ----
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests