Am able to add new application with component using sdk but unable add new component for the existing application. Please anyone help me.
I like where your head is at, and I want to take up a similar task in the near future. Right now the best I have been able to do is import a new template with the component that I wrote into an xml file. That never turned into anything production ready but I basically took the xml export of stuff I wanted, say port monitors, service and process components and turned them into snippets to "rebuild" a new template for import with new components. There is a verb to do the import, but I didn't test that.
If you come up with something, I'd love to see it.
SAM components are complicated, but I have done some automatic template building in SQL. The reason I say it's complicated is that depending on exactly which type of component you are dealing with data needs to be added to several tables, and since it's not a supported feature you are on your own to hack out which tables you would need to modify to achieve the goal. Also you have to be very careful about testing release candidate if you run code like that because any back end changes could cause your custom rolled stuff to stop working.
With that said, the way I did it was to basically pull up any table in sam that seemed even remotely related to components, create myself a new template with the type of component I needed and compared what got added to the various tables, then just wrote SQL inserts to achieve the same. In my case the client wanted to have a SAM template for all their AIX servers that would continually monitor for changes to the file mounts and automatically add a script based monitor for each mount every time a new one popped in. Took about 8 hours of kicking things around in the database but we were able to get what we needed and it worked without a hitch afterward. I can say you will definitely be adding things to apm_component, and most likely to apm_componentsettings or apm_componenttemplatesettings. Beyond that there are several other tables but they only apply to specific component types so you'd have to hunt the new data down on your own. For my scripts I needed new rows in APM_DynamicEvidenceColumnSchema, but you wouldn't need that table for something like a process monitor. I know if I was more of a real database guy then there are traces you can set in SQL that will show you everything that happened to tables in excruciating detail, that's probably best but I never have learned to use those.
If it was easy I'm sure there would already be an API call for it, but unfortunately its not.