Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Update SQL when thresshold is activated

Update SQL when thresshold is activated

Scheduled Pinned Locked Moved Support
3 Posts 2 Posters 22.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    duanebutler
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • M
      M
      MarcusH
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • M
        M
        MarcusH
        wrote on last edited by
        #3

        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


        event policy.png

        event conf.png

        action.png

        threshold.png

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        Powered by NodeBB Contributors
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups