Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script for powering down ports

Status
Not open for further replies.

Maxwell1001

Vendor
Nov 27, 2008
722
0
0
US
I was wondering if anyone knows the script to power down ports on a x250e 24port for example at certain hours of the day


bascially want to power down ip phones while the office is closed, I dont know about writing scripts so was hoping someone could help

regards

ACA - IP Office
ACS - IP Office
 
got it i think

create upm profile disable-ports <ENTER>
disable port 1
. <ENTER>


create upm profile enable-ports <ENTER>
enable port 1
. <ENTER>



create upm timer disableports
configure upm timer disableports profile disableports
configure upm timer disableports at 9 15 2009 19 00 00 every 86400


create upm timer enableports
configure upm timer enableports profile enableports
configure upm timer enableports at 9 16 2009 7 00 00 every 86400

ACA - IP Office
ACS - IP Office
 
this did not work any ideas why????

ACA - IP Office
ACS - IP Office
 
p.s these aint the dates i used

ACA - IP Office
ACS - IP Office
 
Hi Maxwell,

Have you tried with command:
disable inline-power port 1

Let me know.
 
disable inline-power port 1

diables all ok

enable inline-power port 1

enables all ok

ACA - IP Office
ACS - IP Office
 
Hi - I'm also working on a x250e 24port.

When writing the scripts is there a way to check the status of other ports before carrying out the action in the script?

e.g.

I want to check the status of 2 other ports before shutting down a port so it should be on the lines of:

IF (port 1 is up && port 2 is up) THEN
disable port 3
ENDIF

I've checked through EXOSConcepts12_3__Rev.02.book.pdf and can't see the section in there that describes how to check the status of ports in scripts.
 
so are you saying that i need to put the above information into a script and then have the scritp run at certain times???

i got the above off a extreme forum (which i cant find now)

ACA - IP Office
ACS - IP Office
 
The only bit I need to find out is how to check the status of a port in a script.
 
Just to let you know I've figured it out.

You need to parse the information you need from a show command. Therefore, one of the show commands to get the status of a port is:

show port 17 statistics no-refresh

* switch2.54 # show port 17 statistics no-refresh
Port Link Tx Pkt Tx Byte Rx Pkt Rx Byte Rx Pkt Rx Pkt
State Count Count Count Count Bcast Mcast
================================================================================
17 R 5 1710 5 1710 0 0
================================================================================
> indicates Port Display Name truncated past 8 characters
Link State: A-Active, R-Ready, NP-Port Not Present, L-Loopback


In the script you need to get the Link State part i.e. the letter "R"

set var CLI.OUT " "
show port 17 statistics no-refresh
set var port17 $TCL(lindex ${CLI.OUT} 23)

This puts the output of the show command into a list, the command $TCL(lindex ${CLI.OUT} 23) gets the 23rd item in the list which is the letter R.
 
the information i was provided after various testing was not even powring down the ports just disabling it,

i always remember that this had to be done via a script, would you be happy to share your script on here??

Regards

ACA - IP Office
ACS - IP Office
 
You can do it with 2 scripts (UPM Profiles), one to power down the ports and one to power up.

I'm not sure whether you want to just power down the port or remove the inline power so just going to make these scripts generic, you can replace the statement parts with anything you want the switch to do.

create upm profile down
enable cli scripting
<statement>
.

create upm timer down-timer
configure upm timer down-timer profile down
# this runs the profile at set time and every day (86400 seconds)
configure upm timer down-timer at mm dd yyyy hh mm ss every 86400

you then need to create another one to bring it back up

create upm profile up
enable cli scripting
<statement>
.

create upm timer up-timer
configure upm timer up-timer profile up
# this runs the profile at set time and every day (86400 seconds)
configure upm timer up-timer at mm dd yyyy hh mm ss every 86400

The switch is clever enough to adjust the dates in its config so if for example the switch restarts and the upm timer value is set in the past but has the "every" keyword used, it will adjust the timer to kick in at the next cycle, so the next day in this example.

The only problem I can conceive and one which I'm currently trying to figure out is how to get round the switch being powered down during the time the script is supposed to kick in, this means that the required action won't be carried out until the next cycle. Rather than having 2 scripts to run at certain times there must be a way of checking the time within 1 script, comparing it to the actual time and then carrying out the required action. You could then just have this 1 script running every minute or so indefinitely.

Another concern I have is that if the switch is in the state where for example a port has been disabled due to the script and then someone logs onto the switch, makes some changes and saves the config. The switch will then revert to this configuration for the port if it is rebooted and will not come back up until the script starts running again. Being able to compare the time within the switch would be useful for this as well.
 
when i set it up using the same method the the disable port or down as you called it if i just run this command the ports disable but not power down

2ndly

the switch is not following any of the timers

ACA - IP Office
ACS - IP Office
 
I know this sounds obvious but is the system time set correctly?

wrt the inline power I'm not exactly sure what the command is to switch the power off.
 
here is the show switch or some of it

X250e-24p.1 # show switch

SysHealth check: Enabled (Normal)
Recovery Mode: All
System Watchdog: Enabled

Current Time: Fri Mar 26 09:18:03 2010
Timezone: [Auto DST Disabled] GMT Offset: 0 minutes, name is UTC.
Boot Time: Wed Mar 10 11:30:38 2010
Boot Count: 30
Next Reboot: None scheduled
System UpTime: 15 days 21 hours 47 minutes 25 seconds

Current State: OPERATIONAL
Image Selected: primary
Image Booted: primary
Primary ver: 12.3.3.6
Secondary ver: 12.3.3.6

i need to power the port down its a money saving / enviroment sollution its not just disabling the port, i did a scripting workshop and im sure i was given the script but i cant fint it anywhere



ACA - IP Office
ACS - IP Office
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top