diff options
author | Olivier Mehani <shtrom@ssji.net> | 2017-07-22 12:33:59 +0200 |
---|---|---|
committer | Olivier Mehani <shtrom@ssji.net> | 2017-07-22 12:33:59 +0200 |
commit | 8fe5cdc45f8b35044da5a431369bc313411fbfd4 (patch) | |
tree | f0761ee242d9ae8bcfe2695756be9e75c351fbfb | |
parent | 7bc2809bbac5dd7d9336d254a7511a0dc1749c8d (diff) |
wip install rtminstall_rtm
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
-rwxr-xr-x[-rw-r--r--] | openbsd/install_rtm-freebsd.sh | 151 |
1 files changed, 79 insertions, 72 deletions
diff --git a/openbsd/install_rtm-freebsd.sh b/openbsd/install_rtm-freebsd.sh index c6b5a28..ae359d4 100644..100755 --- a/openbsd/install_rtm-freebsd.sh +++ b/openbsd/install_rtm-freebsd.sh @@ -8,7 +8,10 @@ RELEASE_DATE="2016-02-25" LC_ALL=POSIX +CRONTAB=/var/cron/tabs/root + DIR="/usr/local/rtm" +DIR="${PWD}${DIR}" # XXX: deleteme DIR_SCRIPTS_DAILY="${DIR}/scripts/daily" DIR_SCRIPTS_MIN="${DIR}/scripts/min" DIR_SCRIPTS_HOUR="${DIR}/scripts/hour" @@ -26,12 +29,12 @@ if [ "$SCREENDIR" != "" ]; then SCREEN="$SCREENDIR -d -m"; fi SCRIPTDIR="$DIR/scripts" # add user ovh and group ovh to run rtm on it: -if [ -z "`pw usershow ovh 2>\/dev\/null`" ]; then - pw useradd ovh -d /nonexistent -c "OVH user for RTM running" -s /usr/bin/false -P no +if [ -z "`id ovh 2>\/dev\/null`" ]; then + useradd -d /nonexistent -c "OVH user for RTM running" -s /usr/bin/false ovh fi -OVHUID=`pw usershow ovh | cut -d: -f3` -OVHGID=`pw usershow ovh | cut -d: -f4` +OVHUID=`id ovh | sed -n 's/^uid=\([0-9]\+\).*/\1/p'` +OVHGID=`id ovh | sed -n 's/^.* gid=\([0-9]\+\).*/\1/p'` # @@ -39,14 +42,14 @@ OVHGID=`pw usershow ovh | cut -d: -f4` generate_update_report() { echo "Generating update-report.pl..." cat << EOF > $RTM_REPORT -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; EOF cat <<'EOF' >> $RTM_REPORT -#!/usr/local/bin/perl +#!/usr/bin/perl use strict; use Socket; @@ -89,7 +92,7 @@ EOF for scr in "$DIR_SCRIPTS_DAILY", "$DIR_SCRIPTS_MIN", "$DIR_SCRIPTS_HOUR"; do if ! echo "$scr" | grep -q '^/usr/local/'; then echo "invalid script directory: $scr" >&2 - exit 1 + # XXX uncoment me exit 1 fi done # Remove old scripts dirs so there are no unwanted scripts hanging @@ -107,7 +110,7 @@ if [ ! -e "$DIR/etc" ]; then mkdir -p "$DIR/etc"; fi get_interface_ip() { iface=$1 - ifconfig $iface 2>\/dev\/null | grep "inet.*netmask" | awk '{print $2}' | egrep '[0-9]+(\.[0-9]+){3}' + ifconfig $iface 2>\/dev\/null | grep "inet.*netmask" | awk '{print $2}' | egrep '[0-9]+(\.[0-9]+){3}' | head -n1 } mainif="$(netstat -rn|grep "^default" | awk '{print $NF}'|sort|uniq|head -n1)" @@ -141,7 +144,7 @@ fi generate_check() { echo "Generating $DIR_SCRIPTS_MIN/check.pl..." cat << EOF > $DIR_SCRIPTS_MIN/check.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -216,7 +219,7 @@ EOF generate_raid() { echo "Generating $DIR_SCRIPTS_HOUR/raid.pl..." cat << EOF > $DIR_SCRIPTS_HOUR/raid.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -325,7 +328,7 @@ if (map {$_ =~ /3ware/i} @sysctl) { # parse tw_cli basis view: foreach my $line (@twCliInfo) { - if ($line =~ m/Controller (\d+):/) { push @controlers, $1;} + if ($line =~ m/Controller (\d+)[:=]/) { push @controlers, $1;} if ($line =~ /^c(\d+)\s+(\S+)\s+/) { push @controlers, $1; $models{$1} = $2;} } @@ -335,12 +338,12 @@ if (map {$_ =~ /3ware/i} @sysctl) { # parse tw_cli detailed info: foreach my $line (@twCliInfo) { - if ( $line =~ m/Unit\s(\d):\s+(RAID\s+\d+|[^\s]+)\s([^\s]+)\s([^\s]+)[^:]+:\s(.+)/) { + if ( $line =~ m/Unit\s(\d)[:=]\s+(RAID\s+\d+|[^\s]+)\s([^\s]+)\s([^\s]+)[^:=]+[:=]\s(.+)/) { print "hHW_SCSIRAID_UNIT_c$controler\_u$1_capacity|$3 $4\n"; print "hHW_SCSIRAID_UNIT_c$controler\_u$1_type|$2\n"; print "hHW_SCSIRAID_UNIT_c$controler\_u$1_status|$5\n"; } - if ( $line =~ m/Port\s(\d+):\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)[^:]+:\s([^\(]+)\(unit\s(\d+)/) { + if ( $line =~ m/Port\s(\d+)[:=]\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)\s([^\s]+)[^:=]+[:=]\s([^\(]+)\(unit\s(\d+)/) { print "hHW_SCSIRAID_PORT_c$controler\_u$8_phy$1_capacity|$5 $6\n"; print "hHW_SCSIRAID_PORT_c$controler\_u$8_phy$1_model|$2 $3\n"; print "hHW_SCSIRAID_PORT_c$controler\_u$8_phy$1_status|$7\n"; @@ -389,7 +392,7 @@ if (map {$_ =~ /3ware/i} @sysctl) { # check UNIT number: $count = 0; - while(my $a = grep {$_ =~ /^mpt$count: (\d+) Active Volume/i} @dmesg) { + while(my $a = grep {$_ =~ /^mpt$count[:=] (\d+) Active Volume/i} @dmesg) { $units{$count}{volumeCount} = $a; $count++; } @@ -398,8 +401,8 @@ if (map {$_ =~ /3ware/i} @sysctl) { foreach my $u (keys %units){ foreach(@dmesg){ - /^mpt$u:\s*(\d+).*Drive Members/i and $units{$u}{driveCount} = $1; - /^mpt$u: Capabilities: \( (.*?) \)$/i and $units{$u}{capabilities} = $1; + /^mpt$u[:=]\s*(\d+).*Drive Members/i and $units{$u}{driveCount} = $1; + /^mpt$u[:=] Capabilities: \( (.*?) \)$/i and $units{$u}{capabilities} = $1; } # foreach volume: (vol0, vol1, ...) @@ -422,16 +425,16 @@ if (map {$_ =~ /3ware/i} @sysctl) { } - next unless /mpt$u:vol$volume/; + next unless /mpt$u[:=]vol$volume/; # status: - if(/: Status \( (.*?) \)$/ and not $lastFlags){ $lastFlags = uc $1; } + if(/[:=] Status \( (.*?) \)$/ and not $lastFlags){ $lastFlags = uc $1; } # state: - if(/: RAID-\d+ - (.*)$/i){ $lastVolStatus = uc $1;} + if(/[:=] RAID-\d+ - (.*)$/i){ $lastVolStatus = uc $1;} # sync percentage: - if(/: (\d+) of (\d+) blocks remaining/i){ $lastSyncPercent = int($1/$2 * 100); } + if(/[:=] (\d+) of (\d+) blocks remaining/i){ $lastSyncPercent = int($1/$2 * 100); } # we search backwards only till this line: last if /Volume Status Changed/; @@ -450,11 +453,11 @@ if (map {$_ =~ /3ware/i} @sysctl) { my $lastFlags = ''; foreach(@revDmesg) { - next unless /^\(mpt$u:vol$volume:$d\):/; + next unless /^\(mpt$u:vol$volume:$d\)[:=]/; - if(/\(mpt$u:vol$volume:$d\): Status \( (.*) \)$/ and not $lastFlags){ + if(/\(mpt$u:vol$volume:$d\)[:=] Status \( (.*) \)$/ and not $lastFlags){ $lastFlags = uc $1; - } elsif(/\(mpt$u:vol$volume:$d\): Physical.* Pass-thru \(mpt$u:(\d+):(\d+):(\d+)\)\s*$/){ + } elsif(/\(mpt$u:vol$volume:$d\)[:=] Physical.* Pass-thru \(mpt$u:(\d+):(\d+):(\d+)\)\s*$/){ my ($bus, $target, $lun) = ($1, $2, $3); foreach(@camcontrolDevlist){ /<(.*?)>\s+at scbus$bus target $target lun $lun/ @@ -465,9 +468,9 @@ if (map {$_ =~ /3ware/i} @sysctl) { print "hHW_SCSIRAID_PORT_mpt$u\_vol-id$volume\_phy$d\_capacity|".(normalize($1*$2))."\n" if ($c =~ /^(\d+),\s*(\d+)$/); # none - } elsif(/\(mpt$u:vol$volume:$d\): Volume Status Changed.*$/){ + } elsif(/\(mpt$u:vol$volume:$d\)[:=] Volume Status Changed.*$/){ # none - } elsif(/\(mpt$u:vol$volume:$d\): (.*)$/ and not $lastStatus){ + } elsif(/\(mpt$u:vol$volume:$d\)[:=] (.*)$/ and not $lastStatus){ $lastStatus = uc $1; } @@ -517,7 +520,7 @@ EOF generate_smart() { echo "Generating $DIR_SCRIPTS_HOUR/smart.pl..." cat << EOF > $DIR_SCRIPTS_HOUR/smart.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -543,7 +546,7 @@ sub parse_smartctl_line { if($line =~ /^SMART Attributes Data Structure revision number: (\d+\w*)$/) { print "hINFO_RTM_SMART_versionnotcompatible|$1\n" - unless $1 eq '10'; + unless $1 eq '16'; } if($line =~ /^SMART overall-health.*result: (\w+)$/) { @@ -582,11 +585,11 @@ sub parse_smartctl_line { } sub check_ide { - chomp(my $d = `\/sbin\/sysctl -n kern.disks 2>\/dev\/null`); + chomp(my $d = `\/sbin\/sysctl -n hw.disknames 2>/dev/null | sed s/:.*/c/`); my @diskList = split ' ', $d; foreach my $dev (@diskList) { - next if $dev =~ /^ad/; + next if $dev =~ /^sd/; chomp(my @smartctlData = `\/usr\/local\/sbin\/smartctl -a \/dev\/$dev 2>\/dev\/null`); foreach my $line (@smartctlData) { parse_smartctl_line($line, $dev); @@ -595,7 +598,7 @@ sub check_ide { } sub check_scsi { - chomp(my $d = `\/sbin\/sysctl -n kern.disks 2>\/dev\/null`); + chomp(my $d = `\/sbin\/sysctl -n hw.disknames 2>/dev/null | sed s/:.*/c/`); my @diskList = split ' ', $d; foreach my $dev (@diskList) { @@ -681,7 +684,7 @@ EOF generate_listen_ports() { echo "Generating $DIR_SCRIPTS_HOUR/listen_ports.pl..." cat << EOF > $DIR_SCRIPTS_HOUR/listen_ports.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -697,12 +700,20 @@ use utf8; # for \x{nnn} regex my (@netstatTable, $line, $socketInfo, $procInfo, @tempTable, $port, $pid, $procName, $ip, $cmdline, $exe, @status, $statusLine, $uid, @passwd, $passwdLine, %passwdHash); -chomp(@netstatTable = `\/usr\/bin\/sockstat -lP tcp \| \/usr\/bin\/awk \'NR>1 {print \$1"|"\$2"|"\$3"|"\$6;}\'`); +# FreeBSD sockstat has the following columns: USER, COMMAND, PID, FD, PROTO, LOCAL ADDRESS, REMOTE ADDRESS +# chomp(@netstatTable = `\/usr\/bin\/sockstat -lP tcp \| \/usr\/bin\/awk \'NR>1 {print \$1"|"\$2"|"\$3"|"\$6;}\'`); +# OpenBSD fstat has the following columns: USER, CMD, PID, FD, MOUNT, INUM, MODE, R/W, SZ|DV +# TCP sockets are listed as follows, from MOUNT onwards +# * internet stream tcp 0x0 *:8080 +# * internet stream tcp 0x0 91.121.XXX.YYY:6392 --> AAA.BBB.CCC.DDD:4949 +# * internet6 stream tcp 0x0 [::1]:953 +# * internet6 stream tcp 0x0 [2001:41d0:1:XXX::YYY]:443 <-- [2001:AAA::BBB]:49344 +chomp(@netstatTable = `\/usr\/bin\/fstat \| \/usr\/bin\/awk \'NR>1 { if (\$7 == "tcp") { print \$1"|"\$2"|"\$3"|"\$9;}}\'`); map {s/\|\*:/\|0.0.0.0:/; s/:(\d+)$/\|$1/;} @netstatTable; # change to behave as on linux systems # $netstatTable[x] = 'bind|named|517|127.0.0.1|953' # username <=> uid transformation table -open(FILE, "/etc/passwd"); +open(FILE, "/etc/master.passwd"); chomp(my @passwd = <FILE>); close(FILE); my %passwdHash; @@ -766,7 +777,7 @@ EOF generate_usage() { echo "Generating $DIR_SCRIPTS_MIN/usage.pl..." cat << EOF > $DIR_SCRIPTS_MIN/usage.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -811,8 +822,8 @@ sub send_hdd_usage { } sub get_loadavg { - chomp(my $load = `\/sbin\/sysctl vm.loadavg 2>\/dev\/null`); - $load =~ s/.*{\s*(.*)\s*}.*/$1/; + chomp(my $load = `\/sbin\/sysctl -n vm.loadavg 2>\/dev\/null`); + $load =~ s/\s*(.*)\s*.*/$1/; chomp(my @load = split(/\s/, $load)); return ('loadavg1' => $load[0], 'loadavg2' => $load[1], @@ -826,7 +837,7 @@ sub get_cpu_usage { @cpu_usage2 = (0, 0, 0, 0); chomp(my $cpu_time = `\/sbin\/sysctl kern.cp_time 2>\/dev\/null`); - if ($cpu_time =~ /^kern.cp_time:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/i) { + if ($cpu_time =~ /^kern.cp_time[=:]\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/i) { # CPU USAGE LINUX: user, nice, system, idle # CPU USAGE FreeBSD: user, nice, system, interrupt, idle @cpu_usage2 = ($1, $2, $3, $5); @@ -837,7 +848,7 @@ sub get_cpu_usage { if(-e $CPU_STATS_FILE) { open(TMP, "+< $CPU_STATS_FILE") or die "$CPU_STATS_FILE: $!\n"; while (<TMP>) { - if (/^kern.cp_time:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/i) { + if (/^kern.cp_time[=:]\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/i) { @cpu_usage1 = ($1, $2, $3, $5); } } @@ -863,7 +874,7 @@ sub get_cpu_usage { sub get_mem_swap_usage { my %mem_swap_usage = (); - chomp(my @swap = `\/sbin\/swapctl -kl \| grep "\/dev"`); + chomp(my @swap = `\/sbin\/swapctl -kl \| grep "^/"`); my %swap; map { /^\/dev.*\s+(\d+)\s+(\d+)\s*$/; $swap{'total'}+=($1*1024); $swap{'used'}+=($2*1024);} @swap; # when we have more than one swap partition @@ -947,7 +958,7 @@ EOF generate_usage_root() { echo "Generating $DIR_SCRIPTS_MIN/usage-root.pl..." cat << EOF > $DIR_SCRIPTS_MIN/usage-root.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -980,9 +991,9 @@ sub send_top_rss { sub get_processes { #chomp(my @rtm_sids = `ps --no-headers -C rtm -o sess | sort -n | uniq`); - chomp(my @rtm_sids = `\/bin\/ps -o sid,command \| \/usr\/bin\/grep "rtm" \| \/usr\/bin\/sort -n \| \/usr\/bin\/uniq \| \/usr\/bin\/grep -v grep`); + chomp(my @rtm_sids = `\/bin\/ps -o sess,command \| \/usr\/bin\/grep "rtm" \| \/usr\/bin\/sort -n \| \/usr\/bin\/uniq \| \/usr\/bin\/grep -v grep`); #my @ps_output = `ps --no-headers -A -o sess,state,command`; - chomp(my @ps_output = `\/bin\/ps -A -o sid,state,command`); + chomp(my @ps_output = `\/bin\/ps -A -o sess,state,command`); shift @ps_output; # shift headers :) my $active = 0; @@ -1023,7 +1034,7 @@ EOF generate_hwinfo() { echo "Generating $DIR_SCRIPTS_HOUR/hwinfo.pl..." cat << EOF > $DIR_SCRIPTS_HOUR/hwinfo.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -1056,18 +1067,18 @@ sub get_cpu_info { chomp(my @cpuinfo = `\/sbin\/sysctl hw dev.cpu 2>\/dev\/null`); foreach(@cpuinfo) { - if (/^hw\.model:\s*(.*)$/) { + if (/^hw\.model[:=]\s*(.*)$/) { $cpu_info{'cpu_name'} = $1; } - if (/^dev\.cpu\.\d{1,2}\.freq:\s*(.*)$/) { + if (/^hw\.cpuspeed[:=]\s*(.*)$/) { $cpu_info{'cpu_mhz'} = $1; } # TODO - FreeBSD no CPU cache found! # if ($_ =~ /^cache size/) { -# s/cache size\s+:\s*//g; +# s/cache size\s+[:=]\s*//g; # $cpu_info{'cpu_cache'} = $_; # } - if (/^hw\.ncpu:\s*(.*)$/){ + if (/^hw\.ncpu[:=]\s*(.*)$/){ $cpu_info{'cpu_no'} = $1; } @@ -1081,19 +1092,16 @@ sub get_cpu_info { sub get_lspci_info { my %lspci_info = (); - chomp(my @pciconf = `\/usr\/sbin\/pciconf -l 2>\/dev\/null`); + chomp(my @pciconf = `\/usr\/sbin\/pcidump -l 2>\/dev\/null`); if ($? == 0) { foreach (@pciconf) { - if(/^\S+@\S+:(\S+):\s+class=0x(\S+)\s+card=0x(\S{4})(\S{4})\s+chip=0x(\S{4})(\S{4})\s+rev=0x(\S+)\s+hdr=0x(\S+)\s*$/){ + #if(/^\S+@\S+:(\S+):\s+class=0x(\S+)\s+card=0x(\S{4})(\S{4})\s+chip=0x(\S{4})(\S{4})\s+rev=0x(\S+)\s+hdr=0x(\S+)\s*$/){ + if(/^(\S+:S+:S+):\s+(\S+)\s+(\S+)\s+(\S+)/){ # $1 - selector - # $2 - class - # $3 - subvendor device id - # $4 - subvendor id - # $5 - vendor device id - # $6 - vendor id - # $7 - revision - # $8 - describes the header type (see man for pciconf) - my $value = "$6:$5"; + # $2 - vendor + # $3 - vendor device + # $4 - bus + my $value = "$2:$3"; my $selector; $_ = $1; while (/(\w+)(\W+)?/g) {$selector .= length($1)==1?"0$1$2":"$1$2";} @@ -1117,7 +1125,7 @@ EOF generate_hwinfo_root() { echo "Generating $DIR_SCRIPTS_HOUR/hwinfo-root.pl..." cat << EOF > $DIR_SCRIPTS_HOUR/hwinfo-root.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -1228,7 +1236,7 @@ sub get_hdd_info { my $disks = get_disks(); foreach my $disk (@$disks){ - if($disk =~ /^da/){ #SCSI + if($disk =~ /^sd/){ #SCSI # TODO # SCSI/SATA not supported for now under FreeBSD next; @@ -1239,7 +1247,7 @@ sub get_hdd_info { # next if grep {$_ =~ "^$disk at mpt"} @dmesg; # $hdd_info{'model'}{$disk} = ''; - } elsif($disk =~ /^ad/) { #IDE + } elsif($disk =~ /^wd/) { #IDE # atacontrol list chomp(my @ret = `atacontrol list`); foreach(@ret){ @@ -1279,7 +1287,7 @@ sub normalize { } sub get_disks { - chomp(my $d = `sysctl -n kern.disks 2>\/dev\/null`); + chomp(my $d = `sysctl -n hw.disknames 2>/dev/null | sed s/:.*/c/`); my @disks = split (/\s+/, $d); return \@disks; } @@ -1296,7 +1304,7 @@ EOF generate_hddinfo() { echo "Generating $DIR_SCRIPTS_MIN/hddinfo.pl..." cat << EOF > $DIR_SCRIPTS_MIN/hddinfo.pl -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -1314,10 +1322,10 @@ use strict; sub send_hdd_status { my @ide; - chomp(my $i = `sysctl -n kern.disks 2>\/dev\/null`); - map { push @ide, $_ if /^ad/} split(/\s+/,$i); + chomp(my $i = `sysctl -n hw.disknames 2>/dev/null | sed s/:.*/c/`); + map { push @ide, $_ if /^[ws]d/} split(/\s+/,$i); - chomp(my @status = `dmesg 2>\/dev\/null \| grep -i \"error\\\|drive not ready\" \| grep -i \"\^ad\" \| cut -f 1 -d \":\" \| sort \| uniq`); + chomp(my @status = `dmesg 2>\/dev\/null \| grep -i \"error\\\|drive not ready\" \| grep -i \"\[ws]d\" \| cut -f 1 -d \":\" \| sort \| uniq`); foreach my $ide (@ide) { my $error = 0; @@ -1333,7 +1341,7 @@ sub send_hdd_status { # check of scsi errors - chomp(my @scsi = `sysctl -n kern.disks 2>\/dev\/null \| grep \"\^da\"`); + chomp(my @scsi = `sysctl -n hw.disknames 2>/dev/null | sed s/:.*/c/ \| grep \"\^da\"`); my $possible_error; if (scalar @scsi > 0) { @@ -1369,10 +1377,10 @@ sub send_hdd_temp { sub get_hdd_temp { my %hdd_temp = (); - chomp(my @ide = `sysctl -n kern.disks 2>\/dev\/null`); + chomp(my @ide = `sysctl -n hw.disknames 2>/dev/null | sed s/:.*/c/`); foreach (@ide) { - if (/^ad/) { + if (/^[ws]d/) { chomp(my $temp = `\/usr\/local\/sbin\/smartctl -a \/dev\/$_ \| grep "Temperature" 2>\/dev\/null`); my $ide = $_; if ($? == 0) { @@ -1405,7 +1413,7 @@ EOF generate_rtm() { echo "Generating rtm.pl..." cat << EOF > $RTM_PL -#! /usr/local/bin/perl +#! /usr/bin/perl # version: $VERSION ($RELEASE_DATE) \$ENV{"LC_ALL"} = "POSIX"; @@ -1707,7 +1715,7 @@ EOF get_interface_ip() { iface=$1 - ifconfig $iface 2>\/dev\/null | grep "inet.*netmask" | awk '{print $2}' | egrep '[0-9]+(\.[0-9]+){3}' + ifconfig $iface 2>\/dev\/null | grep "inet.*netmask" | awk '{print $2}' | egrep '[0-9]+(\.[0-9]+){3}' | head -n1 } mainif="$(netstat -rn|grep "^default" | awk '{print $NF}'|sort|uniq|head -n1)" @@ -1787,7 +1795,6 @@ ln -s $RTM_PL $RTM_SH rm -rf /rpms -CRONTAB=/etc/crontab if [ -z "`cat $CRONTAB | grep \"$RTM_SH\"`" ]; then minute=`perl -e 'print ((rand()*100)%60)'` CRONTABLINE='*/1 * * * * root '$RTM_SH' '$minute' > /dev/null 2> /dev/null' @@ -1839,7 +1846,7 @@ echo "on breakdown:" echo "CHECK_vm|1" echo "CHECK_oops|1" echo -echo "for exemple:" +echo "for example:" echo "# $DIR_SCRIPTS_MIN/check.pl" $DIR_SCRIPTS_MIN/check.pl echo "" |