You are not logged in.
I have SEVERAL archlinux machines, and like to be able to view alot of data very fast, so I wrote another script to help me with that. Thought I'd share it if anyone else was interested.
#!/bin/bash
# Created by Crouse - usalug.org
# Program Name: alis - (A)rch (L)inux (I)nformation (S)cript
# updated 07-28-2008 version .25
# updated 09-12-2007 version .10
#
# REQUIRES: lynx, sed, awk
#
clear
echo "ALIS: (A)rch (L)inux (I)nformation (S)cript"
echo "Attempting to get EXTERNAL IP address. Please wait . . . . ."
machine_external_ip=`lynx -dump http://www.whatismyip.com | awk '/Your IP Address Is/{print $5}'`
sleep 1
clear
if [[ -z $( type -p lynx ) ]]; then echo -e "The program lynx is required to find external IP. Please install lynx." ;fi
num_cpus=`cat /proc/cpuinfo | grep -c "model name"`
machine_cpu=`cat /proc/cpuinfo | grep -m 1 "model name" | cut -d: -f2`
machine_mhz=`cat /proc/cpuinfo | grep -m 1 "cpu MHz" | cut -d: -f2`
machine_cpuinfo=`uname -mp`
todays_date=`date +"%D %r"`
machine_uptime=`uptime`
machine_ram=`cat /proc/meminfo | grep -m 1 "MemTotal:" | cut -d: -f2 | sed 's/^[ \t]*//'`
machine_video=`lspci | grep -m 1 "VGA" | cut -d: -f3 | sed 's/^[ \t]*//'`
machine_eth_card=`lspci | grep -m 1 "Ethernet" | cut -d: -f3 | sed 's/^[ \t]*//'`
machine_audio_controller=`lspci | grep -m 1 "audio" | cut -d: -f3 | sed 's/^[ \t]*//'`
arch_damons=`grep "DAEMONS=" /etc/rc.conf `
last_logins=`last | head`
eth0info=`ifconfig eth0 | grep "inet addr:" | sed 's/inet addr/Local IP/g' | sed 's/^[ \t]*//;s/[ \t]*$//'`
machine_gateway=`route | grep -m 1 "default" | awk '{print $2}'`
machine_kernel=`pacman -Qi kernel26 | grep -m 1 "Version" | cut -d: -f2 | sed 's/^[ \t]*//'`
machine_filesystem=`fdisk -l`
machine_filesystem2=`cat /proc/mounts | sort | grep -v "none" | grep -v "rootfs" | awk '{print $1,$2,$3}'`
machine_users=`w -f`
pacman_cache_count=`ls /var/cache/pacman/pkg | wc -l`
pacman_cache_size=`du -h /var/cache/pacman/pkg`
pacman_version=`pacman -Qi pacman | grep -m 1 "Version" | cut -d: -f2 | sed 's/^[ \t]*//'`
echo "ALIS: (A)rch (L)inux (I)nformation (S)cript ver 1.0 $todays_date "
echo " "
echo "[ARCH INFO]"
echo "MACHINE NAME: $HOSTNAME "
echo "ARCH KERNEL VERSION: $machine_kernel"
echo "PACMAN VERSION: $pacman_version"
echo "PACMAN CACHE SIZE: $pacman_cache_size -- clear cache with pacman -Scc"
echo "PACMAN CACHE COUNT: $pacman_cache_count packages"
echo "$arch_damons"
echo " "
echo "[HARDWARE]"
echo "CPU INFO: Qty=$num_cpus $machine_cpuinfo"
echo "RAM INFO: $machine_ram"
echo "VIDEO CARD: $machine_video"
echo "AUDIO CONTROLLER: $machine_audio_controller"
echo "ETHERNET CARD: $machine_eth_card"
echo " "
echo "[NETWORK]"
echo "EXTERNAL IP: $machine_external_ip"
echo "GATEWAY: $machine_gateway"
echo "ETH0: $eth0info"
echo " "
echo "[FILE SYSTEM]"
echo "$machine_filesystem2"
echo " "
df -h | sort -r | grep -v "none"
echo "$machine_filesystem"
echo " "
echo "[ACTIVE USER STATUS]"
echo "$machine_users"
echo " "
echo "[LAST 10 LOGINS]"; echo "$last_logins"
echo " "
echo "UPTIME: $machine_uptime"
echo " "
exit 0
Here is a sample output:
ALIS: (A)rch (L)inux (I)nformation (S)cript ver 1.0 07/29/08 02:07:06 AM
[ARCH INFO]
MACHINE NAME: VistaCrusher5
ARCH KERNEL VERSION: 2.6.25.11-1
PACMAN VERSION: 3.1.4-1
PACMAN CACHE SIZE: 4.4G /var/cache/pacman/pkg -- clear cache with pacman -Scc
PACMAN CACHE COUNT: 1640 packages
DAEMONS=(syslog-ng @network @netfs @hal @openntpd @gdm @sshd @cups @crond !foldingathome)[HARDWARE]
CPU INFO: Qty=2 i686 Intel(R) Pentium(R) 4 CPU 3.20GHz
RAM INFO: 514528 kB
VIDEO CARD: nVidia Corporation NV30GL [Quadro FX 1000] (rev a2)
AUDIO CONTROLLER: Intel Corporation 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller (rev 02)
ETHERNET CARD: Intel Corporation 82547GI Gigabit Ethernet Controller[NETWORK]
EXTERNAL IP: 216.1removed
GATEWAY: 192.168.1.1
ETH0: Local IP:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0[FILE SYSTEM]
/dev/root / ext3
/dev/sda1 /boot ext2
/dev/sda4 /home ext3Filesystem Size Used Avail Use% Mounted on
/dev/sda4 64G 7.9G 53G 14% /home
/dev/sda3 9.7G 8.6G 557M 95% /
/dev/sda1 38M 8.5M 28M 24% /bootDisk /dev/sda: 80.0 GB, 80032038912 bytes
255 heads, 63 sectors/track, 9730 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00081d08Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40162 83 Linux
/dev/sda2 6 71 530145 82 Linux swap / Solaris
/dev/sda3 72 1346 10241437+ 83 Linux
/dev/sda4 1347 9730 67344480 83 Linux[ACTIVE USER STATUS]
02:07:06 up 3:45, 2 users, load average: 0.20, 0.12, 0.03
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
crouse vc/3 - 01:25 41:41 0.00s 0.00s -bash
gary vc/7 :0 22:25 1.00s 2:45 0.03s /bin/sh /opt/kd[LAST 10 LOGINS]
crouse vc/3 Tue Jul 29 01:25 still logged in
crouse vc/3 Tue Jul 29 01:25 - 01:25 (00:00)
gary vc/7 :0 Mon Jul 28 22:25 still logged in
crouse vc/7 :0 Mon Jul 28 22:22 - 22:24 (00:02)
reboot system boot 2.6.25-ARCH Mon Jul 28 22:21 (03:45)
gary pts/0 :0.0 Mon Jul 28 22:01 - 22:01 (00:00)
gary pts/0 :0.0 Mon Jul 28 22:00 - 22:01 (00:00)
gary pts/0 :0.0 Mon Jul 28 21:31 - 21:31 (00:00)
gary vc/7 :0 Mon Jul 28 19:22 - 22:09 (02:47)
gary vc/7 :0 Mon Jul 28 19:20 - 19:21 (00:01)UPTIME: 02:07:06 up 3:45, 2 users, load average: 0.20, 0.12, 0.03
Offline
Very nice, maybe you could have info on the running window manager. That would be really nice.
Offline
Very nice script, thanks for sharing.
Offline
Nice.
What about using wget instead of lynx to get the external ip?
I think more users have wget installed than lynx...
so, here is the command
wget -q -O - http://www.whatismyip.de | awk '/title/{print $4}'
Offline
Nice script.
I found one problem though (which won't affect many people)... if you use LVM, the device path names are so long (/dev/mapper/volGroup-name) that they split the lines of the "df -h" output , so when it gets sorted the device paths are all listed together at the top followed by the info in a different order at the bottom (fun to try to match them if you have lots of logical volumes, but probably not intended).
Here's a "one-liner" replacement for "df-h | sort -r | grep -v "none"
perl -e 'print join "",((@fs=grep{$_!~/^\s*$/}map{sprintf"%-30s %4s %4s %5s %4s %-s\n",split/\s+/}split"\n",join q/ /,map{($_=~m/^\s/)?$_:"\n$_"}grep{$_!~/^no/}split"\n",`df -h`)?(shift @fs,sort @fs):())'
Plus this won't hide file systems with "none" in their name.
p.s. Sorry, I've been doing a lot of Perl lately.
Last edited by ProtoXyne (2008-07-29 09:25:06)
Some automators are hitting our home page really hard eating up a lot of bandwidth and possibly causing the site to be slow for other visitors. So we've created an Automation page. This file should make it cleaner for you and easier on our bandwidth. Even though it'll be lighter on the bandwidth, please ONLY hit this page at a reasonable pace. Some of you are hitting the site at a pace of 2 times per second...that's WAY TOO often. We prefer you only hit it once per every 5 minutes, but if you need it more often than that, contact us and we can work something out.
wget -O - "http://whatismyip.com/automation/n09230945.asp"
[git] | [AURpkgs] | [arch-games]
Offline
not everybody has the first network interface active. you could find active interfaces parsing route output
[wonder@laptop ~]$ route | grep default | awk -F' ' '{print $8}'
wlan0
don't know if is the right solution
Last edited by wonder (2008-07-29 15:12:00)
Give what you have. To someone, it may be better than you dare to think.
Offline
I'd personally do
LC_ALL=C route | awk -F' ' '/default/ { print $8 }'
The LC_ALL in case the field changes based on locale.
[git] | [AURpkgs] | [arch-games]
Offline
Cleanest way I know to get my real IP (pretty close to SiD's):
echo `wget -q -O - http://www.whatismyip.org`
...
Offline
#!/bin/bash
# Created by Crouse - usalug.org
# Program Name: alis - (A)rch (L)inux (I)nformation (S)cript
# updated 2008-07-29 by Daenyth
# updated 07-28-2008 version .25
# updated 09-12-2007 version .10
#
# REQUIRES: coreutils
#
clear
echo "ALIS: (A)rch (L)inux (I)nformation (S)cript"
echo "Attempting to get EXTERNAL IP address. Please wait . . . . ."
machine_external_ip=$(wget -O - "http://whatismyip.com/automation/n09230945.asp")
sleep 1
clear
num_cpus=$(grep -c "model name" /proc/cpuinfo)
machine_cpu=$(awk -F: '/model name/ { print $2; exit 0}' /proc/cpuinfo)
machine_mhz=$(awk -F: '/cpu MHz/ { print $2; exit 0 }' /proc/cpuinfo)
machine_cpuinfo=$(uname -mp)
todays_date=$(date +"%D %r")
machine_uptime=$(uptime)
machine_ram=$(awk -F: '/MemTotal:/ { print $2; exit 0 }' /proc/meminfo | sed 's/^[ \t]*//')
machine_video=$(lspci | awk -F: '/VGA/ { print $3; exit 0 }' | sed 's/^[ \t]*//')
machine_eth_card=$(lspci | awk -F: '/Ethernet/ { print $3; exit 0 }' | sed 's/^[ \t]*//')
machine_audio_controller=$(lspci | awk -F: '/audio/ { print $3; exit 0 }' | sed 's/^[ \t]*//')
arch_damons=$(grep "^DAEMONS=" /etc/rc.conf)
last_logins=$(last | head)
eth0info=$(ifconfig eth0 | sed -e '/inet addr:/s/inet addr/Local IP/g' -e 's/^[ \t]*//;s/[ \t]*$//')
machine_gateway=$(route | awk '/default/ { print $2; exit 0 }')
machine_kernel=$(LC_ALL=C pacman -Qi kernel26 | awk -F: '/Version/ { print $2 }' | sed 's/^[ \t]*//')
machine_filesystem=$(fdisk -l)
machine_filesystem2=$(sort </proc/mounts | awk '!/none/ && !/rootfs/ {print $1,$2,$3}')
machine_users=$(w -f)
pacman_cache_count=$(ls -1 /var/cache/pacman/pkg | wc -l)
pacman_cache_size=$(du -h /var/cache/pacman/pkg)
pacman_version=$(LC_ALL=C pacman -Qi pacman | awk -F: '/Version/ { print $2; exit 0; }' | sed 's/^[ \t]*//')
cat << EOM
ALIS: (A)rch (L)inux (I)nformation (S)cript ver 1.0 $todays_date
[ARCH INFO]
MACHINE NAME: $HOSTNAME
ARCH KERNEL VERSION: $machine_kernel
PACMAN VERSION: $pacman_version
PACMAN CACHE SIZE: $pacman_cache_size -- clear cache with pacman -Scc
PACMAN CACHE COUNT: $pacman_cache_count packages
$arch_damons
[HARDWARE]
CPU INFO: Qty=$num_cpus $machine_cpuinfo
RAM INFO: $machine_ram
VIDEO CARD: $machine_video
AUDIO CONTROLLER: $machine_audio_controller
ETHERNET CARD: $machine_eth_card
[NETWORK]
EXTERNAL IP: $machine_external_ip
GATEWAY: $machine_gateway
ETH0: $eth0info
[FILE SYSTEM]
$machine_filesystem2
df -h | sort -r | grep -v "none
$machine_filesystem
[ACTIVE USER STATUS]
$machine_users
[LAST 10 LOGINS]"; echo "$last_logins
UPTIME: $machine_uptime
EOM
exit 0
[git] | [AURpkgs] | [arch-games]
Offline
Nice. Didn't list my : ATI Technologies Inc SBx00 Azalia audio though. Using 'grep -m 1 -i' solved the problem
Offline
Well, at least everyone was able to adapt the script
Thanks for the suggestions.
I think I will use wget instead, I don't know why I didn't think of that first. Good idea. I did change that line to:
machine_external_ip=`wget -q -O - "http://whatismyip.com/automation/n09230945.asp"`
commented out the following line:
# if [[ -z $( type -p lynx ) ]]; then echo -e "The program lynx is required to find external IP. Please install lynx." ;fi
I don't use LVM, so I guess I never thought of that......
I also don't use it for wireless stuff either..... I mostly use this script for when I log into remote machines, and to send me nightly updates on each machine.... so I have it's current IP address and stats (some of the machines are not on static IP's, some are dynamic, making it fun to keep track of how to get into them )
Regardless, thank you for the input, and suggestions and I hope someone finds this as useful as I did.
Offline
Nice... I just started writing something similar on the weekend... I guess I can stop now
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Nice work, crouse. Thank you.
Offline