1 2 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
| #!/usr/bin/ksh
#(@) DCT automatique sous Linux
# @version=S0F7
#
output=$PWD
cd ${0%/*}
script_dir=$PWD
cd $output
output=$( locale | awk -F '"' '/^LC_MESSAGES=/ { print $2; exit }' )
if [[ "${output#*.}" != "$output" ]]; then
iconv="| iconv -f ISO8859-1 -t ${output#*.}"
fi
LANG=C
PATH=/sbin:/usr/sbin:/usr/bin:/bin:/usr/symcli/bin:usr/sbin
umask 022
alias integer="typeset -i"
alias local="typeset"
alias echo="print -r -"
alias read="read -r"
alias fold="fold -s -w 130"
script_version=1.0
script_cksum=$( cksum $0 | awk '{ print $1, $2 }' )
script_datetime=$( chmod 755 $0; ls -l $0 )
execution_datetime=$( date +%Y-%m-%d" "%H:%M )
host=$( awk -F = '$1 == "HOSTNAME" { print $2 }' /etc/sysconfig/network )
oslevel=$( awk '/^Red Hat Enterprise Linux AS release/ { print $7 }' /etc/redhat-release )
case "$oslevel" in
3) tcp_wrappers_version=7.6-34; openssh_version=3.6.1p2-33.30.4; sudo_version=1.6.7p5-1;;
*) tcp_wrappers_version=7.6-37.2; openssh_version=3.9p1-8; sudo_version=1.6.7p5-30.1.3;;
esac
if [[ -f /etc/modprobe.conf ]]; then modules_conf=/etc/modprobe.conf; else modules_conf=/etc/modules.conf; fi
max_lines=24
tmp_file=$script_dir/DCT-$host.tmp # needed since large command outputs blow up this script's shell environment
HTML_file=$script_dir/DCT-$host.html
sudoers_file=/etc/sudoers
mailhost=[193.249.133.24]
is_commonbundle=no
if [[ -d /etc/signatures ]]
then
is_commonbundle=yes
soft_dir="/opt"
soft_dir_appli="/opt"
soft_sys_dir="/etc"
else
soft_dir="/exec"
soft_dir_appli="/exec/products"
soft_sys_dir="/system"
fi
function complete_xml_tags {
awk '{ line = $0; while ( line ~ /</ && line !~ />/ ) { getline; line = line $0 }; print line }'; }
function get_xml_attribute {
sed "s|^.* $1=\" *\([^\"]*\) *\".*\$|\1|"; }
function get_xml_attributes {
local format="$1"; shift
local regexp="^"
while [[ -n "$1" ]]; do
regexp="$regexp.* $1=\" *\([^\"]*\) *\""
shift
done
sed "s|$regexp.*\$|$format|"; }
###function select_xml_attribute {
### attribute=$1; attribute=${attribute%=*}
### value=$1; value=${value#*=}
### grep " $attribute=\" *$value *\""; }
function cat_if_exists {
if [[ -f "$1" ]]; then cat "$1"; else echo "*** $1 inexistant ***"; fi; }
function reduce_columns {
awk '
{ Label[++MaxRec] = $0
MC = length
if (MaxLen < MC)
MaxLen = MC
for (C = 1; C <= MC; C++)
if (substr($0, C, 1) != " ")
Space[C] = "N" }
END {
PrecSpace = " "
for (R = 1; R <= MaxRec; R++) {
for (C = 1; C <= MaxLen; C++) {
if (Space[C] == "N" || PrecSpace == "N")
printf "%s", substr (Label[R], C, 1)
PrecSpace = Space[C] }
printf "\n" } }'; }
function process_lines {
local name
local value
local comment
local command
local count_c
local count_l
while IFS=" " read id name value comment; do
if echo $id | grep -q "^#"; then
continue
fi
if [[ "$value" = "*" ]]; then
# write a title
echo "<h3 id=\"$id\">$name</h3>" >>$HTML_file
if [[ -n "$comment" ]]; then
echo "<p><i>($comment)</i><p>" >>$HTML_file
fi
else
# write a subtitle
echo "<h4 id=\"$id\">$name</h4>" >>$HTML_file
if [[ -n "$comment" ]]; then
echo "<p><i>($comment)</i><p>" >>$HTML_file
fi
eval echo "\"$name\"" $iconv
if [[ "$value" != "-" ]]; then
command=$( echo "$value" | awk '{ print $1 }' )
if whence $command >/dev/null 2>&1; then
{ eval "$value"; } 2>&1 | sed 's:\&:\&\;:g; s:<:\<\;:g; s:>:\>\;:g; s:#:\#\;:g' >$tmp_file
count_l=$( wc -l <$tmp_file )
count_c=$( wc -c <$tmp_file )
if (( count_c <= 1 )); then
echo "$value" | fold | sed '1 s|^|<pre><font color="#008833"># |; $ s|$|</font>|' >>$HTML_file
echo "*** pas de sortie standard ni erreur ***</pre>" >>$HTML_file
elif (( count_l <= max_lines )); then
echo "$value" | fold | sed '1 s|^|<pre><font color="#008833"># |; $ s|$|</font>|' >>$HTML_file
fold $tmp_file | sed '$s:$:</pre>:' >>$HTML_file
else
echo "$value" | fold | sed '1 s|^|<pre><font color="#008833"># </font><a href="javascript: ;" onclick="toggle(this.nextSibling)"><font color="#008833">|; $ s|$|</font></a><span class="oversize" style="display:none">|' >>$HTML_file
fold $tmp_file | sed '$s:$:</span></pre>:' >>$HTML_file
fi
else
echo "<pre>*** commande $command pas trouvée ***</pre>" >>$HTML_file
fi
fi
fi
done; }
function process_filesys {
output=$( dumpe2fs "$1" 2>/dev/null )
local DC=$( echo "$output" | awk '/^Filesystem created:/ { print $5, $4, $7 }' )
local FF=$( echo "$output" | sed '/^Filesystem features/ !d; s/^[^:]*: *//' )
local BC=$( echo "$output" | sed '/^Block count/ !d; s/^[^:]*: *//' )
local BS=$( echo "$output" | sed '/^Block size/ !d; s/^[^:]*: *//' )
if [[ -n "$BC" && -n "$BS" ]]; then local size_MB=$(( BS/512*BC/2048 )); fi
print "<tr><td>$1</td><td>$2</td><td>$DC</td><td>$FF</td><td>$size_MB</td><td>$BC</td><td>$BS</td></tr>" >>$HTML_file; }
function process_EMC_disks {
# In a "SYMCLI_OUTPUT_MODE=xml" context, "2>/dev/null" due to a bug that generates an empty line.
if whence symcfg >/dev/null 2>&1 && whence symdev >/dev/null 2>&1 && whence symmaskdb >/dev/null 2>&1; then
SYMCLI_OUTPUT_MODE=xml symcfg list 2>/dev/null |
sed '/<Symmetrix .* attachment="Local" / !d' | get_xml_attributes '\1 \2' id model |
while read sid model; do
print "<code>Symmetrix $model, numéro de série $sid</code>\n<table>\n<tr><th>Disque front end</th><th>Ports front end</th><th>Disques back end</th><th>Nº de rangée</th><th>Nº de device</th><th>Type de device</th><th>Taille en Mo</th></tr>" >>$HTML_file
(( size_total = 0 ))
SYMCLI_OUTPUT_MODE=xml symdev -sid $sid -v list 2>/dev/null | complete_xml_tags >$tmp_file
spacing=$( sed '/<Device pd_name=/ !d; q' $tmp_file | sed 's|^\( *\)<.*$|\1|' )
# There is a bug in SYMCLI 6.0.1.0 which causes the XML output of the following command to crash; so we use the text output. "-c1-16,24-" is not quite stable...
symmaskdb -host $host -sid $sid list capacity | sed '1,/^-/ d; /^$/ d; /^-/,$ d' | cut -c1-16,24- | while read symm_dev size front; do
tag=$( sed "/<Device pd_name=.* dev_name=\"$symm_dev\"/ !d" $tmp_file )
disk=$( echo "$tag" | get_xml_attribute pd_name )
disk=${disk##*/}
configuration=$( echo "$tag" | get_xml_attribute configuration )
front=$( echo "$front" | tr -d " " )
echo "$symm_dev $size $front $( echo $disk | sed 's:^\(.*[^0-9]\)\([0-9]*\):\1 \2:' ) $configuration"
done | sort -k 4,4 -k 5,5n | while read symm_dev size front disk_nonum disk_num configuration; do
(( size_total += size ))
disk=$disk_nonum$disk_num
front=$( echo "$front" | tr "," " " )
case "$configuration" in
*-5)
back=$(
sed "1,/<Device pd_name=.* dev_name=\"$symm_dev\"/ d; /^$spacing<\\/Device>/,$ d; /<Device dev_name=/ !d" $tmp_file |
get_xml_attribute dev_name |
while read symm_subdev; do
sed "1,/<Device pd_name=.* dev_name=\"$symm_subdev\"/ d; /^$spacing<\\/Device>/,$ d; /<Hyper director=/ !d" $tmp_file | get_xml_attributes '\1:\2\3' director interface tid
done )
;;
*)
back=$( sed "1,/<Device pd_name=.* dev_name=\"$symm_dev\"/ d; /^$spacing<\\/Device>/,$ d; /<Disk director=/ !d" $tmp_file | get_xml_attributes '\1:\2\3' director interface tid )
;;
esac
back=$( echo "$back" | sort | tr [:lower:] [:upper:] )
row=$( print "ibase=16\n$( echo "$back" | head -1 | cut -d ":" -f2 | cut -c 2- )/2 + 1" | bc -q )
back=$( echo $back )
echo "<tr><td>$disk</td><td>$front</td><td>$back</td><td>$row</td><td>$symm_dev</td><td>$configuration</td><td>$size</td></tr>" >>$HTML_file
done
print "</table>\n<code>Taille totale : $size_total Mo</code>" >>$HTML_file
done
else
echo "<pre>*** commande symcfg, symdev ou symmaskdb pas trouvée ***</pre>" >>$HTML_file
fi; }
function process_port {
local port_protocol=$1
local port=$( lsdev -C -r parent -l $port_protocol )
local output=$( lscfg -v -l $port )
local -l WWN_port=$( echo "$output" | grep "Network Address" | sed 's:^.*\.::' )
local driver_fileset=$( lsdev -C -F "subclass.type" -l $port )
local driver=${driver_fileset#*.}
driver_fileset=devices.$driver_fileset.rte
# On utilisera $driver au lieu de $driver_fileset pour garantir que le tableau soit imprimable en A4 à l'italienne.
local version_driver=$( lslpp -cLq $driver_fileset | cut -d ":" -f 3 )
local firmware=$( echo "$output" | grep "Device Specific.(Z9)" | sed 's|^.*Z9.\.*\.[[:alpha:]]*||g' )
local location=$( echo "$output" | awk "\$1 == \"$port\" { print \$2 }" | sed 's:\.: \. :g' )
local scsi_id=$( lsattr -E -l $port_protocol -a scsi_id -F value | sed 's:^0x::' )
scsi_id=${scsi_id}000
local domain_id=$( print "ib=16\n"$( echo $scsi_id | cut -c 1-2 | dd conv=ucase 2>/dev/null ) | bc )
local port_switch=$( print "ib=16\n"$( echo $scsi_id | cut -c 3-4 | dd conv=ucase 2>/dev/null ) | bc )
local found=no
local WWNs
local LUNs
local tape
local tapes=$( lsdev -C -r name -c tape -p $port_protocol | sed 's:^\(.*[^0-9]\)\([0-9]*\):\1 \2:' | sort -k1,1 -k2,2n | tr -d " " )
if [[ -n "$tapes" ]]; then
found=yes
WWNs=$( echo "$tapes" | while read tape; do lsattr -E -l $tape -a ww_name; done | awk '{ print $2 }' | sed 's:^0x::; s:$:<br>:; $ s:<br>$::' | tr -d "\n" )
LUNs=$( echo "$tapes" | while read tape; do lsattr -E -l $tape -a lun_id; done | awk '{ print $2 }' | sed 's:^0x::; s:\([0-9]\)0*$:\1<br>:; $ s:<br>$::' | tr -d "\n" )
tapes=$( echo "$tapes" | sed 's:$:<br>:; $ s:<br>$::' | tr -d "\n" )
echo "<tr><td>$tapes</td><td>$port</td><td>$WWN_port</td><td>$driver $version_driver</td><td>$firmware</td><td>$location</td><td>$domain_id</td><td>$port_switch</td><td>n/a</td><td colspan="2">$WWNs</td><td>$LUNs</td></tr>" >>$HTML_file
fi
if whence symmask >/dev/null 2>&1 && whence symmaskdb >/dev/null 2>&1; then
output=$( SYMCLI_OUTPUT_MODE=xml symmaskdb -wwn $WWN_port list devs 2>/dev/null | complete_xml_tags )
local unit=$( echo "$output" | grep "<symmetrix " | get_xml_attribute id )
if [[ -n "$unit" ]]; then
found=yes
output=$( echo "$output" | grep "<Device " )
local disks=$( echo "$output" | get_xml_attribute Pdev_name | sed 's:^/dev/::; s: *$:<br>:; $ s:<br>$::' | tr -d "\n" )
local symm_devs=$( echo "$output" | get_xml_attribute dev_name | tr -d " " | sed 's:$:<br>:; $ s:<br>$::' | tr -d "\n" )
local LUNs=$( echo "$output" | get_xml_attribute lun | tr -d " " | sed 's:$:<br>:; $ s:<br>$::' | tr -d "\n" )
output=$( SYMCLI_OUTPUT_MODE=xml symmask list hba 2>/dev/null | complete_xml_tags | sed "1,/<Host_HBA WWN=\"$WWN_port\"/ d; /<\\/Host_HBA>/,$ d" )
local port_unit=$( echo "$output" | get_xml_attribute director ):$( echo "$output" | get_xml_attribute port )
echo "<tr><td>$disks</td><td>$port</td><td>$WWN_port</td><td>$driver $version_driver</td><td>$firmware</td><td>$location</td><td>$domain_id</td><td>$port_switch</td><td>Symmetrix $unit</td><td>$port_unit</td><td>$symm_devs</td><td>$LUNs</td></tr>" >>$HTML_file
fi
fi
if [[ "$found" = no ]]; then
echo "<tr><td></td><td>$port</td><td>$WWN_port</td><td>$driver $version_driver</td><td>$firmware</td><td>$location</td><td>$domain_id</td><td>$port_switch</td><td></td><td></td><td></td><td></td></tr>" >>$HTML_file
fi; }
function process_if {
local IF=$1
local teamid=$2
if [[ -n "$2" ]]; then shift 2; local team=$*; fi
case $IF in
TEAM_VA*_)
output=$( sed "1,/^TEAM_ID=$teamid *\$/ d; /^TEAM_ID=/,\$ d; /^$IF/ !d" /etc/basp/team-* )
if=$( echo "$output" | awk -F = '$1 ~ /_NAME$/ { print $2 }' )
local address=$( echo "$output" | awk -F = '$1 ~ /_IP$/ { print $2 }' )
local mask=$( echo "$output" | awk -F = '$1 ~ /_NETMASK$/ { print $2 }' )
local broadcast=$( echo "$output" | awk -F = '$1 ~ /_BROADCAST$/ { print $2 }' )
###F local gateway=$( echo "$output" | awk -F = '$1 ~ /_GW$/ { print $2 }' )
local VLAN=$( echo "$output" | awk -F = '$1 ~ /_VLAN$/ { print $2 }' )
;;
bond*|eth*)
if=$IF
local location=$( lshw -disable scsi -businfo -C network | awk "\$2 == \"$if\" { print \$1 }" )
if [[ -f /proc/net/nicinfo/$if.info ]]; then # Not all NICs maintain such a file.
local driver=$( awk '$1 == "Driver_Name" { ORS = " "; print $2 } $1 == "Driver_Version" { print $2; exit }' /proc/net/nicinfo/$if.info )
local MAC_native=$( awk '$1 == "Permanent_HWaddr" { print $2; exit }' /proc/net/nicinfo/$if.info | tr -d : )
local firmware=$( awk '$1 == "Bootcode_Version" { print $2; exit }' /proc/net/nicinfo/$if.info )
local speed_duplex=$( awk '$1 == "Speed" { ORS = " "; print $2 } $1 == "Duplex" { print $2; exit }' /proc/net/nicinfo/$if.info ) ###F
else
local output=$( lshw -disable scsi -C network | sed "1,/[[:blank:]]logical name: $if\$/ d; /*-network:/,$ d" )
local configuration=$( echo "$output" | sed '/[[:space:]]configuration:/ !d; s/^[^:]*:[[:blank:]]//' | tr -d : )
local driver=$( echo "$configuration" | awk -F = 'BEGIN { RS = " "; ORS = " " } $1 == "driver" { print $2 } $1 == "driverversion" { print $2 }' )
if [[ -z "$driver" && -n "$location" ]]; then
local vendor_device=$( lspci -n -s ${location#pci@} | awk '{ print $4 }' )
local drivers=$( awk "\$2 ~ /^0x0*${vendor_device%:*}\$/ && \$3 ~ /^0x0*${vendor_device#*:}\$/ { print \$1 }" /lib/modules/$( uname -r )/modules.pcimap | sort -u )
if (( $( echo "$drivers" | wc -l ) > 1 )); then
driver=$( echo "$drivers" | while read driver; do if lsmod | grep -q "^$driver[[:blank:]]"; then echo $driver; fi; done )
fi
if [[ -z "$driver" ]]; then
driver=$drivers
fi
driver=$( echo $driver )
fi
local MAC_native=$( echo "$output" | sed '/[[:space:]]serial:/ !d; s/^[^:]*:[[:blank:]]//' | tr -d : )
local firmware=$( echo "$configuration" | awk -F = 'BEGIN { RS = " " } $1 == "firmware" { print $2 }' )
local speed_duplex=$( echo "$configuration" | awk -F = 'BEGIN { RS = " "; ORS = " " } $1 == "speed" { print $2 } $1 == "duplex" { print $2 }' ) ###F
if [[ -z "$speed_duplex" ]]; then
speed_duplex=$( ethtool $if | awk '/\tSpeed:/ { ORS = " "; print $2 } /\tDuplex:/ { print $2; exit }' )
fi
fi
local -l MAC_active=$( ifconfig $if | awk '/ HWaddr / { print $5 }' | tr -d : )
if grep -q '^BOOTPROTO="*dhcp"* *' /etc/sysconfig/network-scripts/ifcfg-$if; then
local address="(DHCP)"
else
local address=$( awk -F = '$1 == "IPADDR" { print $2; exit }' /etc/sysconfig/network-scripts/ifcfg-$if | tr -d "'\"" )
fi
local mask=$( awk -F = '$1 == "NETMASK" { print $2; exit }' /etc/sysconfig/network-scripts/ifcfg-$if | tr -d "'\"" )
local broadcast=$( awk -F = '$1 == "BROADCAST" { print $2; exit }' /etc/sysconfig/network-scripts/ifcfg-$if | tr -d "'\"" )
### local gateway=$( awk -F = '$1 == "GATEWAY" { print $2; exit }' /etc/sysconfig/network-scripts/ifcfg-$if | tr -d "'\"" )
local VLAN=$( echo $if | awk -F. '{print $2}' )
;;
esac
if [[ -n "$address" && "$address" != "(DHCP}" && -z "$broadcast" ]]; then
if [[ -z "$mask" ]]; then
mask="(default)"
broadcast="(default)"
else
old_IFS="$IFS"
IFS=". "
set -A mask_ $mask
set -A address_ $address
IFS="$old_IFS"
for i in 0 1 2 3; do
(( mask_[$i] ^= 255 ))
(( address_[$i] |= mask_[$i] ))
done
broadcast=${address_[0]}.${address_[1]}.${address_[2]}.${address_[3]}
fi
fi
IP_host=$( awk "\$1 == \"$address\" { print \$2; exit }" /etc/hosts )
case $IF in
TEAM_VA*_)
echo "<tr><td>$if</td><td colspan="6">Interface virtuelle sur le team BASP : $team</td><td>$IP_host</td><td>$address</td><td>$mask</td><td>$broadcast</td><td>$VLAN</td></tr>" >>$HTML_file
;;
bond*|eth*)
echo "<tr><td>$if</td><td>$MAC_native</td><td>$MAC_active</td><td>$driver</td><td>$firmware</td><td>$location</td><td>$speed_duplex</td><td>$IP_host</td><td>$address</td><td>$mask</td><td>$broadcast</td><td>$VLAN</td></tr>" >>$HTML_file
;;
esac; }
function process_product {
if [[ -n "$4" ]]; then
local data=$( echo "$4" | sed 's:$:<br>:; $ s:<br>$::' )
print "<tr><td rowspan=\"2\">$1</td><td>$2</td><td>$3</td></tr>\n<tr><td colspan=\"2\">$data</td></tr>" >>$HTML_file
else
print "<tr><td>$1</td><td>$2</td><td>$3</td></tr>" >>$HTML_file
fi; }
function find_inst_root { # Repérage de la racine d'installation d'un logiciel
local file=$1 # Nom du fichier a rechercher
local nodes_up=$2 # Nombre de niveaux a remonter pour atteindre la racine
shift 2 # Les autres arguments sont les repertoires possibles de recherche
find $* -name "$file" 2>/dev/null | \
awk -v nodes_up=$nodes_up -F / '{ for (I = 2; I <= NF-nodes_up; I++) printf "/"$I; printf "\n" }' |
sort 2>/dev/null |
head -1; }
function install_dirs {
rpm -ql "$1" 2>/dev/null |
awk '{
sub ("/[^/]*$", "") # removes the top level, like dirname
print }' |
sort -u |
awk '
BEGIN {
previous_node = "VIDE" }
{
if ( $0 !~ previous_node"/*" || previous_node == "/" ) { # Selects the lines that are no subdirectory of another
printf ", %s", $0
previous_node = $0 } }
END {
printf "\n" }' |
cut -c 3-; }
function send_mail {
local mailuser=$1
{ cat <<EOF
Subject: DCT $host
Content-Type: multipart/mixed; boundary="--@se@pa@ra@teur@"
----@se@pa@ra@teur@
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Ci-joint le relevé par mkdct.ksh de la machine $host.
Pour afficher la table des matières et activer le bouton,
ouvrir la pièce jointe dans un navigateur Web.
----@se@pa@ra@teur@
Content-Type: text/html; charset="iso-8859-1"; name="$title.html"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="$title.html"
EOF
cat $HTML_file
cat <<EOF
----@se@pa@ra@teur@--
EOF
} | sendmail -v $mailuser@$mailhost; }
### MAIN ###
if [[ "$( id -un )" != root ]]; then
print "\nATTENTION :\nComme ce script n'est pas exécuté sous root, certaines informations peuvent manquer.\n"
fi
usage="Usage: $0 [-m recipient] utilization application GoRo\nwhere recipient is a mail recipient at francetelecom.com,\nand utilization is something like PROD, PREPROD, SECOURS\n"
while getopts m: option; do
case $option in
m) mailuser="$OPTARG"
shift 2
;;
?) print "$usage"
return 2
;;
esac
done
if [[ -z "$2" ]]; then
print "$usage"
exit 1
fi
utilization=$1
shift
application=$1
shift
GoRoCo=$1
title="DCT $application $GoRoCo $host $utilization $( echo $execution_datetime | cut -d " " -f 1 )"
HTML_file="DCT_"$application"-"$GoRoCo"_"$host".html"
cat <<EOF >$HTML_file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<title>$title</title>
<!-- execution_datetime=\"$execution_datetime\" -->
<!-- script_datetime=\"$script_datetime\" -->
<!-- script_cksum=\"$script_cksum\" -->
<!-- script_version=\"$script_version\" -->
<style type="text/css">
<!--
BODY { margin-top: .2in; margin-left: .2in; margin-right: .2in; margin-bottom: .2in; }
BODY, P, H1, H4, LI, UL, DIV, SPAN, TABLE { font-size: 10pt; }
H1, H2, H3, H4, H5 { font-family: Verdana, Arial, Helvetica, sans-serif; }
H2 { font-size: 12pt; font-weight: bold; }
H3 { font-size: 11pt; font-weight: bold; margin-top: 30pt; background: #FFFF99; }
PRE, TABLE { font-family: Courier, fixed, serif; }
TH, TD { border-style: none; border-width: 0pt; margin: 0pt; padding: 2pt; text-align: left; vertical-align: top; }
TH { background: #BBBBBB; }
TD { background: #DDDDDD; }
-->
</style>
<script language="JavaScript1.2" type="text/javascript">
<!--
var what = ' les résultats de plus de $max_lines lignes'
function toggleOversize(where) {
var elements = document.getElementsByTagName('SPAN')
if (where.value != 'Afficher'+what) {
for (i = 0; i < elements.length; i++) {
if (elements[i].className == 'oversize')
elements[i].style.display = 'none' }
where.value = 'Afficher'+what }
else {
for (i = 0; i < elements.length; i++) {
if (elements[i].className == 'oversize')
elements[i].style.display = 'inline' }
where.value = 'Masquer'+what } }
function toggle(what) {
if (what.style.display == 'none')
what.style.display = ''
else
what.style.display = 'none' }
function contentsObj(pid,plevel,ptitle) {
this.id = pid
this.level = plevel
this.title = ptitle }
function mkcontents() {
var tags = new Array('H3','H4')
var counters = new Array(0,0)
var contents = new Array()
for (i = 1; i < document.body.childNodes.length; i++) {
child = document.body.childNodes[i]
for (j = 0; j < tags.length; j++) {
if (child.tagName == tags[j]) {
counters[j]++
if ( j == 0 ) {
counters[1] = 0
child.firstChild.nodeValue = counters[0]+'. '+child.firstChild.nodeValue }
contents[contents.length] = new contentsObj(child.id,j,child.firstChild.nodeValue) } } }
contentsElement = document.getElementById('generatedContents')
for (i = 1; i < contents.length; i++) {
if (contents[i].level == 1) {
var numberSpc = document.createTextNode('\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0')
contentsElement.appendChild(numberSpc) }
var numberLink = document.createElement('A')
numberLink.href = '#'+contents[i].id
var numberTxt = document.createTextNode(contents[i].title)
numberLink.appendChild(numberTxt)
contentsElement.appendChild(numberLink)
var numberBr = document.createElement('BR')
contentsElement.appendChild(numberBr) } }
-->
</script>
</head>
<body text=\"#000000\" link=\"#006600\" vlink=\"#669966\" alink=\"#990000\" onload="mkcontents()">
<p>À l'ouverture de ce document, les résultats de commandes dépassant $max_lines lignes sont masqués. Leur affichage peut être basculé globalement en cliquant sur le bouton ci-dessous, ou individuellement en cliquant sur la commande concernée.</p>
<p><input type="button" value="Afficher les résultats de plus de $max_lines lignes" onclick="toggleOversize(this)"></p>
<h2>$title</h2>
<h4 id="contents">Table des matières</h4>
<p id="generatedContents"></p>
EOF
{ cat <<EOF
hard Matériel *
arch Type d'architecture matérielle uname -i
machine Machine lshw -disable scsi -C system | sed '1 d; /description:/ d; s/width:/architecture:/; /-system:/,\$ d'
firmware BIOS lshw -disable scsi -C memory | sed '/ *\*-firmware/ d; /^ *\*-/,$ d'
proc Nombre de processeurs echo \$( lshw -C cpu | awk 'BEGIN{proc=0; ht=0}/-cpu/{proc++}/capabilities:.* ht/{ht++}END{if(ht > 0){print proc, "processeur(s) physique(s) avec support hyperthreading"}else{print proc, "processeur(s) physique(s) sans support hyperthreading"}}' ) En cas d'hyper-threading, un processeur physique fait office de deux processeurs logiques.
procprop Caractéristiques des processeurs awk '/cache size/ { print } /model name/ { print } /cpu MHz/ { print } /vendor_id/ { print }' /proc/cpuinfo | sort -ur
mem Taille totale de la mémoire awk '\$1 == "MemTotal:"' /proc/meminfo
swap Espaces d'échange cat /proc/swaps Taille(s) en Ko
adapter Contrôleurs d'E/S lshw -short -C communication,isapnp,network
hardpathpci Hiérarchie des dispositifs PCI lspci -tv
hardpath Hiérarchie des dispositifs lshw -short
periph Détails des dispositifs lshw
###F tape Bandes SCSI lsdev -C -c tape -s fcp
diskpart Disques et partitions fdisk -lu
disk Disques lshw -C disk Voir aussi syminq en complément.
#raiddisk Disques md RAID cat_if_exists /etc/raidtab Le RAID md est hors cadre de production standard.
syminq Disques SCSI par commande EMC² syminq
symdisk Disques sur baies Symmetrix - À finaliser. Pour le VCM, voir <a href="#symvcm">VCM sur baies Symmetrix</a>. Chaque disque front end (visible par le hôte) est composé de morceaux des disques back end (physiques à l'intérieur de la baie) énumérés. La rangée est la rangée physique des disques back end dans la baie.
EOF
} | process_lines
process_EMC_disks
{ cat <<EOF
symdiskpath Disques sur baies Symmetrix, par lien symmask list hba | sed '1,/^-/ d; /^\$/ d' | awk '{ print \$1 }' | while read WWN; do symmaskdb -wwn \$WWN list devs; done On y trouve également le nom Linux de chaque disque ainsi que son numéro de LUN. D'autre part, on y trouve, pour chaque lien, le nom Linux et le World Wide Name (WWN) du port local, ainsi que le numéro de série de la baie Symmetrix. Pour le WWN du port sur la baie Symmetrix, voir <a href="#hardpath">Hiérarchie des dispositifs</a>". Pour le VCM, voir <a href="#symvcm">VCM sur baies Symmetrix</a>.
#symvcm VCM sur baies Symmetrix symmask list hba A tester. La colonne </i><code>Identifier</code><i> contient le WWN du port local, la colonne </i><code>Physical Device Path</code><i> correspond au VCM.
symvcm VCM sur baies Symmetrix sympd list -vcm A tester. La colonne </i><code>Identifier</code><i> contient le WWN du port local, la colonne </i><code>Physical Device Path</code><i> correspond au VCM.
EOF
if whence powermt >/dev/null 2>&1; then
cat <<EOF
pp Chemins et ports PowerPath powermt display
ppdisk Disques PowerPath powermt display dev=all
EOF
else
cat <<EOF
pp PowerPath - Pas de configuration PowerPath détectée.
EOF
fi
if whence datapath >/dev/null 2>&1; then
cat <<EOF
ap Chemins Autopath lsvpcfg
apport Ports Autopath datapath query adapter
apdisk Disques Autopath datapath query device
EOF
else
cat <<EOF
ap Autopath - Pas de configuration Autopath détectée.
EOF
fi
cat <<EOF
fcnet Réseaux Fiber Channel *
fcport Ports Fiber Channel, bandes et disques - Le domain ID et le port sur le switch sont fiables uniquement quand la SCSI ID du switch suit l'usage DOSI.
EOF
} | process_lines
cat <<EOF >>$HTML_file
<table>
<tr><th colspan="6">Serveur local</th><th colspan="2">Switch</th><th colspan="4">Unité distante</th></tr>
<tr><th rowspan="2">Bandes ou<br>disques<br>(hors VCM)</th><th rowspan="2">Port</th><th rowspan="2">WWN du port</th><th rowspan="2">Driver et version</th><th rowspan="2">Vers. du microc.<br>de la carte</th><th rowspan="2">Emplacement</th><th rowspan="2">Domain ID</th><th rowspan="2">Nº du port</th><th rowspan="2">Désignation et<br>nº de série</th><th colspan="2">WWN des ports corr. aux bandes</th><th rowspan="2">LUNs corr.<br>aux bands<br>ou dsqus</th></tr>
<tr><th>Port</th><th>Nº des<br>devices corr.<br>aux disques</th></tr>
EOF
#lsdev -C -l "fscsi*" -r name | while read port_protocol; do process_port $port_protocol; done
cat <<EOF >>$HTML_file
</table>
EOF
{ cat <<EOF
#fcportprop Ports Fiber Channel, caractéristiques dynamiques lsdev -C -l "fscsi*" -r name | while read port_protocol; do port=\$( lsdev -C -r parent -l \$port_protocol ); print "\\n*** \$port ***\\n"; lsattr -E -l \$port; lsattr -E -l \$port_protocol; done A tester
diskspace Espace disques *
pv Appartenance des PV (disques sous LVM) aux VG (groupes de volumes) pvscan
vg Liste des VG vgdisplay -s | sed '/^$/ d'
activevg Liste des VG actifs vgdisplay -As | sed '/^$/ d'
EOF
vgdisplay -Ac | cut -d : -f 1 | sed '/^$/ d' | while read VG; do cat <<EOF
charvg$VG Caractéristiques du VG $VG vgdisplay -v $VG
EOF
done
cat <<EOF
filesys Systèmes de fichiers cat /etc/fstab
filesyschar Caractéristiques des systèmes de fichiers ext2 et ext3 -
EOF
} | process_lines
cat <<EOF >>$HTML_file
<table>
<tr><th>Système de fichiers</th><th>Label</th><th>Date de création</th><th>Caractéristiques</th><th>Taille<br>en Mo</th><th>Nombre<br>de blocs</th><th>Taille<br>des blocs<br></th></tr>
EOF
awk '$3=="ext2" || $3=="ext3" { print $1 }' /etc/fstab | while read FS; do
label=
if echo $FS | grep -q ^LABEL=; then
label=$( echo "$FS" | cut -d = -f 2 )
FS=$(
awk '{ print $4 }' /proc/partitions | while read dev; do
if [[ $( e2label /dev/$dev 2>/dev/null ) = "$label" ]]; then echo "/dev/$dev"; continue; fi
done )
fi
process_filesys "$FS" "$label"
done
cat <<EOF >>$HTML_file
</table>
EOF
{ cat <<EOF
#crashdump Paramètres de system crash dump -
# Platon ne créé pas de system crash dump
kernel Noyau *
kernelversion Version cat /proc/version
ker64 Noyau 32-bits ou 64-bits uname -m Le noyau est 64-bits quand la chaîne renvoyée par la commande se termine en </i><code>64</code><i>
#opt Options de lancement cat /proc/cmdline
tune Réglages cat /etc/sysctl.conf
module Configuration du chargement des modules cat $modules_conf
activemodule Modules actifs lsmod
service Services *
syslog Configuration du syslog cat /etc/syslog.conf
inittab Services démarrés avec le système chkconfig --list Les services sont lancés suivant le niveau de marche indiqué.
ipnet Réseaux IP *
#ethcfg Interfaces Ethernet et leur configuration persistante sed '/^ *eth[0-9]:/ !d; s|^ *\(eth[0-9]*\):.*$|\1|' /proc/net/dev | while read if ; do ethtool \$if ; done
ethcfg Interfaces Ethernet et leur configuration persistante
###F
EOF
} | process_lines
cat <<EOF >>$HTML_file
<table>
<tr><th>Inter-<br>face</th><th>Adresse MAC native</th><th>Adresse MAC active</th><th>Module du noyau et version</th><th>Vers. du microc.<br>de la carte</th><th>Emplacement</th><th>Vitesse et mode duplex</th><th>Nom IP</th><th>Adresse IP</th><th>Masque IP</th><th>Broadcast IP</th><th>VLAN</th></tr>
EOF
#lshw -disable scsi -short -C network | awk '$2 ~ /^eth/ { print $2 }' | while read if; do process_if $if; done
# sed '/^ *eth[0-9]:/ !d; s|^ *\(eth[0-9]*\):.*$|\1|' /proc/net/dev | while read if; do process_if $if; done
awk -F':' '/eth|bond/{print $1}' /proc/net/dev | while read if; do process_if $if; done
awk -F = '/^TEAM_ID=/ { teamid = $2; team = "" } /^TEAM_PA.*_NAME=/ { team = team" "$2 } /^TEAM_VA.*_NAME=/ { sub("NAME$", "", $1); print $1, teamid, team }' /etc/basp/team-* | while read if teamid team; do process_if $if $teamid $team; done
###F relever le role (0=primary, 1=standby)
cat <<EOF >>$HTML_file
</table>
EOF
{ cat <<EOF
routdefault Passerelle IP par défaut awk -F = '\$1 == "GATEWAY" { print \$2 }' /etc/sysconfig/network Il s'agit de la passerelle globale, non liée à une interface spécifique.
routstat Routes IP statiques cat_if_exists /etc/sysconfig/static-routes
# routdyn Routes IP dynamiques netstat -r
routdynno Routes IP dynamiques, sans résolution des noms IP netstat -rn
hosttab Table des hôtes IP cat /etc/hosts
hostresolv Ordre de résolution des noms IP if [[ -f /etc/nsswitch.conf ]]; then grep ^hosts: /etc/nsswitch.conf; fi
hostresolvdns Résolution des noms IP par DNS cat_if_exists /etc/resolv.conf
# ipstat Statistiques des interfaces IP netstat -i
#ipstatno Statistiques des interfaces IP, sans résolution des noms IP netstat -in
ipconfig Configuration des interfaces IP ifconfig -a
bonding Configuration bonding cat_if_exists /proc/net/bonding/bond*
vconfig Configuration VLAN cat_if_exists /proc/net/vlan/config
ntp Configuration NTP cat /etc/ntp.conf
hostsallow Filtrage TCP Wrappers positif cat_if_exists /etc/hosts.allow
hostsdeny Filtrage TCP Wrappers négatif cat_if_exists /etc/hosts.deny
sysenv Environnement système *
boot Menu des dispositifs proposés à l'amorçage cat /boot/grub/menu.lst
envvar Variables d'environnement grep ^umask /etc/profile; echo; cat_if_exists /etc/sysconfig/i18n
user Utilisateurs *
usergroup Groupes d'utilisateurs cat /etc/group
useraccount Comptes d'utilisateurs cat /etc/passwd
sudo Configuration sudo cat_if_exists $sudoers_file
crontab Crontabs de root et du système echo "root:"; crontab -l; for crontab in \$( find /etc/cron.d/* -prune -type f ); do echo "\$crontab:"; cat \$crontab; done
usercron Utilisateurs ayant droit au service cron cat /etc/cron.allow
userat Utilisateurs ayant droit au service at cat /etc/at.allow
soft Logiciels système *
oslevel Version de l'OS cat /etc/redhat-release
#maintlevel Niveau de maintenance de l'OS - Pas de correspondance en Linux
#maintlevelcomplete Niveaux de maintenance complets et incomplets - Pas de correspondance en Linux
rpm Packages RPM installés rpm -qa
# sisame Dont packages SISAME if output=\$( rpm -qi "tcp_wrappers-*" 2>/dev/null | awk '/^Version.*Vendor: Red Hat, Inc./ { version = \$3 } /^Release/ { if ( version != "" ) print version"-"\$3 }' ) && [[ ! "\$output" < "$tcp_wrappers_version" ]]; then echo "tcp_wrappers-\$output"; fi; if output=\$( rpm -qi "openssh-*" 2>/dev/null | awk '/^Version.*Vendor: Red Hat, Inc./ { version = \$3 } /^Release/ { if ( version != "" ) print version"-"\$3 }' ) && [[ ! "\$output" < "$openssh_version" ]]; then rpm -qa | grep ^openssh-; fi; if output=\$( rpm -qi "sudo-*" 2>/dev/null | awk '/^Version.*Vendor: Red Hat, Inc./ { version = \$3 } /^Release/ { if ( version != "" ) print version"-"\$3 }' ) && [[ ! "\$output" < "$sudo_version" ]]; then echo "sudo-\$output"; fi
sisame Dont packages SISAME for i in tcp_wrappers openssh sudo; do rpm -qi "\$i-*" | awk '/Name/{printf "%s ", \$3}/Version/{print \$3}' ; done
rpmintegr Incohérences parmi les packages RPM installés rpm -aV ok si pas de sortie standard
prod Produits *
prodsignsys Signatures des produits système ls -l ${soft_sys_dir}/signatures
prodsign Signatures des produits d'infrastructure ls -l ${soft_dir}/signatures
prodbase Répertoire d'installation des produits d'infrastructure ls -l ${soft_dir_appli}
prodgoroco GxRxCx des produits d'infrastructure cat_if_exists /exec/execonf/config.cfg
prodvers Version de quelques produits d'infrastructure -
EOF
} | process_lines
\rm $tmp_file
cat <<EOF >>$HTML_file
<table>
<tr><th rowspan="2">Produit</th><th>Version</th><th>Répertoire(s) d'installation</th></tr>
<tr><th colspan="2">Clé(s) d'activation (si applicable)</th></tr>
EOF
product="AMASS"
inst_root=$( find_inst_root aawin 4 ${soft_dir_appli}/amass )
version=$( awk -F= '$1=="VERS" { print $2 }' $inst_root/amass/PRODUCT_FILE 2>/dev/null )
if [[ -n "$version" ]]; then
process_product "$product" "$version" "$inst_root"
fi
product="Apache"
inst_root=$( find_inst_root httpd 2 ${soft_dir_appli}/apache )
version=$( $inst_root/bin/httpd -v 2>/dev/null | awk -F/ '/version/ { sub (" .*", "", $2) ; print $2 }' )
if [[ -n "$version" ]]; then
process_product "$product" "$version" "$inst_root"
fi
product="BEA Tuxedo"
inst_root=$( find_inst_root registry.xml 1 ${soft_dir_appli}/tuxedo )
if [[ -n "$inst_root" ]]; then
version=$( awk '/release level=/ { print $2 }' $inst_root/registry.xml | cut -d '"' -f 2 )
if [[ -n "$version" ]]; then
keys=
keys=$( grep -e '^\[.*\]$' -e '^EXPIRATION=' -e '^SIGNATURE=' $inst_root/udataobj/lic.txt 2>/dev/null )
process_product "$product" "$version" "$inst_root" "$keys"
fi
fi
product="BEA WebLogic"
package="weblogic-*"
inst_root=$( find_inst_root bea 1 ${soft_dir_appli}/weblogic )
if [[ -n "$inst_root" ]]; then
version=$( rpm -qi "$package" | awk -F':' '/Version/{print $2}' )
if [[ -n "$version" ]]; then
keys=$( cat $inst_root/bea/licen?e.bea )
process_product "$product" "$version" "$inst_root" "$keys"
fi
fi
product="BMC Patrol Agent"
inst_root=$( find_inst_root patrolrc.sh 2 ${soft_dir_appli}/patrol )
target=$( find $inst_root -name target 2>/dev/null | head -1 )
if [[ -x "$target" ]]; then
PatrolAgent=${target%/*}/$( $target )/bin/PatrolAgent
if [[ -x "$PatrolAgent" ]]; then
version=$( $PatrolAgent -v 2>&1 | awk '$1 == "PatrolAgent" { print $2, $6 }' | sed 's:^V::' )
keys=
keys=$( grep -E "^V[0-9]|^PASSWD" ${target%/*}/lib/license )
process_product "$product" "$version" "$inst_root" "$keys"
fi
if [[ -d ${target%/*}/lib/knowledge ]]; then
inst_root=${target%/*}/lib/knowledge
if [[ -f $inst_root/SW_SENTRY.km ]]; then
version=$( awk '$1 == "!release" { print $2; exit }' $inst_root/SW_SENTRY.km )
if [[ -f $inst_root/SW_CFT.km ]]; then
addon=" with CFT add-on"
else
addon=""
fi
process_product "- KM Sentry Application$addon" "$version" "$inst_root"
fi
if [[ -f $inst_root/SEN_BO_BLACKOUT.km ]]; then
version=$( awk '$1 == "!RELEASE" { print $2; exit }' $inst_root/SEN_BO_BLACKOUT.km )
process_product "- KM Sentry Blackout Manager" "$version" "$inst_root"
fi
if [[ -f $inst_root/UNI_UNIVERSE.km ]]; then
version=$( grep "KMU RELEASE" $inst_root/UNI_UNIVERSE.km | cut -d V -f 2 | cut -d \\ -f1 | sed 's:( :(:; s: ):):' )
process_product "- KM Dollar Universe" "$version" "$inst_root" "(clé voir Dollar Universe, ligne KMU)"
fi
if [[ -f $inst_root/ORACLE.km ]]; then
process_product "- KM Oracle" "Le script ayant créé ce document ne sait pas récupérer la version !" "$inst_root"
fi
fi
fi
product="BO WebIntelligence"
inst_root=$( find_inst_root SetUp 1 ${soft_dir_appli}/webi )
if [[ -n "$inst_root" ]]; then
version=$( awk '$1 == "version" { print $NF }' $inst_root/SetUp/WebiFileId.txt 2>/dev/null )
if [[ -n "$version" ]]; then
keys=
keys=$( cat $inst_root/SetUp/licence.txt )
process_product "$product" "$version" "$inst_root" "$keys"
fi
fi
product="EMC ControlCenter"
inst_root=$( awk -F = '$1 == "tools_path" { print $2 }' /var/emc/.eccrc 2>/dev/null )
if [[ -x $inst_root/exec/mstragent ]]; then
version=$( $inst_root/exec/mstragent -ver | awk '$1 == "VERS_EXTERNALID" && $2 == "=" { print $3 }' )
process_product "$product" "$version" "$inst_root"
fi
product="EMC PowerPath"
package=EMCpower.LINUX
inst_root=$( install_dirs $package )
if whence powermt >/dev/null 2>&1; then
version=$( powermt version | sed 's:^.*ersion \(.*\)$:\1:' )
keys=
keys=$( emcpreg -list 2>/dev/null | awk '$1 == "Key" { print $2 }' )
process_product "$product" "$version" "$inst_root" "$keys"
fi
product="EMC Solutions Enabler SYMCLI"
inst_root=$( ls -l /usr/symcli 2>/dev/null | sed 's:.*-> ::' )
if whence symcli >/dev/null 2>&1; then
version=$( SYMCLI_OUTPUT_MODE=xml symcli 2>/dev/null | grep "<SYMCLI " | get_xml_attribute version | sed 's|^V||; s|^v||' )
keys=
keys=$( cat /var/symapi/config/symapi_licenses.dat 2>/dev/null )
process_product "$product" "$version" "$inst_root" "$keys"
fi
product="IBM Tivoli Agent"
inst_root=${soft_dir_appli}/tma
if [[ -f $inst_root/lcf/dat/1/last.cfg ]]; then
versionPackage=$( awk -F= '$1=="lcfd_version" { print $2 }' $inst_root/lcf/dat/1/last.cfg )
case "$versionPackage" in
100)
version=3.7.1 ;;
410*)
version=4.1.0 ;;
*)
version= ;;
esac
if [[ -n "$version" ]]; then
process_product "$product" "$version" "$inst_root"
fi
fi
product="IBM WebSphere MQ<br>(ex-MQSeries)"
package="mqseries-*"
inst_root=$( install_dirs "$package" )
version=$( rpm -qi "$package" 2>/dev/null | awk -F: '/^Version/{ print $2 }' )
if [[ -n "$version" ]]; then
keys=""
if [[ -f /opt/mqm/lib/amqpcert.lic ]]; then
keys=$( awk -F= '$1 == "ProductPassword" { key = $2 } END { printf key " (permanente)" }' /opt/mqm/lib/amqpcert.lic )
elif [[ -f /opt/mqm/lib/amqtcert.lic ]]; then
keys=$( awk -F= '$1 == "ProductPassword" { key = $2 } $1 == "LicenseEndDate" { enddate = $2 } END { printf key " (temporaire -> " enddate ")" }' /opt/mqm/lib/amqtcert.lic )
fi
process_product "$product" "$version" "$inst_root" "$keys"
fi
product="JOnAs"
package="jonas-*"
inst_root=$( install_dirs "$package" )
if [[ -n "$inst_root" ]]; then
version=$( rpm -qi "$package" | awk -F':' '/Version/{print $2}' )
process_product "$product" "$version" "$inst_root"
fi
product="MySQL"
package="mysql-*"
inst_root=$( install_dirs "$package" )
if [[ -n "$inst_root" ]]; then
version=$( rpm -qi "$package" | awk -F':' '/Version/{print $2}' )
process_product "$product" "$version" "$inst_root"
fi
product="Veritas NetBackup"
inst_root=$( find_inst_root bpbackup 4 ${soft_dir_appli}/netback*/v* )
version=$( cat /usr/openv/netbackup/bin/version 2>/dev/null | awk '{ print $2 }' )
if [[ -n "$version" ]]; then
typeset -u label
type=Agent
sed 's/#.*//; /^[[:blank:]]*$/d' $inst_root/openv/netbackup/bp.conf | while read Ligne; do
label=$( echo "$Ligne" | sed "s/=/ = /" | awk '{ print $1 }' )
host=$( echo "$Ligne" | sed "s/=/ = /" | awk '{ print $3 }' )
[[ "$label" != SERVER ]] && continue
address=$( host $host 2>/dev/null | awk '{ sub(",.*", ""); print $NF}' )
[[ -z "$address" ]] && address=$host
if netstat -in | grep -q " $address "; then
# local address -> Slave (or Master)
type="Slave (or Master)"
break
fi
done
process_product "$product $type" "$version" "$inst_root"
fi
product="OmniVision"
inst_root=$( find_inst_root bin 1 ${soft_dir_appli}/OmniVision )
if [[ -n "$inst_root" ]]; then
version=$( awk '$2=="OMV_VERSION" { sub(".$", "") ; print $NF }' $inst_root/log/setup_install.log 2>/dev/null )
if [[ -z "$version" ]]; then
version=$( egrep -h " PI-OMV-.*-.*.SIG " $inst_root/Outils/InstallOMV.log $inst_root/OmniVision/Outils/InstallOMV.log \
2>/dev/null | sed "s/.*-OMV-//; s/-.*//; s/OMV//; s/C//; s/./&./g; s/\.\$//" )
fi
if [[ "$version" = "" ]]; then
ls /*/signatures/PI-OMV-*-*.SIG 2>/dev/null | while read FichSign
do
version=$( echo $FichSign | sed "s/.*-OMV-//; s/-.*//; s/OMV//; s/C//; s/./&./g; s/\.\$//" )
done
fi
[[ -z "$version" ]] && version="(non lisible)"
process_product "$product" "$version" "$inst_root"
fi
product="Oracle"
find ${soft_dir}/oracle -name oerr 2>/dev/null | while read file; do
inst_root=$( dirname $( dirname $file ) )
if [[ -x $inst_root/bin/exp ]]; then
version=$( $inst_root/bin/exp help=y 2>&1 | awk '/Release/ { sub (".*Release ", ""); sub (".0$", "", $1); print $1 }' )
process_product "$product" "$version" "$inst_root"
fi
done
product="Orsyp Dollar Universe"
bin=$( find_inst_root FTECOM 0 ${soft_dir}/dollaru )
if [[ -n "$bin" ]]; then
inst_root=${bin%/*}
version=$( $bin/exec/uxversion 2>/dev/null | awk '$1 == "Version" { print $2, $3 }' | sed 's:^v::' )
if [[ -n "$version" ]]; then
keys=
keys=$( grep -E "^[^#].*:DQM|^[^#].*:KMU|^[^#].*:UNI" $bin/mgr/u_fali01.txt )
process_product "$product" "$version" "$inst_root" "$keys"
fi
fi
product="Postgres SQL"
package="postgresql-*"
inst_root=$( install_dirs "$package" )
if [[ -n "$inst_root" ]]; then
version=$( rpm -qi "$package" | awk -F':' '/Version/{print $2}' )
process_product "$product" "$version" "$inst_root"
fi
product="SOPRA AetP"
inst_root=$( find_inst_root aepadm 2 ${soft_dir_appli}/aetp )
version=$( $inst_root/bin/adm3 2>/dev/null | sed "s/-.*//; s/.* //" )
if [[ -n "$version" ]]; then
keys=
worklist=$inst_root/dat/data/srginfo.cal
while [[ -n "$worklist" ]]; do
file=$( echo "$worklist" | awk '{ print $1 }' )
worklist=$( echo "$worklist" | awk '{ print $2 }' )
keys=$( awk '$1=="UTCMGA" { print $3 }' $file )
[[ -n "$keys" ]] && break
worklist=$( echo $worklist $( awk '$1 == "C" { print $4 }' $file ) )
done
process_product "$product" "$version" "$inst_root" "$keys"
fi
product="SOPRA CFT"
bin=$( find_inst_root CFTUTIL 0 ${soft_dir_appli}/cft )
inst_root=${bin%/*/*}
version=$( $bin about 2>/dev/null | awk '$1 ~ /^CFT/ && $2 == "Version" { print $3, "(" $4 ")" }' )
if [[ -n "$version" ]]; then
keys=
if [[ -f $inst_root/fildat/cft_parm.d ]]; then
keys=$( dd if=$inst_root/fildat/cft_parm.d ibs=1 skip=812 count=26 2>/dev/null; echo )
elif [[ -f $inst_root/fildat/cft_parm ]]; then
keys=$( dd if=$inst_root/fildat/cft_parm ibs=1 skip=2914 count=41 2>/dev/null; echo )
fi
process_product "$product" "$version" "$inst_root" "$keys"
fi
product="StreamWeaver"
inst_root=$( find_inst_root STREAMW.MSG 3 ${soft_dir_appli}/sw* )
version=$( grep version $inst_root/pbsssw/bin/STREAMW.MSG 2>/dev/null | sed "s:.*version ::; s: .*::" )
if [[ -n "$version" ]]; then
keys=
keys=$( grep PBSSTTY $inst_root/pbsssw/bin/swvrexe | sed -e 's/#.*//; /^ *$/d' -e 's/.*=//' )
process_product "$product" "$version" "$inst_root" "$keys"
fi
product="Time Navigator"
inst_root=$( find_inst_root Conf 1 ${soft_dir_appli}/tina )
version=$( awk '$1 == "version:" { print $2 }' $inst_root/Conf/version.txt 2>/dev/null )
if [[ -n "$version" ]]; then
process_product "$product" "$version" "$inst_root"
fi
cat <<EOF >>$HTML_file
</table>
</body>
</html>
EOF
if [[ -n "$mailuser" ]]; then
send_mail "$mailuser"
fi |