Alarm Sound when Threshold reached

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
Sjoerd
Posts: 44
Joined: Wed May 28, 2008 5:20 am

Alarm Sound when Threshold reached

Post by Sjoerd »

Im using the monitor plugin, witch plays an alarm sound when a host goes down.
When there's a threshold reached, the host turns orrange.
Is there a posibility to play (another) alarm sound when a threshold is reached?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

wrong forum, moving.
Sjoerd
Posts: 44
Joined: Wed May 28, 2008 5:20 am

Re: Alarm Sound when Threshold reached

Post by Sjoerd »

Still looking for this functionality. Anyone?
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Alarm Sound when Threshold reached

Post by noname »

That's interesting a little. I tried to add code for Thold 0.4.1.

In function tholds() of 'plugins/thold/thold_graph.php',
before the line 267: '/* build the SQL query and WHERE clause */'...

Code: Select all

	/* embedding alarm */
	$alarm_sql = "SELECT * FROM thold_data
		LEFT JOIN user_auth_perms ON (
		(thold_data.graph_id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ") OR
		(thold_data.host_id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . ") OR
		(thold_data.graph_template=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION['sess_user_id'] . "))
		WHERE thold_alert!=0 AND (thold_fail_count >= thold_fail_trigger)";

	$alarm = sizeof(db_fetch_assoc($alarm_sql));
	if ($alarm) {
		$alarm_sound = $config['url_path'] . 'plugins/monitor/sounds/attn-noc.wav';

		print "<embed name='alarm' src='" . $alarm_sound . "' autostart='true' loop='true' volume='100' hidden='true'></embed>";
		print "<noembed><bgsound src='" . $alarm_sound . "'></noembed>";
		print "<table width='100%' border='0' cellspacing='0' cellpadding='5'><tr>";
		print "<td style='text-align:center; background-color:#" . $thold_bgcolors['red'] . ";'>";
		print "<a href='#' onClick='javascript:alarm.stop()'>";
		print "<strong>$alarm threshold(s) triggered!</strong>";
		print "</a></td></tr></table><br>";
	}
(Sorry, I borrowed sound file from monitor plugin :-) Please replace the file you like.)

At the result, when triggered,
thold_alarm_normal.png
thold_alarm_normal.png (19.88 KiB) Viewed 6858 times
will be changed like as (with alarm):
thold_alarm_triggered.png
thold_alarm_triggered.png (19.42 KiB) Viewed 6858 times
Click the alerting message to stop alarm.
(But this behavior depends browser. I tested with IE(6) on Windows. With Chrome, it can't be stopped, but played only 1 time.)

// Sorry my English..
TVTDatos
Posts: 3
Joined: Wed Feb 26, 2014 6:18 am

Re: Alarm Sound when Threshold reached

Post by TVTDatos »

Hey dude. Thank you very much. Your "hack" works perfect for me.
I know, this post is 3 years ago, but I really appreciate it and Im saying thanks.

He deserves it.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests