
#!/bin/bash
# File	: cdot_set_asup-config.sh
# By	: Maarten.deBoer@atos.net, 141222
# Subject	: Script to set ASUP config as work a round for Bug: 993376
# https://kb.netapp.com/support/s/article/ka11A0000000pHoQAI/autosupport-can-truncate-on-collection-or-delivery
#set -x
PGM="`basename $0|cut -d\. -f1`"
VER="0.2"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
SSH="/usr/bin/ssh -n"
CLUSTERS="${HOME}/etc/clusters"


#                                       Node: nlnaf100-01
#                                      State: enable
#                            SMTP Mail Hosts: 10.192.109.45
#                               From Address: nlnaf100-01@atos.net
#                       List of To Addresses: fsod@atos.net,
#                                             mdrglob@msssyscol01.bcklan.ao-srv.
#                                             com
#      (DEPRECATED) List of Noteto Addresses: fsod@atos.net
#                  List of Partner Addresses: support@e-storage.nl,
#                                             mdrglob@msssyscol01.bcklan.ao-srv.
#                                             com
#Send AutoSupport Messages to Vendor Support: enable
#                Protocol to Contact Support: https
#                 Support URL for HTTP/HTTPS: support.netapp.com/asupprod/post/1.0/postAsup
#                 Support URL for HTTP/S PUT: support.netapp.com/put/AsupPut
#                          Support Proxy URL: 10.192.8.29:63001
#                            Support Address: autosupport@netapp.com
#                           Hostname Subject: false
#                                 NHT Enable: true
#                    Performance Data Enable: true
#                             Retry Interval: 4m
#                                Retry Count: 15
#                            Reminder Enable: true
#                          Last Subject Sent: MANAGEMENT_LOG
#                             Last Time Sent: 3/24/2020 00:24:32
#                          Maximum HTTP Size: 50MB
#                          Maximum SMTP Size: 20MB
#                      Remove Sensitive Data: false
#      Validate Digital Certificate Received: true
#            AutoSupport OnDemand Server URL: https://support.netapp.com/aods/asupmessage
#
#  [ -state {enable|disable} ]               State
#  [ -mail-hosts <text>, ... ]               SMTP Mail Hosts
#  [ -from <Mail Address> ]                  From Address
#  [ -to <Mail Address>, ... ]               List of To Addresses
#  [ -noteto <Mail Address>, ... ]           (DEPRECATED) List of Noteto
#                                            Addresses
#  [ -partner-address <Mail Address>, ... ]  List of Partner Addresses
#  [ -support {enable|disable} ]             Send AutoSupport Messages to Vendor
#                                            Support
#  [ -transport {smtp|http|https} ]          Protocol to Contact Support
#  [ -proxy-url <text> ]                     Support Proxy URL
#  [ -hostname-subj {true|false} ]           Hostname Subject
#  [ -nht {true|false} ]                     NHT Enable
#  [ -perf {true|false} ]                    Performance Data Enable
#  [ -retry-interval <[<integer>h][<integer>m][<integer>s]> ]
#                                            Retry Interval
#  [ -retry-count <integer> ]                Retry Count
#  [ -reminder {true|false} ]                Reminder Enable
#  [ -max-http-size {<integer>[KB|MB|GB|TB|PB]} ]
#                                            Maximum HTTP Size
#  [ -max-smtp-size {<integer>[KB|MB|GB|TB|PB]} ]
#                                            Maximum SMTP Size
#  [ -remove-private-data {true|false} ]     Remove Sensitive Data
#  [ -validate-digital-certificate {true|false} ]
#                                            Validate Digital Certificate
#                                            Received

for CLUSTER in `cat ${CLUSTERS}|grep -v ^#`
do
  echo "${CLUSTER} ..."

  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport modify -node * -max-http-size 50MB'
  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport modify -node * -max-smtp-size 20MB'

#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem performance_asup -size-limit 350MB -time-limit 10m'
#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem performance -size-limit 150MB -time-limit 10m'
#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem mhost -size-limit 17MB -time-limit 4m'
#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem storage -size-limit 26MB -time-limit 6m'
#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem asup_ems -size-limit 4MB -time-limit 2m'
#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem kernel -size-limit 6MB -time-limit 2m'
#  ${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport budget modify -node * -subsystem wafl -size-limit 30MB -time-limit 10m'

#${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport modify -node * -proxy-url 10.192.8.29:63001 -mail-host 10.192.8.29'

#${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport modify -node * -to mdrglob@msssyscol01.bcklan.ao-srv.com -partner-address mdrglob@msssyscol01.bcklan.ao-srv.com -noteto "" ' 

# NEW SMTP & HTTPS-GateWays
${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport modify -node * -proxy-url 10.216.62.224:63001 -mail-host 10.216.62.223'

# Send a CHECK
${SSH} ${CLUSTER} 'set -privilege diagnostic; system node autosupport invoke -node * -type all -message check-new-proxy' 

done  # for CLUSTER


echo "`date` ${PGM} v${VER} finished."|tee -a ${LOG}
exit 0

