Author Topic: Dhcpcd Logs  (Read 8936 times)

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« on: April 18, 2007, 12:48:15 am »
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
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Dhcpcd Logs
« Reply #1 on: April 19, 2007, 07:40:05 am »
I get the following to the screen:
Code: [Select]
dhcpcd pid is PID parent is Uidand
Code: [Select]
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-:)
« Last Edit: April 19, 2007, 07:41:36 am by Antikx »
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #2 on: April 19, 2007, 08:53:19 am »
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
« Last Edit: April 19, 2007, 11:49:11 am by sdjf »
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Dhcpcd Logs
« Reply #3 on: April 19, 2007, 12:09:51 pm »
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.
« Last Edit: April 19, 2007, 12:10:38 pm by Antikx »
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #4 on: April 19, 2007, 01:55:30 pm »
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
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #5 on: April 20, 2007, 11:12:58 am »
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.
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Dhcpcd Logs
« Reply #6 on: April 24, 2007, 05:22:28 pm »
Code: [Select]
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-:)
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #7 on: April 24, 2007, 07:10:28 pm »
This time the final ps used was busybox's.    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
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Dhcpcd Logs
« Reply #8 on: April 24, 2007, 09:30:23 pm »
Code: [Select]
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
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #9 on: April 24, 2007, 10:18:31 pm »
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
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #10 on: April 24, 2007, 11:30:26 pm »
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
« Last Edit: April 24, 2007, 11:40:39 pm by sdjf »
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Dhcpcd Logs
« Reply #11 on: April 27, 2007, 01:39:21 am »
/etc/pcmcia/network has this in it:
Code: [Select]
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)
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #12 on: April 27, 2007, 04:08:34 am »
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
« Last Edit: April 27, 2007, 04:12:36 am by sdjf »
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards

sdjf

  • Sr. Member
  • ****
  • Posts: 447
    • View Profile
    • http://www.sdjf.wordpress.com and http://www.sdjf.esmartdesign.com
Dhcpcd Logs
« Reply #13 on: April 27, 2007, 05:16:54 am »
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
http://www.sdjf.esmartdesign.com
http://www.sdjf.wordpress.com
-----------------
sl5500 running Sharp ROM 2.38 (dead batteries)
sl6000L running Sharp ROM 1.12 (still working)
Opera 7.25 and 7.30
Socket CF 56k modem
3Com USB Ethernet Adapter
Toshiba, Lexar and Kingston SD cards
Lexar, Kingston and Transcend CF cards