| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 
 |  
#/bin/bash/
for serveur in $(cat serveurs.txt)
do
ssh $serveur
kernel=`uname`
manufacturer=`dmidecode | grep 'Manufacturer:' | head -n 1 | cut -f 2 -d ' '`
puppet=0
if [ "$kernel" == "AIX" ]; then
        echo "Est AIX !"
        short_name=`/usr/bin/hostname | cut -f 1 -d '.'`
        domain=`/usr/bin/hostname | cut -f 2,3,4 -d '.'`
        fqdn=`/usr/bin/hostname`
        version=`/usr/bin/uname | cut -f 3,4 -d ' '`
        ip=`/etc/ifconfig en0 | grep inet | cut -c 7- | cut -f 1 -d ' '`
        ip2=`/etc/ifconfig en1 | grep inet | cut -c 7- | cut -f 1 -d ' '`
else if [ "$kernel" == "Linux" ]; then
	short_name=`hostname | cut -f 1 -d '.'`
	domain=`hostname | cut -f 2,3,4 -d '.'`
	fqdn=`hostname`
	version=`cat /etc/redhat-release | cut -f 1,2,3 -d ' '`
	ip=`cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR=  | cut -f 2 -d '='`
	ip2=`cat /etc/sysconfig/network-scripts/ifcfg-eth1 | grep IPADDR=  | cut -f 2 -d '='`
	version_maj=`cat /etc/redhat-release  | cut -f 7 -d ' ' | cut -c -1`
	if [ "version_maj" == "4" ]; then
		puppet=stopped_on_rhel_4
		else
		puppet=`/etc/init.d/puppet status | cut -f 3 -d ' '`
		test_retour=`echo $?`
	fi
		if [ "$test_retour" == "127" ]; then
		puppet=puppet_not_found
		else
		test_retour=0
	fi	
		if [ "$manufacturer" == "VMware," ]; then
			service_tag=`dmidecode | grep "Serial Number: VMware" | cut -c 17-`
			else
			service_tag=`dmidecode | grep -w "Serial Number" | head -n 1 | cut -c 18-`
		fi
else
	short_name=$serveur
	kernel="Is"
	domain=" not"
	fqdn=" a"
	kernel="Linux"
	version=" or"
	ip=" AIX"
	ip2=" operating"
	service_tag=" system."
        fi
fi
 
echo $short_name;$domain;$fqdn;$kernel;$version;$ip;$ip2;$manufacturer;$service_tag;`date +%Y-%m-%d-%Hh%M` >> retour.csv
logout
done | 
Partager