Script para identificar la configuración de un vps

Script sh para identificar la configuración de un VPS.

Cuando adquirimos un VPS una de las principales preguntas que nos hacemos, es:

  • Realmente que procesador tengo.
  • Que disco duro tengo.
  • Que velocidad de descarga admite.
  • Mi disco duro es rápido o no.
  • etc…

Haciendo uso de comandos y alguna herramienta, podríamos identificar absolutamente todo. Pero en este caso creamos un script bash que nos identifique lo que nosotros queremos, lo lanzamos y los resultados los tendremos todos en una impresión en la consola / terminal y también en un archivo log.

Script para identificar la configuración de un vps 1

 

En este articulo vamos a crear un script, que identificara lo siguiente:

  • Modelo de CPU
  • Frecuencia de CPU
  • Numero de núcleos
  • Información general (IP, Hostname, etc…)
  • Ram
  • Swap
  • Tiempo de actividad
  • Speedtest IPv4
  • Speedtest IPv6 (solo si dispones de el)
  • Disk Speed I/O
  • Crea archivo log

 

Un ejemplo…

Benchmark started on mié nov 15 16:46:21 CET 2017
Full benchmark log: /root/benchmark.log

System Info
———–
Processor : Intel Core Processor (Haswell, no TSX)
CPU Cores : 4
Frequency : 2399.990 MHz
Memory : 7694 MB
Swap : 2000 MB
Uptime : 21:09:08,

OS : \S
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-693.5.2.el7.x86_64
Hostname : vps479982.ovh.net

Speedtest (IPv4 only)
———————
Your public IPv4 is XXX.XXX.XXX.XXX

Location Provider Speed
CDN Cachefly 12,6MB/s

Atlanta, GA, US Coloat 10,80MB/s
Dallas, TX, US Softlayer 10,58MB/s
Seattle, WA, US Softlayer 8,37MB/s
San Jose, CA, US Softlayer 9,04MB/s
Washington, DC, US Softlayer 11,6MB/s

Tokyo, Japan Linode 5,22MB/s
Singapore Softlayer 5,61MB/s

Rotterdam, Netherlands id3.net 12,6MB/s
Haarlem, Netherlands Leaseweb 12,7MB/s

Disk Speed
———-
I/O (1st run) : 395 MB/s
I/O (2nd run) : 387 MB/s
I/O (3rd run) : 380 MB/s
Average I/O : 390.667 MB/s

 

Identificar configuración de un VPS

Tan solo tienes que copiar este script y crear un archivo llamado benchmark.sh.

#!/bin/bash

sysinfo () {
	# Removing existing benchmark.log
	rm -rf $HOME/benchmark.log
	# Reading out system information...
	# Reading CPU model
	cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
	# Reading amount of CPU cores
	cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
	# Reading CPU frequency in MHz
	freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
	# Reading total memory in MB
	tram=$( free -m | awk 'NR==2 {print $2}' )
	# Reading Swap in MB
	vram=$( free -m | awk 'NR==4 {print $2}' )
	# Reading system uptime
	up=$( uptime | awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }' | sed 's/^[ \t]*//;s/[ \t]*$//' )
	# Reading operating system and version (simple, didn't filter the strings at the end...)
	opsy=$( cat /etc/issue.net | awk 'NR==1 {print}' ) # Operating System & Version
	arch=$( uname -m ) # Architecture
	lbit=$( getconf LONG_BIT ) # Architecture in Bit
	hn=$( hostname ) # Hostname
	kern=$( uname -r )
	# Date of benchmark
	bdates=$( date )
	echo "Benchmark started on $bdates" | tee -a $HOME/benchmark.log
	echo "Full benchmark log: $HOME/benchmark.log" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# Output of results
	echo "System Info" | tee -a $HOME/benchmark.log
	echo "-----------" | tee -a $HOME/benchmark.log
	echo "Processor	: $cname" | tee -a $HOME/benchmark.log
	echo "CPU Cores	: $cores" | tee -a $HOME/benchmark.log
	echo "Frequency	: $freq MHz" | tee -a $HOME/benchmark.log
	echo "Memory		: $tram MB" | tee -a $HOME/benchmark.log
	echo "Swap		: $vram MB" | tee -a $HOME/benchmark.log
	echo "Uptime		: $up" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	echo "OS		: $opsy" | tee -a $HOME/benchmark.log
	echo "Arch		: $arch ($lbit Bit)" | tee -a $HOME/benchmark.log
	echo "Kernel		: $kern" | tee -a $HOME/benchmark.log
	echo "Hostname	: $hn" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
}
speedtest4 () {
	ipiv=$( wget -qO- ipv4.icanhazip.com ) # Getting IPv4
	# Speed test via wget for IPv4 only with 10x 100 MB files. 1 GB bandwidth will be used!
	echo "Speedtest (IPv4 only)" | tee -a $HOME/benchmark.log
	echo "---------------------" | tee -a $HOME/benchmark.log
	echo "Your public IPv4 is $ipiv" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# Cachefly CDN speed test
	echo "Location		Provider	Speed"	| tee -a $HOME/benchmark.log
	cachefly=$( wget -4 -O /dev/null http://cachefly.cachefly.net/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "CDN			Cachefly	$cachefly" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# United States speed test
	coloatatl=$( wget -4 -O /dev/null http://speed.atl.coloat.com/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Atlanta, GA, US		Coloat		$coloatatl " | tee -a $HOME/benchmark.log
	sldltx=$( wget -4 -O /dev/null http://speedtest.dal05.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Dallas, TX, US		Softlayer	$sldltx " | tee -a $HOME/benchmark.log
	slwa=$( wget -4 -O /dev/null http://speedtest.sea01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Seattle, WA, US		Softlayer	$slwa " | tee -a $HOME/benchmark.log
	slsjc=$( wget -4 -O /dev/null http://speedtest.sjc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "San Jose, CA, US	Softlayer	$slsjc " | tee -a $HOME/benchmark.log
	slwdc=$( wget -4 -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Washington, DC, US	Softlayer 	$slwdc " | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# Asia speed test
	linodejp=$( wget -4 -O /dev/null http://speedtest.tokyo.linode.com/100MB-tokyo.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Tokyo, Japan		Linode		$linodejp " | tee -a $HOME/benchmark.log
	slsg=$( wget -4 -O /dev/null http://speedtest.sng01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Singapore 		Softlayer	$slsg " | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# Europe speed test
	i3d=$( wget -4 -O /dev/null http://mirror.i3d.net/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Rotterdam, Netherlands	id3.net		$i3d" | tee -a $HOME/benchmark.log
	leaseweb=$( wget -4 -O /dev/null http://mirror.leaseweb.com/speedtest/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Haarlem, Netherlands	Leaseweb	$leaseweb " | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
}
speedtest6 () {
	ipvii=$( wget -qO- ipv6.icanhazip.com ) # Getting IPv6
  	# Speed test via wget for IPv6 only with 10x 100 MB files. 1 GB bandwidth will be used! No CDN - Cachefly not IPv6 ready...
  	echo "Speedtest (IPv6 only)" | tee -a $HOME/benchmark.log
  	echo "---------------------" | tee -a $HOME/benchmark.log
  	echo "Your public IPv6 is $ipvii" | tee -a $HOME/benchmark.log
  	echo "" | tee -a $HOME/benchmark.log
  	echo "Location		Provider	Speed" | tee -a $HOME/benchmark.log
  	# United States speed test
	v6atl=$( wget -6 -O /dev/null http://speedtest.atlanta.linode.com/100MB-atlanta.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Atlanta, GA, US		Linode		$v6atl" | tee -a $HOME/benchmark.log
  	v6dal=$( wget -6 -O /dev/null http://speedtest.dallas.linode.com/100MB-dallas.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  	echo "Dallas, TX, US		Linode		$v6dal" | tee -a $HOME/benchmark.log
  	v6new=$( wget -6 -O /dev/null http://speedtest.newark.linode.com/100MB-newark.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  	echo "Newark, NJ, US		Linode	 	$v6new" | tee -a $HOME/benchmark.log
	v6fre=$( wget -6 -O /dev/null http://speedtest.fremont.linode.com/100MB-fremont.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Fremont, CA, US		Linode	 	$v6fre" | tee -a $HOME/benchmark.log
  	v6chi=$( wget -6 -O /dev/null http://testfile.chi.steadfast.net/data.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  	echo "Chicago, IL, US		Steadfast	$v6chi" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# Asia speed test
  	v6tok=$( wget -6 -O /dev/null http://speedtest.tokyo.linode.com/100MB-tokyo.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  	echo "Tokyo, Japan		Linode	 	$v6tok" | tee -a $HOME/benchmark.log
  	v6sin=$( wget -6 -O /dev/null http://speedtest.singapore.linode.com/100MB-singapore.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
  	echo "Singapore		Linode		$v6sin" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	# Europe speed test
	v6fra=$( wget -6 -O /dev/null http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "Frankfurt, Germany	Linode		$v6fra" | tee -a $HOME/benchmark.log
        v6lon=$( wget -6 -O /dev/null http://speedtest.london.linode.com/100MB-london.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
	echo "London, UK		Linode		$v6lon" | tee -a $HOME/benchmark.log
        v6har=$( wget -6 -O /dev/null http://mirror.nl.leaseweb.net/speedtest/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
        echo "Haarlem, Netherlands	Leaseweb	$v6har" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
}
iotest () {
	echo "Disk Speed" | tee -a $HOME/benchmark.log
	echo "----------" | tee -a $HOME/benchmark.log
	# Measuring disk speed with DD
	io=$( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
	io2=$( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
	io3=$( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
	# Calculating avg I/O (better approach with awk for non int values)
	ioraw=$( echo $io | awk 'NR==1 {print $1}' )
	ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )
	ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )
	ioall=$( awk 'BEGIN{print '$ioraw' + '$ioraw2' + '$ioraw3'}' )
	ioavg=$( awk 'BEGIN{print '$ioall'/3}' )
	# Output of DD result
	echo "I/O (1st run)	: $io" | tee -a $HOME/benchmark.log
	echo "I/O (2nd run)	: $io2" | tee -a $HOME/benchmark.log
	echo "I/O (3rd run)	: $io3" | tee -a $HOME/benchmark.log
	echo "Average I/O	: $ioavg MB/s" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
}
gbench () {
	echo "" | tee -a $HOME/benchmark.log
	echo "System Benchmark (Experimental)" | tee -a $HOME/benchmark.log
	echo "-------------------------------" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
	echo "Note: The benchmark might not always work (eg: missing dependencies)." | tee -a $HOME/benchmark.log
	echo "Failures are highly possible. We're using Geekbench for this test." | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
        gb_page=http://www.primatelabs.com/geekbench/download/linux/
        gb_dl=$(wget -qO - $gb_page | \
                 sed -n 's/.*\(https\?:[^:]*\.tar\.gz\).*/\1/p')
        gb_noext=${gb_dl##*/}
        gb_noext=${gb_noext%.tar.gz} 
        gb_name=${gb_noext//-/ }
	echo "File is located at $gb_dl" | tee -a $HOME/benchmark.log
	echo "Downloading and extracting $gb_name" | tee -a $HOME/benchmark.log
        wget -qO - "$gb_dl" | tar xzv 2>&1 >/dev/null
	echo "" | tee -a $HOME/benchmark.log
	echo "Starting $gb_name" | tee -a $HOME/benchmark.log
	echo "The system benchmark may take a while." | tee -a $HOME/benchmark.log
	echo "Don't close your terminal/SSH session!" | tee -a $HOME/benchmark.log
	echo "All output is redirected into a result file." | tee -a $HOME/benchmark.log
	echo "" >> $HOME/benchmark.log
	echo "--- Geekbench Results ---" >> $HOME/benchmark.log
	sleep 2
	$HOME/dist/$gb_noext/geekbench_x86_32 >> $HOME/benchmark.log
	echo "--- Geekbench Results End ---" >> $HOME/benchmark.log
	echo "" >> $HOME/benchmark.log
	echo "Finished. Removing Geekbench files" | tee -a $HOME/benchmark.log
	sleep 1
	rm -rf $HOME/dist/
	echo "" | tee -a $HOME/benchmark.log
        gbl=$(sed -n '/following link/,/following link/ {/following link\|^$/b; p}' $HOME/benchmark.log | sed 's/^[ \t]*//;s/[ \t]*$//' )
	echo "Benchmark Results: $gbl" | tee -a $HOME/benchmark.log
	echo "Full report available at $HOME/benchmark.log" | tee -a $HOME/benchmark.log
	echo "" | tee -a $HOME/benchmark.log
}
hlp () {
	echo ""
	echo "(C) Benchmark.sh 2 by Hidden Refuge <me at hiddenrefuge got eu dot org>"
	echo ""
	echo "Usage: benchmark.sh <option>"
	echo ""
	echo "Available options:"
	echo "No option	: System information, IPv4 only speedtest and disk speed & IOPing benchmark will be run."
	echo "-sys		: Displays system information such as CPU, amount CPU cores, RAM and more."
	echo "-io		: Runs a disk speed test and a IOPing benchmark and displays the results."
	echo "-iops		: Runs a extended IOPing test for latency, reading and et cetera."
	echo "-6		: Normal benchmark but with a IPv6 only speedtest (run when you have IPv6)."
	echo "-46		: Normal benchmark with IPv4 and IPv6 speedtest."
	echo "-64		: Same as above."
	echo "-b		: Normal benchmark with IPv4 only speedtest, I/O test and Geekbench system benchmark."
	echo "-b6		: Normal benchmark with IPv6 only speedtest, I/O test and Geekbench system benchmark."
	echo "-b46		: Normal benchmark with IPv4 and IPv6 speedtest, I/O test and Geekbench system benchmark."
	echo "-b64		: Same as above."
	echo "-h		: This help page."
	echo ""
	echo "The Geekbench system benchmark is experimental. So beware of failure!"
	echo ""
}
case $1 in
	'-sys')
		sysinfo;;
	'-io')
		iotest;;
	'-6' )
		sysinfo; speedtest6; iotest;;
	'-46' )
		sysinfo; speedtest4; speedtest6; iotest;;
	'-64' )
		sysinfo; speedtest4; speedtest6; iotest;;
	'-b' )
		sysinfo; speedtest4; iotest; gbench;;
	'-b6' )
		sysinfo; speedtest6; iotest; gbench;;
	'-b46' )
		sysinfo; speedtest4; speedtest6; iotest; gbench;;
	'-b64' )
		sysinfo; speedtest4; speedtest6; iotest; gbench;;
	'-h' )
		hlp;;
	*)
		sysinfo; speedtest4; iotest;;
esac

Lo ejecutas en tu VPS y listo.

 

Si quieres identificar la configuración de un vps, sin crear tu mismo el script bash, accede a la consola / terminal y ejecuta lo siguiente:

wget https://www.sololinux.es/public/benchmark.sh -O - -o /dev/null|bash

Se descargara y ejecutara automáticamente.

 

Espero que sea de utilidad el script identificador de la configuración de un vps.

Agregar comentario