OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Dhcpcd Logs
sdjf
post Apr 17 2007, 08:48 PM
Post #1





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



Has anyone got logging of dhcpcd sessions working? I see in the man page that it takes more than just enabling the logging in /etc/syslog.conf. I can't test this on my Z as I only have dialup, but I need to know so we can debug problems more easily when people test using my scripts on dhcpcd connections.

I believe the call to dhcpcd probably needs the -d flag in order to send output to the log, and I think we need to see which process is calling it to do that.

I did see on the web that it's possible to get the debugging output by calling dhcpcd from the command line, but I would like to make it happen automatically when people use their GUIs to get online.

If nobody has figured out how to get it working on your type of setup, could you run the following three lines when dhcpcd is active and you are online?

array=(`ps -C dhcpcd --noheader -o " %p %P"`)
echo dhcpcd pid is ${array[0]} parent is ${array[1]}
ps ${array[0]}; ps ${array[1]} | tail -n1

Oh, if all you have is BusyBox ps, the above won't work. Instead of getting information about dhcpcd's parent, you'll get a listing for all active processes on your Zaurus, as BusyBox ps has no options.

If you want to install a better ps, I have posted more information about doing that at http://www.sdjf.esmartdesign.com/commands/ps.html


Thanks,
sdjf
Go to the top of the page
 
+Quote Post
Antikx
post Apr 19 2007, 03:40 AM
Post #2





Group: Members
Posts: 1,156
Joined: 5-January 05
From: Winnipeg, Manitoba
Member No.: 6,127



I get the following to the screen:
CODE
dhcpcd pid is PID parent is Uid

and
CODE
root-:) ./ps-3100 ${array[0]}; ./ps-3100 ${array[1]} | tail -n1
ps: error: Unsupported option (BSD syntax)
usage: ps -[Unix98 options]
      ps [BSD-style options]
      ps --[GNU-style long options]
      ps --help for a command summary
ps: error: User name does not exist.
usage: ps -[Unix98 options]
      ps [BSD-style options]
      ps --[GNU-style long options]
      ps --help for a command summary
root-:)
Go to the top of the page
 
+Quote Post
sdjf
post Apr 19 2007, 04:53 AM
Post #3





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



Hmmm. what does your busybox ps show when you are online? do you use dhcpcd? [Edit: I thought you did...maybe you ran when dhcpcd was not active?]

I suppose we should surround the array elements with quotes so the full list appears if dhcpcd is not active:

ps "${array[0]}"; ps "${array[1]}" | tail -n1

Or more complicated but more sure of results:

if [[ "${array[0]}" -gt "0" ]]; then
ps ${array[0]}; ps ${array[1]} | tail -n1
else
ps
fi

No sense running ps on an empty array. What protocol do you use to get online?

thanks,
sdjf

This post has been edited by sdjf: Apr 19 2007, 07:49 AM
Go to the top of the page
 
+Quote Post
Antikx
post Apr 19 2007, 08:09 AM
Post #4





Group: Members
Posts: 1,156
Joined: 5-January 05
From: Winnipeg, Manitoba
Member No.: 6,127



I used ps and grep to confirm that dhcpd wasn't running
I stuck my WiFi card in and tested to make sure I had an Internet connection
I used ps and grep to determine that dhcpd was indeed now running
I copied and pasted what you had in your first post into a terminal and ran them.

I'll try your suggestions later tnite.
Go to the top of the page
 
+Quote Post
sdjf
post Apr 19 2007, 09:55 AM
Post #5





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



if you get this before the test please also post the grep and busybox ps if the code still doesn't work.

you might also do a "ps-3100 ax" in that case.

thanks so much,
sdjf
Go to the top of the page
 
+Quote Post
sdjf
post Apr 20 2007, 07:12 AM
Post #6





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



I see what happened! In the array statement, you used BusyBox ps instead of sharp's.

use this instead on that line:

array=(`./ps-3100 -C dhcpcd --noheader -o " %p %P"`)
You had entered:
array=(`ps -C dhcpcd --noheader -o " %p %P"`)__
So of course it spit back the first 2 words in busybox's header. wink.gif
Go to the top of the page
 
+Quote Post
Antikx
post Apr 24 2007, 01:22 PM
Post #7





Group: Members
Posts: 1,156
Joined: 5-January 05
From: Winnipeg, Manitoba
Member No.: 6,127



CODE
root-:) array=(`./ps-3100 -C dhcpcd --noheader -o " %p %P"`)
root-:) echo dhcpcd pid is ${array[0]} parent is ${array[1]}
dhcpcd pid is 2090 parent is 1
root-:) ./ps-3100  ${array[0]}; ps ${array[1]} | tail -n1
 PID TTY      STAT   TIME COMMAND
2090 ?        S      0:00 /sbin/dhcpcd -N wlan0
2127 root        524 S   tail -n1
root-:)
Go to the top of the page
 
+Quote Post
sdjf
post Apr 24 2007, 03:10 PM
Post #8





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



This time the final ps used was busybox's. sad.gif Let's try an alias:
alias ps="./ps-3100"
array=(`ps -C dhcpcd --noheader -o " %p %P"`)
echo dhcpcd pid is ${array[0]} parent is ${array[1]}
ps ${array[0]}; ps ${array[1]} | tail -n1
alias ps="ps" # return to normal here

sdjf
Go to the top of the page
 
+Quote Post
Antikx
post Apr 24 2007, 05:30 PM
Post #9





Group: Members
Posts: 1,156
Joined: 5-January 05
From: Winnipeg, Manitoba
Member No.: 6,127



CODE
root-:) alias ps="./ps-3100"
root-:) array=(`ps -C dhcpcd --noheader -o " %p %P"`)
root-:) echo dhcpcd pid is ${array[0]} parent is ${array[1]}
dhcpcd pid is 3013 parent is 1
root-:) ps ${array[0]}; ps ${array[1]} | tail -n1
 PID TTY      STAT   TIME COMMAND
3013 ?        S      0:00 /sbin/dhcpcd -N wlan0
   1 ?        S      0:43 ini
Go to the top of the page
 
+Quote Post
sdjf
post Apr 24 2007, 06:18 PM
Post #10





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



Bingo! Thank you. That tells me that either your dhcpcd wlan0 is always up, started at initialization, or that the process that called dhcpcd is no longer active.

Anyone know what calls dhcpcd? An "lsof" might yield data if it got run just before dhcpcd happened. Hmmm.

I don't know what to read to figure this out.

sdjf
Go to the top of the page
 
+Quote Post
sdjf
post Apr 24 2007, 07:30 PM
Post #11





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



Eureka! I think I've found it, at least for Sharp ROMs.

In /etc/pcmcia/network, I would try adding a -d right
after /sbin/dhcpcd, and before $HN, on both of the following two lines to get debugging output to happen automatically. On my copy, they are lines 82 and 87 according to grep.


/sbin/dhcpcd $HN $DEVICE >/dev/null 2>&1 || exit 1
/sbin/dhcpcd $HN -c $L $DEVICE >/dev/null 2>&1

I believe that the above, after also adding "local0.* /var/log/dhcpcd.log" to /etc/syslog.conf, will do the trick. I think pdaXii13 uses a different scheme, so I still don't know what to do there.

If anyone tries testing this, let me know what happens. Again, I'm sorry I can't test it on my Z because all I have is dialup.

The basic info on debugging output for dhcpcd is in the man page for dhcpcd...the challenge has been in finding where it gets called.

sdjf

This post has been edited by sdjf: Apr 24 2007, 07:40 PM
Go to the top of the page
 
+Quote Post
Antikx
post Apr 26 2007, 09:39 PM
Post #12





Group: Members
Posts: 1,156
Joined: 5-January 05
From: Winnipeg, Manitoba
Member No.: 6,127



/etc/pcmcia/network has this in it:
CODE
elif is_true $DHCP; then                                            
    bootp_setup                                                      
    HN=${DHCP_HOSTNAME:+-h $DHCP_HOSTNAME}                          
    TO=${DHCP_TIMEOUT:+-t $DHCP_TIMEOUT}                            
    if [ -x /sbin/dhcpcd ]; then                                    
        # This is a version check: I know it looks weird            
        if /sbin/dhcpcd --help 2>&1 | grep -q DHCP; then            
            /sbin/dhcpcd -N $HN $TO $DEVICE >/dev/null 2>&1 || exit 1
        else                                                        
            # Jump through hoops for lame 0.70-era dhcpcd            
            L=/var/run/dhcp-lock-$DEVICE                            
            /bin/echo "#!/bin/sh\nrm $L" > $L; chmod +x $L          
            /sbin/dhcpcd -N $HN -c $L $DEVICE >/dev/null 2>&1        
            for t in 0 1 2 3 4 5 6 7 8 9; do                        
                sleep 2; if [ ! -e $L ]; then break; fi          
            done                                                    
            rm -f $L                                                
            if [ -e /etc/dhcpc/resolv.conf ]; then                  
                echo "# $DEVICE begin" > $RESOLV.N    

(just part of file)
Go to the top of the page
 
+Quote Post
sdjf
post Apr 27 2007, 12:08 AM
Post #13





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



Oh, how cool! The line of interest added a "-N":

/sbin/dhcpcd -N $HN -c $L $DEVICE >/dev/null 2>&1_

And the -N, according to the man page:

"Prevents dhcpcd from replacing existing /etc/ntp.conf file."

So, if you want to log what's going on, I should think it would not hurt to add a "-d":

/sbin/dhcpcd -d -N $HN -c $L $DEVICE >/dev/null 2>&1

The version check is different...on my version, they enter options that do not exist to trigger an error/help message.

if /sbin/dhcpcd -XYZZY 2>&1 | grep -q DHCP ; then_
/sbin/dhcpcd $HN $DEVICE >/dev/null 2>&1 || exit 1_

Unsure whether a -d would hurt or be necessary in your other /sbin/dhcpcd lines, but I think you probably would need it on:

/sbin/dhcpcd -d -N $HN $TO $DEVICE >/dev/null 2>&1 || exit 1
Go to the top of the page
 
+Quote Post
sdjf
post Apr 27 2007, 01:16 AM
Post #14





Group: Members
Posts: 454
Joined: 17-November 05
Member No.: 8,551



Looking at the pdaXrom howto here, I see dhcpcd gets called by the "wifiup" script.

There's a line "dhcpcd wlan0" which I would imagine could have debugging added like thus:

dhcpcd -d wlan0

Your system may use this instead of the "network" script, which is more in line with what I'd read elsewhere.
sdjf
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd July 2014 - 11:34 AM