User Tools

Site Tools


scripting:python_scripts:checkpoint.py

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
scripting:python_scripts:checkpoint.py [2016/09/04 17:08] – created jotasandokuscripting:python_scripts:checkpoint.py [2023/11/02 14:38] (current) – external edit 127.0.0.1
Line 1: Line 1:
-import sys +  import sys 
-import subprocess +  import subprocess 
-import time +  import time 
-import pexpect +  import pexpect 
-import smtplib +  import smtplib
- +
- +
-#while dblock is 1 script will fail +
- +
- +
- +
-dblock = 1 +
-CPTMGMT = '10.30.165.21' +
-cpstat_output = 'set a true value so script fails if ssh does not run' +
-pushpolicy_output = 'set a value here so i know nothing got set at the end' +
-CPSTATCMD = 'cpstat' +
-PPCMD = 'fwm load -p firewall -m MKTX_DC03 DC03CPTFW' +
- +
- +
- +
-#or this, this is the mail alert in case we have any problems pushing policy +
-def mail_alert_push(ipaddr,message): +
-        SERVER = "ash1mail.marketaxess.com" +
-        FROM = "CheckPointPushAlerts@crpashnetdev01.com" +
-        TO = 'network@marketaxess.com' +
-        SUBJECT = "CHECKPOINT PUSH FAILED FOR PUSH " + ipaddr ,  message +
-        TEXT = "ALERT! The push policy script was not able to run!!!!!!" + message +
-        message = 'TO: %s ' % (TO) + '\n' + 'Subject: %s\n\n%s' % (SUBJECT, TEXT) +
-        server = smtplib.SMTP(SERVER) +
-        server.sendmail(FROM, [TO], message) +
-        server.quit() +
- +
-#if we are lucky this is the only alert we will hit +
-  def mail_alert_final(ipaddr,output): +
-          SERVER = "ash1mail.marketaxess.com" +
-          FROM = "CheckPointPushAlerts@crpashnetdev01.com" +
-          TO = 'network@marketaxess.com' +
-          SUBJECT = "CHECKPOINT POLICY HAS BEEN PUSHED" #real good dun duh dun dun duh dun dun nun na nun nun nah +
-          TEXT = "Checkpoint Policy has been pushed via the push policy script" +
-          message = 'TO: %s ' % (TO) + '\n' + 'Subject: %s\n\n%s \n\n%s' % (SUBJECT, TEXT, output) +
-          server = smtplib.SMTP(SERVER) +
-          server.sendmail(FROM, [TO], message) +
-          server.quit()+
      
      
-  +  #while dblock is 1 script will fail
      
      
      
 +  dblock = 1
 +  CPTMGMT = '10.30.165.21'
 +  cpstat_output = 'set a true value so script fails if ssh does not run'
 +  pushpolicy_output = 'set a value here so i know nothing got set at the end'
 +  CPSTATCMD = 'cpstat'
 +  PPCMD = 'fwm load -p firewall -m MKTX_DC03 DC03CPTFW'
      
      
      
 +  #or this, this is the mail alert in case we have any problems pushing policy
 +  def mail_alert_push(ipaddr,message):
 +          SERVER = "ash1mail.mycompany4.com"
 +          FROM = "CheckPointPushAlerts@crpashnetdev01.com"
 +          TO = 'network@mycompany4.com'
 +          SUBJECT = "CHECKPOINT PUSH FAILED FOR PUSH " + ipaddr ,  message
 +          TEXT = "ALERT! The push policy script was not able to run!!!!!!" + message
 +          message = 'TO: %s ' % (TO) + '\n' + 'Subject: %s\n\n%s' % (SUBJECT, TEXT)
 +          server = smtplib.SMTP(SERVER)
 +          server.sendmail(FROM, [TO], message)
 +          server.quit()
      
 +  #if we are lucky this is the only alert we will hit
 +  def mail_alert_final(ipaddr,output):
 +          SERVER = "ash1mail.mycompany4.com"
 +          FROM = "CheckPointPushAlerts@crpashnetdev01.com"
 +          TO = 'network@mycompany4.com'
 +          SUBJECT = "CHECKPOINT POLICY HAS BEEN PUSHED" #real good dun duh dun dun duh dun dun nun na nun nun nah
 +          TEXT = "Checkpoint Policy has been pushed via the push policy script"
 +          message = 'TO: %s ' % (TO) + '\n' + 'Subject: %s\n\n%s \n\n%s' % (SUBJECT, TEXT, output)
 +          server = smtplib.SMTP(SERVER)
 +          server.sendmail(FROM, [TO], message)
 +          server.quit()
 +    
   try:   try:
       conn = pexpect.spawn('ssh admin@10.30.165.21')       conn = pexpect.spawn('ssh admin@10.30.165.21')
scripting/python_scripts/checkpoint.py.1473008891.txt.gz · Last modified: (external edit)