Update SQL when thresshold is activated

Started by duanebutler, November 21, 2016, 12:28:18 PM

Previous topic - Next topic

duanebutler

Good day

I want to update a MSSQL database whenever a threshold is being hit.

Is this at all possible? If not. Can i update the MySQL database?

I want to insert a line into a table i created with specific values each time a threshold is reached. 

Regards

MarcusH

Hi,

I do it by threshold->event->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.

MarcusH

By request here is more in detail

Under event configuration i have setup events named Alarm for all the severity levels the message is what you see in the alarm browser.
Event policy is set to execute xmpp and action snd_alert on these events
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

snd_script:
body = "snd_alert";

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

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

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

return body;


In the agent configuration is:
ActionShellExec=snd_alert:/alert_sound/alert.sh $1 $2

Scenario:

On the DCI named SQL Deadlock there is a threshold that triggers if the polled value is greater then 3.
This triggers the Alarm Major severity
The policy on Alarm Major triggers the action snd_alert
The action snd_alert runs script snd_alert
The script has statement for SQL Deadlock and the return string will be "snd_alert sql_deadlock"
The first value is the action to run on the node agent "snd_alert" the second value is the first parameter
The agent will then run: "/alert_sound/alert.sh sql_deadlock"

For me this runs a wave file named sql_deadlock on the dashboard TV and inserts the event in a local db

You can add more parameters by adding $3 $4 etc on the action and returning more values via the script.

Helpful links

https://wiki.netxms.org/wiki/Main_Page
https://wiki.netxms.org/wiki/Scripting_Guide