Forum Discussion
3 years ago
Updated version! Much smaller now thank you @Michael Rodrigues
{ "scheduleOption": 0, "dataType": 0, "description": "List all Oracle databases with SNMP", "appliesTo": "hasCategory(\"OracleDB\")", "technology": "", "type": "propertyrule", "params": [ { "name": "linuxcmdline", "comment": "", "value": "" }, { "name": "linuxscript", "comment": "", "value": "" }, { "name": "scriptgroovy", "comment": "", "value": "// Locate Oracle database names via SNMP, tested on Linux\nimport com.santaba.agent.groovyapi.snmp.Snmp\n\ndef host = hostProps.get('system.hostname')\ndef timeout = 30000 // 30 seconds\n\n// List all running processes\noutput = Snmp.walkAsMap(host, \"1.3.6.1.2.1.25.4.2.1.4\", null, timeout)\ndef databases = [:]\ndef dblist = []\noutput.each { oid,process ->\n // Find the Oracle process names\n def proc_name = process =~ /oracle(?!PRD)([A-Z]+)([0-9+]?)/\n if(proc_name) {\n // Dump it in a Map to keep it unique\n databases[proc_name[0][1]] = 1\n }\n}\n// Loop the Map and pump them back into an array\ndatabases.each{entry -> dblist << entry.key}\ndb_names = dblist.join(\",\")\nprint \"auto.oracle_dbs=${db_names}\"" }, { "name": "scripttype", "comment": "embed", "value": "embed" }, { "name": "windowscmdline", "comment": "", "value": "" }, { "name": "windowsscript", "comment": "", "value": "" } ], "version": 1628201456, "tags": "", "auditVersion": 0, "name": "List_Oracle_Databases_SNMP", "id": 153, "group": "Oracle" }
Related Content
- 6 months agoJames_Rolt
- 2 years agordeluher
- 10 months agoTodd_Theoret