
By default the Hyperic agent will autodiscover sendmail and NTP server resources. So quite a few of Hyperic’s platforms will likely be monitoring these resources in your installation. In quite a few cases you don’t care about monitoring these resources and rather increase Hyperic performance by removing them. Also, they will likely fill up the auto-discovery screen and become a nuisance.
1. You can add a line to the agent.properties file to have the Hyperic agent NOT autodiscover these services:
pugins.exclude=sendmail,ntp
2. To remove the “servers” from existing “platforms” you can use the below script. It makes use of the hqapi.sh cli tool (available for download from Hyperic). Just change the “server_to_remove” variable appropriately.
Caution, this script was written in 2.3 seconds and I’m quite sure the xml tree parsing is suboptimal.
#!/usr/bin/python3.2
import os
import sys
import subprocess as SP
import xml.etree.ElementTree as ET
def run_cmd(cmd, wd=os.getcwd()):
""" Executes a unix command and verifies exit status. Takes command to be
executed and directory from which to execute. """
try:
child = SP.Popen(cmd.split(), stdout=SP.PIPE, stderr=SP.PIPE, cwd=wd)
stdout, stderr = [ str(out, 'UTF-8', 'ignore') for out in child.communicate()[:2] ]
rc = child.returncode
except OSError as e:
print('Critical: Error running {}, {}'.format(cmd, e), file=sys.stderr)
sys.exit(2)
if rc:
print('Error running command: {}'.format(cmd), file=sys.stderr)
print(stderr, file=sys.stderr)
sys.exit(2)
return(stdout.rstrip())
def main():
server_to_remove = "NTP 4.x"
api_path = '/bin/hqapi.sh'
all_resources = '{} resource list --prototype=Linux --children'.format(api_path)
del_resource = '{} resource delete --id={}'.format(api_path, '{}')
xml = run_cmd(all_resources)
elements = ET.fromstring(xml)
for element in elements:
for child in element:
ResourcePrototype = child.find('ResourcePrototype')
if ResourcePrototype is not None:
if server_to_remove in str(ResourcePrototype.get('name')):
result = run_cmd( del_resource.format( child.get( 'id')))
print(result)
if __name__ == '__main__': main()