Skip to content

Commit 47f7ceb

Browse files
author
Anton Yuzhaninov
committed
Add inventory-save.sh script
1 parent f4caf72 commit 47f7ceb

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Some small and simple scripts used by me for for various tasks. Most of them tes
99
* gmirror-rebuild.sh - run gmirror rebuild for stale components after full server startup
1010
* grabssh - fix ssh-agent forwarding when attaching to an existing [tmux](http://tmux.sourceforge.net/) or screen
1111
* hdd-r-speed.sh - run short read benchmark for all HDD
12+
* inventory-save.sh - save hardware information as text files in `/var/db/inventory`
1213
* jpeg2pdf.sh - pack several jpeg images into single pdf file (wrapper around [gs](http://www.ghostscript.com/))
1314
* lib_check.sh - list dynamic executables that have unresolvable shared library links
1415
* ozi-map-merge.pl - generate Global Mapper script to merge raster maps (georeferenced by OziExplorer)

inventory-save.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
6+
7+
cd /var/db/inventory || exit 1
8+
9+
if kldstat -q -m g_mirror; then
10+
gmirror status -s | sort > gmirror.txt
11+
elif [ -f gmirror.txt ]; then
12+
rm gmirror.txt
13+
fi
14+
15+
if [ -c /dev/zfs ]; then
16+
zpool status | grep -Fv 'scan:' > zpool.txt
17+
elif [ -f zpool.txt ]; then
18+
rm zpool.txt
19+
fi
20+
21+
if [ $(id -u) -ne 0 ]; then
22+
SUDO=sudo
23+
else
24+
SUDO=''
25+
fi
26+
27+
$SUDO dmidecode --quiet > dmidecode.txt
28+
29+
rm -f disk_*.txt
30+
31+
for d in $(sysctl -n kern.disks); do
32+
case $d in
33+
# skip removable devices
34+
cd[0-9] | mmcsd[0-9] )
35+
;;
36+
* )
37+
disk_list="$disk_list $d"
38+
;;
39+
esac
40+
done
41+
42+
for d in $disk_list; do
43+
$SUDO smartctl --info /dev/${d} | awk 'NR > 3 && ! /Local Time/' > disk_${d}.txt
44+
done

0 commit comments

Comments
 (0)