Skip to content

Commit 49d080d

Browse files
authored
Create sl_config_diff_to_spark.py
Adding device name
1 parent 5b07db4 commit 49d080d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: eem_configdiff_to_spark/sl_config_diff_to_spark.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@
2828
#
2929
# spark_token : Bearer token for your Spark user/bot
3030
# spark_room : Spark room name to which messages will be sent
31+
# device_name : Device name from which the messages will be sent
3132
#
3233
# E.g.:
3334
#
3435
# event manager environment spark_token Bearer 1234abd...
3536
# event manager environment spark_room Network Operators
37+
# event manager environment device_name C3850
3638
#
3739

3840
import eem
@@ -58,6 +60,10 @@
5860
eem.action_syslog(
5961
'Environment variable "spark_room" must be set', priority='3')
6062
sys.exit(1)
63+
if 'device_name' not in arr_envinfo:
64+
eem.action_syslog(
65+
'Environment variable "device_name" must be set', priority='3')
66+
sys.exit(1)
6167

6268
# Get a CLI handle
6369
cli = eem.cli_open()
@@ -98,7 +104,9 @@
98104
# No differences found
99105
sys.exit(0)
100106

101-
msg = 'Configuration differences between the running config and last backup:\n'
107+
device_name = arr_envinfo['device_name']
108+
msg = '### Alert: Config changed on ' + device_name + '\n'
109+
msg += 'Configuration differences between the running config and last backup:\n'
102110
msg += '```{}```'.format('\n'.join(diff_lines[:-1]))
103111

104112
headers = {

0 commit comments

Comments
 (0)