View previous topic :: View next topic |
Author |
Message |
bicolao n00b
Joined: 05 Jan 2004 Posts: 50
|
Posted: Fri May 14, 2004 3:44 am Post subject: Show me your service dependency tree |
|
|
Hi,
I found /var/lib/init.d/deptree holding some info for parallel service starting. I wrote a script to visualize it using graphviz
The code is:
Code: |
#!/bin/bash
source /var/lib/init.d/deptree
echo "digraph deptree {"
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
NAME=`echo "$LABEL"|tr -cd '[a-zA-Z]'`
echo "${NAME} [label=\"${LABEL}\"];"
done
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
NAME=`echo "$LABEL"|tr -cd '[a-zA-Z]'`
DEP=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}+${rc_type_needsme}))]}
for j in ${DEP}; do
DEPNAME=`echo "$j"|tr -cd '[a-zA-Z]'`
echo "${NAME} -> ${DEPNAME};"
done
done
echo "}"
|
Use as follow:
Code: |
dep2dot |dot -Tpng -o dep.png
|
dep2dot is the script name. Then you can look into dep.png. I don't know if i interpret deptree properly. If i'm wrong, please correct me.
Have fun. _________________ Bi Cờ Lao |
|
Back to top |
|
|
ecatmur Advocate
Joined: 20 Oct 2003 Posts: 3595 Location: Edinburgh
|
|
Back to top |
|
|
langthang Retired Dev
Joined: 27 Nov 2003 Posts: 620
|
Posted: Fri May 14, 2004 4:41 am Post subject: |
|
|
really nice! now where is that package dependency tree minus the base system packages? |
|
Back to top |
|
|
bicolao n00b
Joined: 05 Jan 2004 Posts: 50
|
Posted: Fri May 14, 2004 5:45 am Post subject: |
|
|
langthang wrote: | really nice! now where is that package dependency tree minus the base system packages? |
Which package is base system package? How to know it? I may emphasize them to distinguish with others _________________ Bi Cờ Lao |
|
Back to top |
|
|
langthang Retired Dev
Joined: 27 Nov 2003 Posts: 620
|
Posted: Fri May 14, 2004 4:26 pm Post subject: |
|
|
Look in '/usr/portage/profiles/default-[arch]-2004.0/packages' for base system packages. |
|
Back to top |
|
|
ecatmur Advocate
Joined: 20 Oct 2003 Posts: 3595 Location: Edinburgh
|
|
Back to top |
|
|
bicolao n00b
Joined: 05 Jan 2004 Posts: 50
|
Posted: Sat May 15, 2004 6:11 am Post subject: |
|
|
Ok, new script
Code: |
#!/bin/bash
[ -n "$NOEXTRA" -a -z "$BASESTYLE" ] && BASESTYLE=solid
[ -n "$BASESTYLE" ] || BASESTYLE=dashed
[ -n "$EXTRASTYLE" ] || EXTRASTYLE=solid
function myname
{
echo `echo "$1"|tr -cd '[a-zA-Z]'`
}
if [ -f services.base ];then
while read n;do
if [ -n "$n" ]; then
let "BASE_`myname $n`=1"
fi
done < services.base
fi
source /var/lib/init.d/deptree
echo "digraph deptree {"
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
NAME=`myname "$LABEL"`
eval ret=\$BASE_`myname ${NAME}`
if [ "$ret" = 1 ]; then
[ -n "$NOBASE" ] || echo "${NAME} [label=\"${LABEL}\" style=${BASESTYLE}];"
else
[ -n "$NOEXTRA" ] || echo "${NAME} [label=\"${LABEL}\" style=${EXTRASTYLE}];"
fi
done
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
NAME=`myname "$LABEL"`
DEP=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}+${rc_type_needsme}))]}
for j in ${DEP}; do
DEPNAME=`myname "$j"`
eval ret1=\$BASE_`myname "${NAME}"`
eval ret2=\$BASE_`myname "${DEPNAME}"`
if [ "$ret1" = 1 -o "$ret2" = 1 ]; then
if [ -z "$NOBASE" -a '(' -z "$NOEXTRA" -o "$ret2" = 1 ')' ]; then
echo "${NAME} -> ${DEPNAME} [style=${BASESTYLE}];"
fi
else
[ -n "$NOEXTRA" ] || echo "${NAME} -> ${DEPNAME} [style=${EXTRASTYLE}];"
fi
done
done
echo "}"
|
It's pain to find out which service is base service. Base service names is stored in services.base file,
Code: |
hdparm
hostname
keymaps
local
localmount
modules
net.eth0
net.lo
netmount
nscd
numlock
rmnologin
rsyncd
serial
sysklogd
urandom
xdm
xfs
bootmisc
checkfs
checkroot
clock
consolefont
crypto-loop
domainname
net
|
Use can set NOBASE=1 to remove base services from the graph or NOEXTRA=1 to remove the rest from the graph.
Change BASESTYLE, EXTRASTYLE to others (dashed, bold, solid ...) as you wish. _________________ Bi Cờ Lao |
|
Back to top |
|
|
|