Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


THold 2.1a: email subject?

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Threshold)
Author Message
imp



Joined: 30 May 2005
Posts: 5

PostPosted: Tue Mar 21, 2006 7:03 am    Post subject: THold 2.1a: email subject? Reply with quote

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

PostPosted: Tue Mar 21, 2006 7:47 am    Post subject: Reply with quote

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

PostPosted: Tue Mar 21, 2006 7:49 am    Post subject: Reply with quote

(thanks to anuraganuj for the hint)
Back to top
warnesj
Cacti User


Joined: 29 May 2005
Posts: 163

PostPosted: Fri Mar 24, 2006 3:31 pm    Post subject: Reply with quote

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

PostPosted: Fri Feb 09, 2007 1:13 am    Post subject: Reply with quote

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

PostPosted: Wed Jun 20, 2007 6:55 am    Post subject: Reply with quote

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

PostPosted: Wed Jul 04, 2007 10:18 am    Post subject: Reply with quote

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

PostPosted: Thu Jul 05, 2007 4:42 am    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Threshold) All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group