It is very often that the power supply of IT infrastructure objects of small and middle offices is a bottleneck. Server rooms of small and middle companies often are not organized well, do not satisfy informational, fire, and electrical safety requirements and are limited in space. Such conditions may lead to emergency situations that are followed by downtime or, if luckily, potential risks, which can cause unnecessary anxiety about the safety of employees and business as a whole. To solve these issues, there is a range of effective practical methods to improve the operability of information equipment in small server rooms. In this article, we will examine a feature of intelligent power management of a small server group using NetPing power distribution units.
Task
It is necessary to ensure a long operation of a small group of servers from the uninterrupted power source, considering the next conditions:
- If the power supply is switched off in non-working hours, there is a need to avoid the situation when batteries are completely discharged by the beginning of a working day (9:00). This means switching off a majority of users and having duty devices only. It is necessary to restore the operation of the equipment if a power supply is restored in a server room or at the beginning of a working day (9:00). At the beginning of the working day, servers must be switched on regardless of the power supply;
- If the power supply is switched off during working hours, the equipment of a server room must operate until a working day is over (18:00) or until UPS batteries are fully charged;
- If the power supply is switched off in a server room, IT specialists of the organization and involved individuals must receive an SMS notification to a mobile phone.
Necessary Equipment
- NetPing 8/PWR-220 v4/SMS rack power distribution unit – 1 pc.;
- Supply voltage sensor – 1 pc.;
- UPS – 1 pc.;
- a PC or a server with low power supply for the operation of the managing script – 1 pc.;
- User servers – 4 pcs.;
- A local network
Wiring Diagram for Equipment
Algorithm of the Solution Operation
- A script works on a central computer and requests the status of a supply voltage sensor that is connected to the NetPing 8/PWR-220 v4/SMS rack power distribution unit once in 5 minutes using the URL-encoded commands;
- If the supply voltage sensor informs of the availability of the power supply, then nothing happens;
- If the supply voltage sensor informs of deenergizing, and the event of switching off the power supply took place during working hours, then a distributed power device NetPing 8/PWR-220 v4/SMS sends an SMS notification about the event. The script on a central computer does not send a command to servers to turn off. Instead, the equipment works until batteries are completely drained, until the power supply restores or until the working day is over;
- If supply voltage sensor informs of deenergizing, and the event has happened during non-working hours, a NetPing 8/PWR-220 v4/SMS rack PDU an SMS notification about the event. A script sends a command to all servers to turn off. When the power supply is restored or at the beginning of the working day, the script sends the command to turn on the sockets where servers are connected to the NetPing 8/PWR-220 v4/SMS rack PDU.
Implementing the Solution
Configuring a NetPing 8/PWR-200 v4/SMS Rack Power Distribution Unit
Let's consider a NetPing 8/PWR-220 v4/SMS rack PDU is configured for the operation in your local network, and its web interface is accessible to you. It is possible to learn the settings of a NetPing 8/PWR-220 v4/SMS rack PDU in a documentation for a device. In addition, there is a need to plug a supply voltage sensor to NetPing 8/PWR-220 v4/SMS. It is possible to learn the rules for connecting sensors to NetPing 8/PWR-220 v4/SMS from a user guide.
In our article, we are going to use the next parameters:
Parameter | NetPing 8/PWR-220 v4/SMS rack PDU |
---|---|
IP address | 192.168.1.203 |
Login | visor |
Password | ping |
IO lines with a supply voltage sensor | IO 1 |
Sockets, where servers are connected | Relay 1, Relay 2, Relay 3, Relay 4 |
Let's configure an SMS notification for IT specialists and other committed individuals.
Go to the page «SMS» through the navigation menu under the heading of a web interface (1) and fill in phone numbers in the section «GSM SETUP». Phone numbers are specified in the international format (starting from +7). Together, it is possible to indicate up to 4 destination numbers for receiving notifications. Save entered data using the button «Apply changes» (3):
Then, go to the page «DISCRETE IO» through the navigation menu under the heading of a web interface (1), click the button «Setup» for an IO line 1, where a supply voltage sensor (2) is connected:
In a window that opens, specify necessary event notification types for the IO line 1 (1). Confirm saving changes by clicking the button «Apply changes» (2):
At this point, NetPing 8/PWR-220 v4/SMS can be considered configured for sending SMS notifications about events, registered by a supply voltage sensor.
Preparing Managed Servers
Let's consider that a server group with intelligent power management includes servers with the next parameters:
IP address | 192.168.1.180 | 192.168.1.181 | 192.168.1.182 | 192.168.1.183 |
Operating System | Ubuntu 16.04.4 LTS | Windows Server 2012 R2 | Windows Server 2012 R2 | CentOS 7.0 |
Login | tester | tester | tester | tester |
Password | 12345 | 12345 | 12345 | 12345 |
For a script to work successfully on servers with *nix operating systems, there is a need to install an SSH server (if it was not installed before). For servers running on Windows operating systems, there is a need to install the package OpenSSH (a description of installing OpenSSH). In addition, we recommend to create a separate user at all managed server and give rights for remote connecting and turning off the operating system to this user (in our case, it is the user «tester»). BIOS of managed servers is necessary to be configured so that the servers turn on automatically when the power supply of servers is restored.
Creating a Control Script
To implement a software component for our intelligent power management system for a server group, let's write a script on a scripting programming language BASH. The script will be executed in a console and on a PC/server with OS Ubuntu. A control script can also be started on a computer outside the local network. In this case, a NetPing 8/PWR-220 v4/SMS rack PDU must be available through the Internet, and the Internet option must be non-volatile. It is possible to read here how to make a NetPing 8/PWR-220 v4/SMS rack PDU available through the Internet.
For the script to operate on a PC/server under OS Ubuntu, there is a need to install the utilities Curl and Expect. To do this, execute the next commands in a console «sudo apt install curl» and «sudo apt install expect»
Then, create a script file intellect_pdu.with a command «nano intellect_pdu.sh». It is possible to download a prepared file with a script here.
#!/bin/bash ##### In this section you can specify your values ##### #Device NetPing 8/PWR-220 v4/SMS IP address NPip="192.168.1.200" #Credentials for a NetPing 8/PWR-220 v4/SMS device NPuser="visor" NPpass="ping" #Credentials for servers user="tester" pass="12345" #List of servers serv=" 192.168.1.180 192.168.1.181 192.168.1.182 192.168.1.183 " ########################################################### while true do #We request information about the status of the presence 220V sensor: io1=$(curl --silent --user $NPuser:$NPpass http://$NPip/io.cgi?io1) sensor_220=${io1:20:1} if [ "$sensor_220" -eq 0 ] #If there is no power then echo "No power" d=$(date +%H) #Get the current time if [ "$d" -lt "09" ]||[ "$d" -gt "18" ] #If the current time is earlier than 9 am and later than 18 hours then echo "Out of hours - turn off the server" #turn off the servers: for S in $serv do expect -c " spawn ssh $user@$S expect \"*(yes/no)?*\" {send \"yes\r\"} expect \"Password:\" send \"$pass\r\" expect \"*>\" send \"shutdown -s\r\" expect \"*shutdown:*\" {send \"sudo shutdown -h now\r\"} expect \"*$user:*\" {send \"$pass\r\"} expect eof " >> /dev/null done sleep 10m #timeout for server shutdown #Disconnect the sockets to which the servers are connected: for ((n=1; n<5; n++)) do curl --silent --user $NPuser:$NPpass http://$NPip/relay.cgi?r$n=0 >> /dev/null done else echo "Working time - turn on the server" #We supply power to the server: for ((n=1; n<5; n++)) do curl --silent --user $NPuser:$NPpass http://$NPip/relay.cgi?r$n=1 >>/dev/null done fi else #If there power is on echo "Power is On" #We supply power to the server: for ((n=1; n<5; n++)) do curl --silent --user $NPuser:$NPpass http://$NPip/relay.cgi?r$n=1 >>/dev/null done fi sleep 5m done
Save and make the file executable by using the command «sudo chmod +x intellect_pdu.sh»:
Then, run our script with a command «./intellect_pdu.sh»:
And, if a source script code does not have syntax errors, then a console will display notifications about a status of a supply voltage sensor and the actions performed by the script. The script is adjusted for the endless cyclic operation. It is possible to stop the execution by using the combination «CTRL+C». On a screenshot below, the script events were created artificially,to represent all possible statuses:
To make your script run automatically when a PC/server is loaded, there is a need to add it to the autoload. To do this, open the file with rc.local using the command «sudo nano /etc/rc.local»:
Indicate the script before a line «exit 0» and save the file:
The script will be executed after the system reboot.
Therefore, we implemented a system of the intelligent power management for a small server room.