Hello
This is similar topic as I have asked in the past - but still it is little different. ServiceNow Connector pulls specific fields from icinga
Following is the list:
last_check_result.output
groups
notes_url
performance_data
notes
last_state_up
address
check_command
Now we somehow have to pass oracle DB instance name in the output field or one of hte above fields.
I took a dump of the /object/serivices api for lets say oracle
{
"attrs": {
"__name": "hostname!P_OR_PDB_SwitchInterval",
"acknowledgement": 0.0,
"acknowledgement_expiry": 0.0,
"action_url": "",
"active": true,
"check_attempt": 1.0,
"check_command": "oracle_health",
"check_interval": 300.0,
"check_period": "",
"check_timeout": null,
"command_endpoint": "hostname",
"display_name": "P_OR_PDB_SwitchInterval",
"downtime_depth": 0.0,
"enable_active_checks": true,
"enable_event_handler": true,
"enable_flapping": false,
"enable_notifications": true,
"enable_passive_checks": true,
"enable_perfdata": true,
"event_command": "",
"flapping": false,
"flapping_current": 27.4,
"flapping_last_change": 0.0,
"flapping_threshold": 0.0,
"flapping_threshold_high": 30.0,
"flapping_threshold_low": 25.0,
"force_next_check": false,
"force_next_notification": false,
"groups": [],
"ha_mode": 0.0,
"handled": false,
"host_name": "hostname",
"icon_image": "",
"icon_image_alt": "",
"last_check": 1594201220.619314,
"last_check_result": {
"active": true,
"check_source": "hostname",
"command": [
"/usr/lib//nagios/plugins/check_oracle_health",
"--connect",
"abcdef_instance",
"--mode",
"switch-interval",
"--report",
"long",
"--username",
"secrete_user"
],
"execution_end": 1594201220.61927,
"execution_start": 1594201219.236873,
"exit_status": 2.0,
"output": "CRITICAL - cannot connect to abcdef_instance. ORA-01017: invalid username/password; logon denied (DBD ERROR: OCISessionBegin)",
"performance_data": [],
"schedule_end": 1594201220.619314,
"schedule_start": 1594201220.619314,
"state": 2.0,
"ttl": 0.0,
"type": "CheckResult",
"vars_after": {
"attempt": 1.0,
"reachable": true,
"state": 2.0,
"state_type": 0.0
},
"vars_before": {
"attempt": 1.0,
"reachable": true,
"state": 0.0,
"state_type": 1.0
}
},
"last_hard_state": 0.0,
"last_hard_state_change": 1594200844.829981,
"last_reachable": true,
"last_state": 0.0,
"last_state_change": 1594201220.610858,
"last_state_critical": 1594201220.610879,
"last_state_ok": 1594201141.470915,
"last_state_type": 1.0,
"last_state_unknown": 0.0,
"last_state_unreachable": 0.0,
"last_state_warning": 1594199598.625638,
"max_check_attempts": 3.0,
"name": "P_OR_PDB_SwitchInterval",
"next_check": 1594201279.760888,
"notes": "",
"notes_url": "",
"original_attributes": null,
"package": "director",
"paused": true,
"previous_state_change": 1594200844.829981,
"problem": true,
"retry_interval": 60.0,
"severity": 136.0,
"source_location": {
"first_column": 1.0,
"first_line": 242.0,
"last_column": 43.0,
"last_line": 242.0,
"path": "/var/lib/icinga2/api/packages/director/fcec207d-89a1-407d-a4f3-2231794c1a70/zones.d/Satellite_INF/service_apply.conf"
},
"state": 2.0,
"state_type": 0.0,
"templates": [
"P_OR_PDB_SwitchInterval",
"tmplService-OraHealth",
"host var overrides (Director)"
],
"type": "Service",
"vars": {
"oracle_health_connect": "abcdef_instance",
"oracle_health_mode": "switch-interval",
"oracle_health_username": "secret_user"
},
"version": 0.0,
"volatile": false,
"zone": "Satellite_INF"
},
"joins": {},
"meta": {},
"name": "hostname!P_OR_PDB_SwitchInterval",
"type": "Service"
},
This is basically a single service which has been overridden for each instance of monitoring. This alert is for Oracle instance abcdef_instance. I want to somehow pass this information in one of the default fields mentioned above which servicenow pulls. Can I write in the serrvice-template of P_OR_PDB_SwitchInterval under lets say in output
Long Story Short:
I want to somehow pass like this without touching the plugin
“output”: $oracle_health_connect$ + “CRITICAL - cannot connect to abcdef_instance. ORA-01017: invalid username/password; logon denied (DBD ERROR: OCISessionBegin)”,
And this information will be populated on specific instance name of the field