Forum Discussion
9 years ago
A way to solve this might be creating a datasource which runs every x minutes, depending on your needs. This datasource executes a perl script somehow similar to the one below. The example script we use to get the number of open alerts, and trigger an alert if the number reaches a specific threshold. It will need some modification...
The script executes an rpc call to LM getting the results on which you want to trigger the execution. If the monitored value is above the threshold some action is taken. Based on the output of the script you could even set an alert on the fact that the script is executed. It's not directly bound to a datasource, but could work.
#!/usr/bin/env perl # Replace parameters below to suit your situation $userName="myUsername"; $password="mySecret"; $sitename="mySite"; $siteurl="mySite.logicmonitor.com"; $groupId="1"; $curlopt="'https://$siteurl/santaba/rpc/getAlerts?c=$sitename&u=$userName&p=$password&hostGroupId=$groupId'"; $curlrun="env curl -s $curlopt"; # Now we have the command to run $alertwarn=0; $alerterr=0; $alertcrit=0; open(FILE, "-|", $curlrun) or die $!; while (<FILE>) { $alertwarn++ if /warn/; $alerterr++ if /error/; $alertcrit++ if /critical/; } close $handle; $alerttotal=$alertwarn+$alerterr+$alertcrit; if ($alerttotal > 30) { # execute any required action # execution more action $scriptresult=1; } else { $scriptresult=0; } print "ScriptResult" . $scriptresult . "\n";
Related Content
- 3 years ago
- 5 years ago
- 2 years agoAnonymous