SysInfo: a set of scripts that document your system

danger@

Administrator
Staff member
Administrator
Moderator
Developer
Hello guys,

I am developing a script that automatically documents settings of particular freebsd (currently 7.x) box from the hardware point of view to the network and services related information.

The point of this script is to provide some descriptive information about unknown system's configuration (hardware and software) for administrator who has no idea about the given system.

I would greatly appreciate if you guys could test it in your environment and provide some feedback. It currently doesn't provide very much information, so I would really also like to hear your opinions on what kind of information would you be interested in in above described situation, which I should document.

The latest version of this script can be found at:
http://people.freebsd.org/~danger/sysinfo/

Thank you.
 
I get an error in the part handled by the 020-mem script.

Code:
System memory summary
expr: illegal option -- 4
usage: expr [-e] expression
expr: illegal option -- 1
usage: expr [-e] expression
Total real memory available:	2047 MB
Logically used memory:		 MB
Logically available memory:	 MB

020-mem run with sh -xv:

Code:
cat <<EOF
Total real memory available:	$(calc_mb $physmem) MB
Logically used memory:		$(calc_mb $usedmem) MB
Logically available memory:	$(calc_mb $availmem) MB
EOF
+ cat
+ calc_mb 3203567616
+ expr 3203567616 / 1048576
+ echo 2047
+ return
+ calc_mb -465883137
+ expr -465883137 / 1048576
expr: illegal option -- 4
usage: expr [-e] expression
+ echo
+ return
+ calc_mb -1681600512
+ expr -1681600512 / 1048576
expr: illegal option -- 1
usage: expr [-e] expression
+ echo
+ return
Total real memory available:	2047 MB
Logically used memory:		 MB
Logically available memory:	 MB

My real mem (dmesg -a) is 3220897792 (3071 MB), btw ;)
 
no errors and all true :)
Code:
CPU information

Machine class:	i386
CPU Model:	Intel(R) Pentium(R) Dual  CPU  E2200  @ 2.20GHz
Number of CPUs:	2

RAM information

System memory summary
Total real memory available:	1005 MB
Logically used memory:		481 MB
Logically available memory:	523 MB

Swap information
Device          1K-blocks     Used    Avail Capacity
/dev/ad6s1b       4194304       0B     4.0G     0%

Operating system information

Operating system release:	FreeBSD 7.1-RELEASE-p2
OS architecture:		i386
Hostname:			icer.local
Kernel build dir location:	/usr/obj/usr/src/sys/WiFi
Currently booted kernel:	/boot/kernel/kernel

Currently loaded kernel modules (kldstat):
acpi.ko
linprocfs.ko
linux.ko
Storage information

Available hard drives:
da3: <Generic USB MS Reader 1.03> Removable Direct Access SCSI-0 device 
da3: 1.000MB/s transfers
da3: Attempt to query device size failed: NOT READY, Medium not present
da2: <Generic USB SM Reader 1.02> Removable Direct Access SCSI-0 device 
da2: 1.000MB/s transfers
da2: Attempt to query device size failed: NOT READY, Medium not present
da1: <Generic USB CF Reader 1.01> Removable Direct Access SCSI-0 device 
da1: 1.000MB/s transfers
da1: Attempt to query device size failed: NOT READY, Medium not present
da0: <Generic USB SD Reader 1.00> Removable Direct Access SCSI-0 device 
da0: 1.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present
acd0: DVDR <Optiarc DVD RW AD-7170A/1.03> at ata2-master UDMA66
cd0: <Optiarc DVD RW AD-7170A 1.03> Removable CD-ROM SCSI-0 device 
cd0: 66.000MB/s transfers
cd0: Attempt to query device size failed: NOT READY, Medium not present
ad6: 76319MB <WDC WD800JD-60LSA5 10.01E03> at ata3-master SATA300

Currently mounted filesystems:
/dev/ad6s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad6s1e on /tmp (ufs, local, soft-updates)
/dev/ad6s1f on /usr (ufs, local, soft-updates)
/dev/ad6s1d on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
linprocfs on /usr/compat/linux/proc (linprocfs, local)

I/O statistics:
      tty             ad6              da0              da1             cpu
 tin tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
  14  209 11.09  11  0.12   0.01   0  0.00   0.01   0  0.00   6  0  2  2 90
INFO: 
Run gstat(8) to see live statistics.

Disk usage:
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ad6s1a    496M    252M    204M    55%    /
devfs          1.0K    1.0K      0B   100%    /dev
/dev/ad6s1e    496M     17M    439M     4%    /tmp
/dev/ad6s1f     58G     27G     26G    52%    /usr
/dev/ad6s1d    9.7G    1.4G    7.5G    16%    /var
procfs         4.0K    4.0K      0B   100%    /proc
linprocfs      4.0K    4.0K      0B   100%    /usr/compat/linux/proc

Network information

hostname:  icer.local

Currently available network devices:
em0 ath0 fwe0 fwip0 lo0 pflog0 pfsync0

Basic configuration for currently available NICs:

em0:
MAC address: 00:1c:c0:73:7c:2c
IPv4 addresses:
192.168.x.x netmask 0xffffff00

ath0:
MAC address: 00:21:91:97:ba:5e
IPv4 addresses:
192.168.x.x netmask 0xffffff00
MAC address: 02:90:27:24:da:b9

lo0:
IPv4 addresses:
127.0.0.1 netmask 0xff000000
IPv6 addresses:
fe80::1%lo0 prefixlen 64
::1 prefixlen 128

Default route: 192.168.x.x
INFO: For a complete routing table please run netstat -rn

There are 12 currently opened or listening connections.
INFO: For more information please see sockstat(8) manual

Information related to services

Misc information

Currently logged-in users:
icer             v8       :0                9:51PM     - -
icer             p1       :0.0             10:48PM     - w -hi
icer             p0       :0.0              9:51PM     9 /usr/bin/as -o nsPlugi

Uptime:
10:50PM  up  4:55, 3 users, load averages: 1.17, 1.05, 0.88
thx, useful fiche
P.S. btw in my opinion, it will be useful if script check rc.conf and after what check runing services and show status. smf like this:
apache 2.2.1 - runing
samba 3.3.3 - runing
 

Yes, that looks normal to me.

Code:
SYSTEM MEMORY INFORMATION:
mem_wire:         144449536 (    137MB) [  4%] Wired: disabled for paging out
mem_active:  +    179015680 (    170MB) [  5%] Active: recently referenced
mem_inactive:+    567050240 (    540MB) [ 18%] Inactive: recently not referenced
mem_cache:   +      2453504 (      2MB) [  0%] Cached: almost avail. for allocation
mem_free:    +   2252898304 (   2148MB) [ 71%] Free: fully available for allocation
mem_gap_vm:  +       688128 (      0MB) [  0%] Memory gap: UNKNOWN
-------------- ------------ ----------- ------
mem_all:     =   3146555392 (   3000MB) [100%] Total real memory managed
mem_gap_sys: +     57012224 (     54MB)        Memory gap: Kernel?!
-------------- ------------ -----------
mem_phys:    =   3203567616 (   3055MB)        Total real memory available
mem_gap_hw:  +     17657856 (     16MB)        Memory gap: Segment Mappings?!
-------------- ------------ -----------
mem_hw:      =   3221225472 (   3072MB)        Total real memory installed

SYSTEM MEMORY SUMMARY:
mem_used:         398823424 (    380MB) [ 12%] Logically used memory
mem_avail:   +   2822402048 (   2691MB) [ 87%] Logically available memory
-------------- ------------ ----------- ------
mem_total:   =   3221225472 (   3072MB) [100%] Logically total memory
 
I also get an error in the memory section:

Code:
expr: illegal option -- 1
usage: expr [-e] expression
expr: syntax error

I threw a few extra lines into 020.mem to see the values of the memory variables:

Code:
physmem: 3744890880
activemem: 140959744
inactmem: -1125810176
cachemem: 142274560
allmem: -616513536
wiremem: 211468288
freemem: 13770752

and the direct sysctl outputs (done after the script ran, so the results might be a little different) are:

Code:
hw.pagesize: 4096
hw.physmem: 3744890880
vm.stats.vm.v_active_count: 34425
vm.stats.vm.v_inactive_count: 773958
vm.stats.vm.v_cache_count: 34531
vm.stats.vm.v_page_count: 898060
vm.stats.vm.v_wire_count: 51683
vm.stats.vm.v_free_count: 3258

Seems to be an overflow error for memory above a certain size.
 
interesting...I will check later today and see what's going on. I have been developing this tool on 8gb box, so it's a bit weird. We will see.
 
Yup, the services part is not yet implemented. I will be working on this part today or maybe during the weekend and Easter holidays.

Having that said, I would like to hear what kind of information you guys are interested to see in the script's output in that regard.

Thanks.
 
what does % expr 3744890880 / 1048576 give you?
 
danger@ said:
what does % expr 3744890880 / 1048576 give you?

That gives 2047. Although the problem seemed to be with multiplication, not division.

While reading the expr man page, I noticed the -e option, to detect overflows. I added it to the script, and no longer get errors:

Code:
RAM information

System memory summary
Total real memory available:    3571 MB
Logically used memory:          398 MB
Logically available memory:     3172 MB

Swap information
Device          1K-blocks     Used    Avail Capacity
/dev/twed0s1b     4194304     248K     4.0G     0%
 
Daniel, that's a very nice script! :)
Code:
Available hard drives:
acd0: DVDR <TSSTcorpCD/DVDW TS-L632D/SC01> at ata0-slave UDMA33
acd0: FAILURE - INQUIRY ILLEGAL REQUEST asc=0x24 ascq=0x00
cd0: <TSSTcorp CD/DVDW TS-L632D SC01> Removable CD-ROM SCSI-0 device
cd0: 33.000MB/s transfers
cd0: Attempt to query device size failed: NOT READY, 
^^^^ should be grepped out
Medium not present - tray closed
acpi_acad0: <AC Adapter> on acpi0
^^^^^^^^^^^^^^^^^^^^^^^
  no, this is not a drive ;-)
ad0: 114473MB <Seagate ST9120822A 3.ALC> at ata0-master UDMA100

Code:
Basic configuration for currently available NICs:
MAC address: 00:13:02:3f:0d:e4
MAC address: 00:00:f0:7f:da:00
MAC address: 02:00:f0:0f:ab:79
You should add the device names here.

Code:
Default route: 192.168.10.1

Here you could add the interface.
 
Code:
CPU information

Machine class:  i386
CPU Model:      Intel(R) Core(TM)2 Duo CPU     T7250  @ 2.00GHz
Number of CPUs: 2

RAM information

System memory summary
Total real memory available:    2035 MB
Logically used memory:          1352 MB
Logically available memory:     682 MB

Swap information
Device          512-blocks     Used    Avail Capacity
/dev/ad4s1b        4194304     920K     2.0G     0%

Operating system information

Operating system release:       FreeBSD 8.0-CURRENT
OS architecture:                i386
Hostname:                       imax
Kernel build dir location:      /usr/obj/usr/src/sys/HEAD
Currently booted kernel:        /boot/kernel/kernel

Currently loaded kernel modules (kldstat):
drm.ko
radeon.ko
linprocfs.ko
linux.ko
ng_socket.ko
ng_mppc.ko
rc4.ko
ng_iface.ko
ng_ppp.ko
fuse.ko
kqemu.ko
Storage information

Available hard drives:
acd0: DVDR <MATSHITADVD-RAM UJ-861H/1.50> at ata0-master PIO4
acd0: FAILURE - INQUIRY ILLEGAL REQUEST asc=0x24 ascq=0x00
acd0: FAILURE - INQUIRY ILLEGAL REQUEST asc=0x24 ascq=0x00
cd0: <MATSHITA DVD-RAM UJ-861H 1.50> Removable CD-ROM SCSI-0 device
cd0: 16.000MB/s transfers
cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed
ad4: 152627MB <FUJITSU MHY2160BH 890B> at ata2-master SATA150

Currently mounted filesystems:
/dev/ufs/root on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ufs/tmp on /tmp (ufs, local, soft-updates)
/dev/ufs/usr on /usr (ufs, local, soft-updates)
/dev/ufs/var on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
linprocfs on /usr/compat/linux/proc (linprocfs, local)
devfs on /usr/compat/linux/dev (devfs, local)
/usr/home/imax/music/Audio on /var/ftp/music/audio (nullfs, local, read-only)
/usr/home/imax/music/Video on /var/ftp/music/video (nullfs, local, read-only)
/usr/home/imax/music/Lyrics on /var/ftp/music/lyrics (nullfs, local, read-only)
/usr/home/imax/Films on /var/ftp/films (nullfs, local, read-only, union)
/usr/home/imax/Share on /var/ftp/share (nullfs, local, read-only)
/var/ftp/incoming on /usr/home/imax/incoming (nullfs, local)
/usr/ports/distfiles on /var/ftp/distfiles (nullfs, local, read-only)
/usr/home/imax/Documents/docs on /var/ftp/docs (nullfs, local, read-only)
devfs on /var/named/dev (devfs, local)

I/O statistics:
      tty             ad4              cd0            pass0             cpu
 tin tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
  57 1588 65.26  17  1.05   0.00   0  0.00   0.00   0  0.00  17  3  9  1 69
modules/030.storage: DEBUG: checkyesno: INFO_MSGS is set to YES.
INFO: Run gstat(8) to see live statistics.

Disk usage:
Filesystem                       Size    Used   Avail Capacity  Mounted on
/dev/ufs/root                    496M    167M    289M    37%    /
devfs                            1.0K    1.0K      0B   100%    /dev
/dev/ufs/tmp                     989M    123M    787M    13%    /tmp
/dev/ufs/usr                     138G    135G    1.2G    99%    /usr
/dev/ufs/var                     2.9G    687M    2.0G    25%    /var
procfs                           4.0K    4.0K      0B   100%    /proc
linprocfs                        4.0K    4.0K      0B   100%    /usr/compat/linux/proc
devfs                            1.0K    1.0K      0B   100%    /usr/compat/linux/dev
/usr/home/imax/music/Audio       138G    135G    1.2G    99%    /var/ftp/music/audio
/usr/home/imax/music/Video       138G    135G    1.2G    99%    /var/ftp/music/video
/usr/home/imax/music/Lyrics      138G    135G    1.2G    99%    /var/ftp/music/lyrics
/usr/home/imax/Films             138G    135G    1.2G    99%    /var/ftp/films
/usr/home/imax/Share             138G    135G    1.2G    99%    /var/ftp/share
/var/ftp/incoming                2.9G    687M    2.0G    25%    /usr/home/imax/incoming
/usr/ports/distfiles             138G    135G    1.2G    99%    /var/ftp/distfiles
/usr/home/imax/Documents/docs    138G    135G    1.2G    99%    /var/ftp/docs
devfs                            1.0K    1.0K      0B   100%    /var/named/dev

Network information

hostname:  imax

Currently available network devices:
em0 wpi0 lo0 vlan0 ng0 gif0 gif1 gif4

Basic configuration for currently available NICs:

em0:
MAC address: 00:1a:4b:76:91:e1
IPv4 addresses:
10.45.71.120 netmask 0xffffff80
MAC address: 00:1c:bf:2e:dc:fc

lo0:
IPv4 addresses:
127.0.0.1 netmask 0xff000000
IPv6 addresses:
fe80::1%lo0 prefixlen 64
::1 prefixlen 128

vlan0:
MAC address: 00:1a:4b:76:91:e1
IPv4 addresses:
10.45.74.7 netmask 0xffffff00

gif0:
IPv4 addresses:
inet 10.45.74.7 -->
192.168.100.1 --> 192.168.100.2

gif1:
IPv4 addresses:
inet 10.45.74.7 -->
192.168.100.1 --> 192.168.100.3

gif4:
IPv4 addresses:
inet 10.45.74.7 -->
192.168.100.17 --> 192.168.100.18

Default route: 10.45.74.254
modules/040.network: DEBUG: checkyesno: INFO_MSGS is set to YES.
INFO: For a complete routing table please run netstat -rn

There are 183 currently opened or listening connections.
modules/040.network: DEBUG: checkyesno: INFO_MSGS is set to YES.
INFO: For more information please see sockstat(8) manual

Information related to services

Misc information

Currently logged-in users:
root             pts/10   :pts/9:S.0       Thu03PM  9:18 /usr/local/bin/zsh

Uptime:
12:55AM  up 10:51, 1 user, load averages: 0.55, 0.56, 0.59
ifconfig output parsing not adopted for point-to-point interfaces.

Maybe resolv.conf should be printed in network information.
Also, information about firewall could be useful (as for ipfw - at least sysctl net.inet(6).ip(6).fw.enable, net.link.ether.ipfw and net.link.bridge.ipfw variables).

P.S.: `./sysinfo -a | less` full of esacpe sequences used for coloring which makes output some less readable.

P.P.S.: thanks for developing such tool :)
 
gelraen said:
ifconfig output parsing not adopted for point-to-point interfaces.

First, let me thank you for the feedback.

Could you please send me the output of your ifconfig, so I can fix it for P2P devices?

gelraen said:
Maybe resolv.conf should be printed in network information.

Feature added in my local version, thanks for an idea.

gelraen said:
Also, information about firewall could be useful (as for ipfw - at least sysctl net.inet(6).ip(6).fw.enable, net.link.ether.ipfw and net.link.bridge.ipfw variables).

That's a great idea, I will implement it soon.

gelraen said:
P.S.: `./sysinfo -a | less` full of esacpe sequences used for coloring which makes output some less readable.

That's why there's -c option :)

gelraen said:
P.P.S.: thanks for developing such tool :)

It's nice to hear such words, thanks :)
Actually it's being developed as part of my bachelor thesis.
 
lme@ said:
Code:
cd0: Attempt to query device size failed: NOT READY, 
^^^^ should be grepped out
Medium not present - tray closed
acpi_acad0: <AC Adapter> on acpi0
^^^^^^^^^^^^^^^^^^^^^^^
  no, this is not a drive ;-)[/quote]

I think I have fixed this in my local version :) I will release new version probably during the weekend so you will be welcome to test it :)

[quote="lme@"][code]
Basic configuration for currently available NICs:
MAC address: 00:13:02:3f:0d:e4
MAC address: 00:00:f0:7f:da:00
MAC address: 02:00:f0:0f:ab:79
You should add the device names here.

I wonder how does your ifconfig output look like?

lme@ said:
Code:
Default route: 192.168.10.1

Here you could add the interface.

Added. :)
 
danger@ said:
Could you please send me the output of your ifconfig, so I can fix it for P2P devices?

Code:
% ifconfig gif0
gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1280
        tunnel inet 10.45.74.7 --> 10.45.67.94
        inet 192.168.100.17 --> 192.168.100.18 netmask 0xffffffff

General interface looks like this:
Code:
% ifconfig vlan0
vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=3<RXCSUM,TXCSUM>
        ether 00:1a:4b:76:91:e1
        inet 10.45.74.7 netmask 0xffffff00 broadcast 10.45.74.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        vlan: 1000 parent interface: em0

danger@ said:
That's why there's -c option :)
Oh, sorry, I've missed this one :)

And one more small thing, when started without parameters it show help message followed by
Code:
./sysinfo: ERROR: Not enough arguments provided.
 
SysInfo v0.4 release

Hello guys,

I have packaged a new version of my script. It can be downloaded from http://people.freebsd.org/~danger/sysinfo/sysinfo-110409.tar.gz.

Please test it (including execution with -v to include verbose information) and report any bugs you may have found.

I am still also interested in ideas on what should this script document.

Thanks in advance!
 
Your latest script works without issue on my slightly out-dated version of FreeBSD 7.1 and served to remind me I have to do an OS update this weekend.

Quick small issue - advice in the following statement is spelled incorrectly:

INFO: For system tuning adice, see the tuning(7) man page.
 
1) check_firewalls() should handle also $firewall_type, not just $firewall_script (btw, maybe will be better to say "ipfw show" instead)

2) services module output full of
Code:
Cannot 'status' snmpd. Set snmpd_enable to YES in /etc/rc.conf or use 'onestatus' instead of 'status'.

3) Socket statistics doesn't count tcp/udp sockets. And phrase "IP connections" has no sense.
 
CPU information

You could add vmstat(8) -i info after cpu info.

System memory summary

You could vmstat(8) output here.

Currently mounted filesystems:

You could compare against /etc/fstab and list currently unmounted filesystems too.

Disk usage:

After this, it might be useful to see the output of dump(8) -W ... although I'm sure everyone's backups would be up-to-date :)

MAC address: 00:1f:d0:a4:ec:fc
IPv4 addresses:
192.168.1.4 netmask 0xffffff00

Why does the MAC address run on? Most of your other info after a colon starts a new line.

Firewall related information:

Leave this out if there isn't any firewall info? Or say "no firewall info found" ?

INFO: Use the portsnap(8) tool to update your ports tree.

Why not csup(1) with compression? Faster and smaller updates.

Services status

adzapper is running as pid 730.

apache is running as pid 736.

apcupsd is running as pid 625.

bsdstats is not running.

...

Why the blank line between entries?

INFO: Configuration of system-wide services is located in the /etc/ directory.
INFO: Configuration files for local services can be found in the /usr/local/etc/

Might as well be consistent and make it "Configuration of..." rather than "Configuration files for..." the second time.

Nice job!
 
Hello,

it's me again! I have put up a new version of SysInfo (0.5), which can be downloaded from http://people.freebsd.org/~danger/sysinfo/sysinfo-140409.tar.gz.

In this version, I have incomporated the latest feedback I have recieved. I would be very thankful if anybody could test it in their own environment and report any bugs found in this release.

As a last note -- I am still looking for ideas of what should be documented by this script.
 
Two quirks:

Double:

Code:
Available hard drives:
cd0: <HL-DT-ST DVDRAM GSA-T40L KC07> Removable CD-ROM SCSI-0 device 
cd0: 16.000MB/s transfers
cd0: <HL-DT-ST DVDRAM GSA-T40L KC07> Removable CD-ROM SCSI-0 device 
cd0: 16.000MB/s transfers
ad8: 114473MB <Seagate ST9120823AS 3.AHE> at ata4-master SATA300
ad8: 114473MB <Seagate ST9120823AS 3.AHE> at ata4-master SATA300

?

Code:
Firewall related information:
[: -ne: unexpected operator

(not using any)
 
Back
Top