Using the LogicMonitor Account name in LogicModules that call the LM API
Quick tip...
EDIT: Now updated with an even quicker tip...
When (if!) you're creating a scripted LogicModule that calls the LogicMonitor API, you need the account name (<accountName>.logicmonitor.com), API token ID, andAPI token key.
You can set all these as resource properties of course, but it seems a bit annoying to have to tell resources in the LogicMonitor account their own account name, right?
So you might end up with a section of script like this:
def accessId = hostProps.get("lm.api.id");
def accessKey = hostProps.get("lm.api.key");
def account = hostProps.get("lm.api.account");
Here's the thing: Collectors run these scripts. Collectors know which account they belong to, it's in their agent.conf file. Collectors can read their own agent.conf file.
It's in a line like:
company=<accountName>
It's possible to pull out collector settings within scripts, therefore, this works:
import com.santaba.agent.util.Settings
// You'll need the above import...
// ...then:
account = Settings.getSetting("company")
// and then...
accessId = hostProps.get('lm.api.id');
accessKey = hostProps.get('lm.api.key');
Ta-dah! A property you no longer have to set...