<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Update SQL when thresshold is activated]]></title><description><![CDATA[<p dir="auto">Good day</p>
<p dir="auto">I want to update a MSSQL database whenever a threshold is being hit.</p>
<p dir="auto">Is this at all possible? If not. Can i update the MySQL database?</p>
<p dir="auto">I want to insert a line into a table i created with specific values each time a threshold is reached. </p>
<p dir="auto">Regards</p>
]]></description><link>https://forum.netxms.org/topic/4807/update-sql-when-thresshold-is-activated</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 15:40:27 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4807.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Nov 2016 10:28:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Update SQL when thresshold is activated on Wed, 23 Nov 2016 08:10:07 GMT]]></title><description><![CDATA[<p dir="auto">By request here is more in detail</p>
<p dir="auto">Under event configuration i have setup events named Alarm for all the severity levels the message is what you see in the alarm browser.<br />
Event policy is set to execute xmpp and action snd_alert on these events<br />
The action then runs command on the node via the agent and what the action sends to the node agent is returned by the script snd_alert</p>
<p dir="auto">snd_script:</p>
<pre><code>body = "snd_alert";

if ($event-&gt;parameters[2] == "SQLServer:General Statistics: Processes blocked")
{
	body .= " sql_locked";
	if ((localtime()-&gt;hour == 13) &amp;&amp; (localtime()-&gt;min &lt; 15))
	{
		body .= " delivery_journal";
	}
}

if ($event-&gt;parameters[2] == "SQL Deadlock")
{
	body .= " sql_deadlock";
}

if ($event-&gt;parameters[2] == "MD5 hash check for unchanged file")
{
	body .= " breadcrumb_files";
}

return body;
</code></pre>
<p dir="auto">In the agent configuration is:<br />
ActionShellExec=snd_alert:/alert_sound/alert.sh $1 $2</p>
<p dir="auto">Scenario:</p>
<p dir="auto">On the DCI named SQL Deadlock there is a threshold that triggers if the polled value is greater then 3.<br />
This triggers the Alarm Major severity<br />
The policy on Alarm Major triggers the action snd_alert<br />
The action snd_alert runs script snd_alert<br />
The script has statement for SQL Deadlock and the return string will be "snd_alert sql_deadlock"<br />
The first value is the action to run on the node agent "snd_alert" the second value is the first parameter<br />
The agent will then run: "/alert_sound/alert.sh sql_deadlock"</p>
<p dir="auto">For me this runs a wave file named sql_deadlock on the dashboard TV and inserts the event in a local db</p>
<p dir="auto">You can add more parameters by adding $3 $4 etc on the action and returning more values via the script.</p>
<p dir="auto">Helpful links</p>
<p dir="auto"><a href="https://wiki.netxms.org/wiki/Main_Page" rel="nofollow ugc">https://wiki.netxms.org/wiki/Main_Page</a><br />
<a href="https://wiki.netxms.org/wiki/Scripting_Guide" rel="nofollow ugc">https://wiki.netxms.org/wiki/Scripting_Guide</a></p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000003351-event_policy.png" alt="event policy.png" class="img-markdown  img-fluid" width="1588" height="343" /></p>
<p dir="auto"><img src="/assets/uploads/files/smf/0000000003353-event_conf.png" alt="event conf.png" class="img-markdown  img-fluid" width="822" height="94" /></p>
<p dir="auto"><img src="/assets/uploads/files/smf/0000000003355-action.png" alt="action.png" class="img-markdown  img-fluid" width="326" height="452" /></p>
<p dir="auto"><img src="/assets/uploads/files/smf/0000000003357-threshold.png" alt="threshold.png" class="img-markdown  img-fluid" width="577" height="413" /></p>
]]></description><link>https://forum.netxms.org/post/21406</link><guid isPermaLink="true">https://forum.netxms.org/post/21406</guid><dc:creator><![CDATA[MarcusH]]></dc:creator><pubDate>Wed, 23 Nov 2016 08:10:07 GMT</pubDate></item><item><title><![CDATA[Reply to Update SQL when thresshold is activated on Tue, 22 Nov 2016 07:05:58 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I do it by threshold-&gt;event-&gt;action and under action run execute command on remote node via agent then on the sql node i have setup that action to run a file that updates sql with data provided from parameters.</p>
]]></description><link>https://forum.netxms.org/post/21396</link><guid isPermaLink="true">https://forum.netxms.org/post/21396</guid><dc:creator><![CDATA[MarcusH]]></dc:creator><pubDate>Tue, 22 Nov 2016 07:05:58 GMT</pubDate></item></channel></rss>