DevOps Admin Windows from Linux



As a DBA with difference engines to administer, sometimes I need to connect to SQL Server and MySQL engines, sometimes in Windows and sometimes in Linux.

I prefer to use Linux O.S. in my notebooks, may be it's not the best option at all, I know, but I want to be safe, have more resources for my tasks, less delays, and a simple way to do daily tasks. (clean, simple, spartan), off course I'm a Debian Linux fan too.

Right or wrong...? it's my option.


I had to prepare some script to simplify my daily works.

may be I'm a DevOp + DBA ?
who cares, je je...


As I.T. Engineering I have to solve problems everyday and sometimes build my own tools to solve it (if I don't have them).

I want to share some script I use in my daily tasks, I guess you could modify it with "your needs" too, and think in GPL and share it too.


Massive connection to Linux & MySQL servers and SQL Servers


(if you want the .sh file, just ask for it)

#!/bin/bash
# run it $ xxxxx NN
#
clear
echo " ----- All in One -----------------------------"
echo "1. uptime"
echo "2. mysql running ? check"
echo "3. SQL Server check"

for i in '192.168.10.2' \
'192.168.10.3' \
'192.168.10.4'

do
case $1 in
1)
echo "****"
echo "$i"
ssh "$i" 'echo `hostname`' "$i"
ssh "$i" "uptime"
;;

case $1 in
2)
clear
echo "****"
echo "$i"
ssh "$i" 'echo `hostname`' "$i"
mysql -uUSER -p'PASSWORD' -h "$i" -e 'select 1;'

read
;;

case $1 in
2)
clear
echo "****"
echo "$i"
ping -c 1 "$i"

# mssql tools installed in Linux
sqlcmd -U"user" -P"password" -S "$i" -Q "select 1;"

;;

esac

done

echo " # EOT "
exit 0
#
# EOF
#




Another script to connect to Windows servers (from Linux)
Again simple, clear and spartan (I have hundreds like this, one for each server) it's easy to type the name/ip and "Enter"



#!/bin/bash
rdesktop SERVERNAME/IP -x l -z -g 1024x768 -uUser -pPassword -r sound:off

I'm pretty sure you could create more like this for simple tasks, "bash" is still a great tool to interact, program and administer a remote server.



Another one, to identify new connections in a server or dis-connections.



#!/bin/bash
clear
netstat -a -n | grep tcp > /tmp/tcp
netstat -a -n | grep udp > /tmp/udp
while [ 1 = 1 ]
do
# sleep 0.5
cp /tmp/tcp /tmp/tcp2
cp /tmp/udp /tmp/udp2

netstat -a -n | grep tcp > /tmp/tcp
netstat -a -n | grep udp > /tmp/udp

# clear
echo "-----------------------------------------------------------------------"
date
echo "-----------------------------------------------------------------------"

# compare what lines appear now, not exists before
diff --side-by-side --suppress-common-lines /tmp/tcp /tmp/tcp2 | grep "<" diff --side-by-side --suppress-common-lines /tmp/udp /tmp/udp2 | grep "<" # read key, if Q exit read -t 1 -n 1 key if [[ $key = q ]] then break fi done # # EOF #







Comentarios

Entradas populares