Forum Discussion
Hi Tom,
You could create a script datasource to get the ulimit value, here is an example below. You would need to create a datapoint in the datasource using a key value pair *Key set to "Ulimit". You can set a threshold in the datapoint for alerting. You will need to set "ssh.user" and "ssh.pass" properties on the device.
The output from the script will look like this --> Ulimit:1024
-Jon
/* Ulimit script */
import com.santaba.agent.groovyapi.expect.Expect
def hostname = hostProps.get("system.hostname");
def username = hostProps.get("ssh.user");
def pass = hostProps.get("ssh.pass");
// default timeout for Expect SSH
def timeout = 15;
// Command to get load average data
def ulimit_cmd = "ulimit -n\n";
// Expected shell prompt character, may have to be changed
// Linux generally uses "#" for root shells
def prompt = '\\$'
/*
* Ulimit Pattern Key
*/
ulimit_pattern = ~/^(\d+)$/
// Connect to the device and wait for the prompt
ssh_conn = Expect.open(hostname, username, pass, timeout);
ssh_conn.expect(prompt);
// Send the ulimit command and wait for the prompt
ssh_conn.send(ulimit_cmd);
ssh_conn.expect(prompt);
// Iterate over output
ssh_conn.before().eachLine
{ line ->
//println line
// Run the match
matcher = ulimit_pattern.matcher(line);
// Did we match?
if (matcher.getCount() > 0)
{
// Yes, print data
println "ulimit:" + matcher[0][1];
}
}
// Exit the shell!
ssh_conn.send("exit\n");
ssh_conn.expectClose();
return 0;
Related Content
- 18 days ago
- 8 years ago
- 6 months ago
- 3 months ago
- 2 years ago