Simply, I need a script to run the command request platform software package clean switch all which scans the root of flash: for unused .bin and .pkg files.
- If there are packages to clean if the switch prompts
Do you want to proceed? [y/n]and awaits user input. - If there are no packages to clean the switch presents a message
SUCCESS: No extra package or provisioning files found on media. Nothing to clean.and then returns to the exec prompthostname#.
Platform: 3650/3850 running IOS-XE 16.3.6
I tried an EEM applet to that watches the switch log for %SYS-5-RESTART, then;
- Runs the pkg_clean.tcl script.
- Reconfigures int gi1/0/48; removes description.\\**
- Performs the "software package clean" command, with typeahead "y".
- Deletes SVI for vlan 2.
- Deletes itself (the applet).
- Writes the config.
\\** I only put the Gi1/0/48 command in the tcl script so I could see the %SYS-5-CONFIG_I syslog message in debug since TCL does not print to syslog. This tells me that at least the ios_config line from the tcl script successfully ran.
EEM Applet
event manager applet pkg_clean event syslog occurs 1 pattern "%SYS-5-RESTART: System restarted" maxrun 60 action 001 cli command "enable" action 002 cli command "tclsh flash:pkg_clean.tcl" action 005 cli command "conf t" action 006 cli command "no int vlan 2" action 007 cli command "no event man app pkg_clean" action 008 cli command "end" action 009 cli command "write mem" action 010 cli command "" action 011 syslog msg "\n ##Old .bin and .pkg files cleaned from flash:, temporary interface vlan 2 deleted, wrote startup-config."
pkg_clean.tcl
ios_config "int gi1/0/48" "no desc" typeahead "y" exec "req plat soft pack clean sw all"
Result... The EEM applet hits the 60 second maxrun timer and then dies.
switch#debug event man act cli switch#event man run pkg_clean *Jul 31 2018 14:13:38.181 PDT: %HA_EM-6-LOG: pkg_clean : DEBUG(cli_lib) : : CTL : cli_open called. *Jul 31 2018 14:13:38.183 PDT: %HA_EM-6-LOG: pkg_clean : DEBUG(cli_lib) : : OUT : switch> *Jul 31 2018 14:13:38.183 PDT: %HA_EM-6-LOG: pkg_clean : DEBUG(cli_lib) : : IN : switch>enable *Jul 31 2018 14:13:38.295 PDT: %HA_EM-6-LOG: pkg_clean : DEBUG(cli_lib) : : OUT : switch# *Jul 31 2018 14:13:38.508 PDT: %HA_EM-6-LOG: pkg_clean : DEBUG(cli_lib) : : IN : switch#tclsh flash:pkg_clean.tcl *Jul 31 2018 14:13:38.551 PDT: %SYS-5-CONFIG_I: Configured from console by on vty0 (EEM:pkg_clean) switch# *Jul 31 2018 14:14:38.223 PDT: %HA_EM-6-LOG: pkg_clean : DEBUG(cli_lib) : : CTL : cli_close called. *Jul 31 2018 14:14:38.228 PDT: *Jul 31 2018 14:14:38.228 PDT: tty is now going through its death sequence
If I run it manually, it only takes about 15 seconds to prompt with [y/n].
switch#show clock *14:41:47.006 PDT Tue Jul 31 2018 switch#req plat soft pack clean sw all Running command on switch 1 Cleaning up unnecessary package files No path specified, will use booted path flash:packages.conf Cleaning flash: Scanning boot directory for packages ... done. Preparing packages list to delete ... cat3k_caa-guestshell.16.03.06.SPA.pkg File is in use, will not delete. cat3k_caa-rpbase.16.03.06.SPA.pkg File is in use, will not delete. cat3k_caa-rpcore.16.03.06.SPA.pkg File is in use, will not delete. cat3k_caa-srdriver.16.03.06.SPA.pkg File is in use, will not delete. cat3k_caa-wcm.16.03.06.SPA.pkg File is in use, will not delete. cat3k_caa-webui.16.03.06.SPA.pkg File is in use, will not delete. packages.conf File is in use, will not delete. done. The following files will be deleted: [1]: /flash/cat3k_caa-guestshell.16.03.03.SPA.pkg Do you want to proceed? [y/n]n switch# switch#show clock *14:42:01.748 PDT Tue Jul 31 2018
No comments:
Post a Comment