[Discussion] Proposals for getinfo.sh

A 5 star hangout for overworked and underpaid system admins.
User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

[Discussion] Proposals for getinfo.sh

Post by jlehtone » 2012/04/20 08:21:05

Hi,

The [url=https://www.centos.org/modules/newbb/viewtopic.php?topic_id=28723&forum=54]getinfo[/url] is a wonderful tool for wrenching details from users before their issues can be approached. However -- risking data overload -- I feel that it could tell even more.

I mainly dwell on the network fora where routing is a frequent issue. Thus, my notes are about that this time.

One bit of information, but perhaps relevant when traffic does not pass as expected.:
[code]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0[/code]
There have been couple cases when [url=https://www.redhat.com/archives/rhelv6-list/2011-January/msg00080.html]this[/url] policy change in CentOS 6 has saved the day:
[code]# grep rp_filter /etc/sysctl.{conf,d/*}
/etc/sysctl.conf:net.ipv4.conf.default.rp_filter = 1[/code]
(Not quite optimal command for CentOS 5, where there is no /etc/sysctl.d/.)

I'm not fond of "ifconfig -a" but I have to admit that its output is more compact than "ip -s link show" and "ip address show".

When someone has added routing rules/tables, they know what they are doing, so the following would not help?
[code]# ip rule show
0: from all lookup local
32766: from all lookup main
32767: from all lookup default[/code]

My pet peeve is "route vs. ip", since they show a bit different details. Sadly, the route has neater columns:
[code]]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.20.0 0.0.0.0 255.255.255.0 U 0 0 0 bond0.69
172.16.2.0 10.0.0.230 255.255.255.0 UG 0 0 0 brsbl
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 brsbl
192.168.168.0 10.0.0.254 255.255.255.0 UG 0 0 0 brsbl
10.0.10.0 0.0.0.0 255.255.255.0 U 0 0 0 brman
10.21.0.0 10.0.0.230 255.255.0.0 UG 0 0 0 brsbl
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 brsbl

# ip route show
10.0.20.0/24 dev bond0.69 proto kernel scope link src 10.0.20.3
172.16.2.0/24 via 10.0.0.230 dev brsbl
10.0.0.0/24 dev brsbl proto kernel scope link src 10.0.0.207
192.168.168.0/24 via 10.0.0.254 dev brsbl
10.0.10.0/24 dev brman proto kernel scope link src 10.0.10.1
10.21.0.0/16 via 10.0.0.230 dev brsbl
default via 10.0.0.1 dev brsbl[/code]

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: [Discussion] Proposals for getinfo.sh

Post by pschaff » 2012/04/20 12:39:59

Moving to Social as this is not CentOS-6 (or even CentOS) specific.

No problem with adding the suggested [b]ip[/b] information, but I'd be reluctant to replace the current commands. On the [b]sysctl[/b] stuff, some file [b]grep[/b]ping can certainly provide it.

Before moving out on this, any others with suggestions please jump in. I'd rather incorporate all suggestions at once, particularly now that this is in an [url=http://elrepo.org/tiki/Getinfo]ELRepo package[/url].

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: [Discussion] Proposals for getinfo.sh

Post by AlanBartlett » 2012/04/20 23:16:15

I do not think I am suitably qualified to comment on the finer networking points currently being discussed. However I will show the results I have obtained from executing those commands on an [b]RHEL 6.2[/b] system --

[quote]
[ajb@Duo2 ~]$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
[ajb@Duo2 ~]$ grep rp_filter /etc/sysctl.{conf,d/*}
/etc/sysctl.conf:net.ipv4.conf.default.rp_filter = 1
[color=FF0000]grep: /etc/sysctl.d/*: No such file or directory[/color]
[ajb@Duo2 ~]$ ip rule show
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
[ajb@Duo2 ~]$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 wlan0
[ajb@Duo2 ~]$ ip route show
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 2
default via 192.168.1.254 dev wlan0 proto static
[ajb@Duo2 ~]$
[/quote]
Note the line highlighted in red? :-o

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: [Discussion] Proposals for getinfo.sh

Post by TrevorH » 2012/04/21 03:40:37

I've never been keen on the errors we get because a command is not installed. Not sure if this is exactly elegant but it seems to work

[code]
--- /usr/local/bin/oldinfo.sh 2012-04-10 20:09:19.000000000 +0000
+++ /usr/local/bin/getinfo.sh 2012-04-21 03:35:54.077342619 +0000
@@ -85,9 +85,14 @@

for program in $PRGS
do
- echo "== BEGIN $program ==" >> $TMPFILE 2>&1
- eval $program >> $TMPFILE 2>&1
- echo "== END $program ==" >> $TMPFILE 2>&1
+ PRG=$(which `echo $program | cut -d" " -f1` 2>/dev/null)
+ if [ -n "$PRG" -a -x "$PRG" ]; then
+ echo "== BEGIN $program ==" >> $TMPFILE 2>&1
+ eval $program >> $TMPFILE 2>&1
+ echo "== END $program ==" >> $TMPFILE 2>&1
+ else
+ echo "== NO $program ==" >> $TMPFILE 2>&1
+ fi
echo >> $TMPFILE 2>&1
done

[/code]

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: [Discussion] Proposals for getinfo.sh

Post by pschaff » 2012/04/21 12:48:46

Good idea. I had thought about doing something like that but never got it done. Will do it this iteration.

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: [Discussion] Proposals for getinfo.sh

Post by pschaff » 2012/04/21 13:02:47

[quote]
AlanBartlett wrote:
...
Note the line highlighted in red? :-o[/quote]
Actually, same thing on 5.8 now that I test...
[code]# grep rp_filter /etc/sysctl.{conf,d/*}
/etc/sysctl.conf:net.ipv4.conf.default.rp_filter = 1
grep: /etc/sysctl.d/*: No such file or directory
# rpm -q centos-release
centos-release-5-8.el5.centos.x86_64[/code]

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: [Discussion] Proposals for getinfo.sh

Post by TrevorH » 2012/04/21 16:55:06

I had a thought after posting my patch... unfortunately I don't think `which` is a default package :-(

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: [Discussion] Proposals for getinfo.sh

Post by pschaff » 2012/04/21 20:21:38

That is a problem. All I can come up with as an alternative is to use the full paths for executables so they can be checked with "if [ -f /bin/name ]; then ..." as the original command strings are constructed. Makes it rather messy.

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: [Discussion] Proposals for getinfo.sh

Post by TrevorH » 2012/04/21 21:06:46

Hmmm... in the RPM I guess we could cheat:

Requires: which

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: [Discussion] Proposals for getinfo.sh

Post by pschaff » 2012/04/22 02:31:43

That would take care of people who use the package. Better than anything I've come up with. A more general solution that also works for a direct download of the script would be better. I'm still looking/thinking. Other suggestions welcome.

Post Reply