GatewaySQL Example - Specific Value and Dynamic Rows comparison to alert if value not the same on either row
Example and Requirements:
-
The static data (192.XXX.0.78) should be monitored even when the row has changed.
-
The static data (192.XXX.0.78) should be present on either row of the value column. This gives us an ok severity if present and critical if not.
Here we have used this data as an example:
For us to segregate these values, we have configured the Gateway-SQL to obtain the data coming from both columns:
Following this example should give you something like this. This way, the data should still be detected even if it’s present on different rows.
Now, we will have a rule that should compare these two values, when the data is not present in the second column, it should trigger a critical severity:
As an example, here we have removed the highlighted IP on the 2nd column:
This should then trigger a critical severity given that the data is not available on the 2nd column:
To also check to see if this can be detected even with a different row:
Gateway SQL Sampler
<sampler name="testinggatewaysql">
<sampleInterval>
<data>20</data>
</sampleInterval>
<plugin>
<Gateway-sql>
<tables>
<dataview>
<tableName>
<data>timetoolkit</data>
</tableName>
<xpath>/geneos/gateway[(@name="Primary Gateway")]/directory/probe[(@name="1_probe")]/managedEntity[(@name="TESTS")]/sampler[(@name="toolkit-time")][(@type="")]/dataview</xpath>
<columns>
<column>
<name>
<data>time</data>
</name>
<type>TEXT</type>
</column>
<column>
<name>
<data>name</data>
</name>
<type>INTEGER</type>
</column>
<column>
<name>
<data>Value</data>
</name>
<type>INTEGER</type>
</column>
</columns>
</dataview>
</tables>
<views>
<view>
<name>
<data>toolkit</data>
</name>
<sql>
<data>SELECT time,name FROM timetoolkit WHERE name = '192.XXX.0.78';</data>
</sql>
</view>
<view>
<name>
<data>value</data>
</name>
<sql>
<data>SELECT time,Value FROM timetoolkit WHERE Value = '192.XXX.0.78';</data>
</sql>
</view>
</views>
</Gateway-sql>
</plugin>
</sampler>
Rule XML
<rule name="New Rule 1">
<targets>
<target>/geneos/gateway[(@name="Primary Gateway")]/directory/probe[(@name="1_probe")]/managedEntity[(@name="Main")]/sampler[(@name="testinggatewaysql")][(@type="")]/dataview[(@name="toolkit")]/rows/row/cell[(@column="name")]</target>
</targets>
<priority>1</priority>
<pathAliases>
<pathAlias name="outboundcolumn">/geneos/gateway[(@name="Primary Gateway")]/directory/probe[(@name="1_probe")]/managedEntity[(@name="Main")]/sampler[(@name="testinggatewaysql")][(@type="")]/dataview[(@name="value")]/rows/row/cell[(@column="Value")]</pathAlias>
</pathAliases>
<block>
<set>
<var ref="outbound"></var>
<dataItem>
<pathAlias ref="outboundcolumn"></pathAlias>
<property>@value</property>
</dataItem>
</set>
<if>
<equal>
<dataItem>
<property>@value</property>
</dataItem>
<var ref="outbound"></var>
</equal>
<transaction>
<update>
<property>state/@severity</property>
<severity>ok</severity>
</update>
</transaction>
<transaction>
<update>
<property>state/@severity</property>
<severity>critical</severity>
</update>
</transaction>
</if>
</block>
</rule>
Toolkit Sampler
<sampler name="toolkit-time">
<plugin>
<toolkit>
<samplerScript>
<data>/home/MNL/lbasinal/geneos/gateway/test_sql/toolkit_time.bash</data>
</samplerScript>
</toolkit>
</plugin>
<dataviews>
<dataview name="test">
<additions>
<var-headlines>
<data>
<headline>
<data>rowCount1</data>
</headline>
</data>
</var-headlines>
</additions>
</dataview>
</dataviews>
</sampler>
Bashscript for Toolkit
#!/bin/bash
echo time,name,Value
echo 00:01:00,192.111.0.71,192.111.0.70
echo 00:06:00,192.111.0.70,192.111.0.71
echo 00:02:00,192.111.0.73,192.111.0.73
echo 00:04:00,192.111.0.74,192.111.0.74
echo 00:05:55,192.111.0.78,192.111.0.77
echo 00:05:26,192.111.0.72,192.111.0.72