linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Monitoring attributes of the device
@ 2010-01-21  5:39 Shashank KotaSathish
  2010-01-21  6:26 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shashank KotaSathish @ 2010-01-21  5:39 UTC (permalink / raw)
  To: linux-hotplug

Hi,

      I wanted to know is it possible to write a rule for the udev which will run a program when the attribute of the device changes. For example if the ethernet plug is removed, the attribute "carriers" of net class will change from 1 to 0. To track this change i wrote the following rule in the /etc/udev/rules.d/70-persistent-net.rules file

SUBSYSTEM="net", DRIVERS="?*", ATTR{carrier}="0", ATTR{address}="00:0c:29:27:a2:95", ATTR{dev_id}="0x0", ATTR{type}="1", KERNEL="eth*", RUN+="/bin/up.sh"

 up.sh will echo some thing in to the text file  in my home directory.
But the up.sh is not getting executed.  Thanks in advance.

Regards,
Shashank K S

http://www.mindtree.com/email/disclaimer.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Monitoring attributes of the device
  2010-01-21  5:39 Monitoring attributes of the device Shashank KotaSathish
@ 2010-01-21  6:26 ` Greg KH
  2010-01-22  4:12 ` Shashank KotaSathish
  2010-01-26  6:07 ` Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2010-01-21  6:26 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Jan 21, 2010 at 10:57:26AM +0530, Shashank KotaSathish wrote:
> Hi,
> 
>       I wanted to know is it possible to write a rule for the udev which will run a program when the attribute of the device changes. For example if the ethernet plug is removed, the attribute "carriers" of net class will change from 1 to 0. To track this change i wrote the following rule in the /etc/udev/rules.d/70-persistent-net.rules file
> 
> SUBSYSTEM="net", DRIVERS="?*", ATTR{carrier}="0", ATTR{address}="00:0c:29:27:a2:95", ATTR{dev_id}="0x0", ATTR{type}="1", KERNEL="eth*", RUN+="/bin/up.sh"
> 
>  up.sh will echo some thing in to the text file  in my home directory.
> But the up.sh is not getting executed.  Thanks in advance.

No sysfs event is getting emitted by the kernel when this attribute
changes.  You need to modify the kernel to create such an event, and
then your script can run.

Or you can just use ethtool and detect the carrier change that way, like
the rest of the world does :)

Hope this helps,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Monitoring attributes of the device
  2010-01-21  5:39 Monitoring attributes of the device Shashank KotaSathish
  2010-01-21  6:26 ` Greg KH
@ 2010-01-22  4:12 ` Shashank KotaSathish
  2010-01-26  6:07 ` Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Shashank KotaSathish @ 2010-01-22  4:12 UTC (permalink / raw)
  To: linux-hotplug

Modifying kernel. Hmmm An intriguing idea. Perhaps some other time. For the current requirement I believe netlink will do. Thanks for the clarification. I should have understood the same when udevadm monitor --kernel did not give any output when I unplugged the network cable.

Regards,
Shashank K S
-----Original Message-----
From: Greg KH [mailto:greg@kroah.com]
Sent: Thursday, January 21, 2010 11:57 AM
To: Shashank KotaSathish
Cc: linux-hotplug@vger.kernel.org
Subject: Re: Monitoring attributes of the device

On Thu, Jan 21, 2010 at 10:57:26AM +0530, Shashank KotaSathish wrote:
> Hi,
>
>       I wanted to know is it possible to write a rule for the udev which will run a program when the attribute of the device changes. For example if the ethernet plug is removed, the attribute "carriers" of net class will change from 1 to 0. To track this change i wrote the following rule in the /etc/udev/rules.d/70-persistent-net.rules file
>
> SUBSYSTEM="net", DRIVERS="?*", ATTR{carrier}="0", ATTR{address}="00:0c:29:27:a2:95", ATTR{dev_id}="0x0", ATTR{type}="1", KERNEL="eth*", RUN+="/bin/up.sh"
>
>  up.sh will echo some thing in to the text file  in my home directory.
> But the up.sh is not getting executed.  Thanks in advance.

No sysfs event is getting emitted by the kernel when this attribute
changes.  You need to modify the kernel to create such an event, and
then your script can run.

Or you can just use ethtool and detect the carrier change that way, like
the rest of the world does :)

Hope this helps,

greg k-h

http://www.mindtree.com/email/disclaimer.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Monitoring attributes of the device
  2010-01-21  5:39 Monitoring attributes of the device Shashank KotaSathish
  2010-01-21  6:26 ` Greg KH
  2010-01-22  4:12 ` Shashank KotaSathish
@ 2010-01-26  6:07 ` Stephen Hemminger
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2010-01-26  6:07 UTC (permalink / raw)
  To: linux-hotplug

On Fri, 22 Jan 2010 09:30:18 +0530
Shashank KotaSathish <Shashank_KotaSathish@mindtree.com> wrote:

> Modifying kernel. Hmmm An intriguing idea. Perhaps some other time. For the current requirement I believe netlink will do. Thanks for the clarification. I should have understood the same when udevadm monitor --kernel did not give any output when I unplugged the network cable.
> 
> Regards,
> Shashank K S
> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com]
> Sent: Thursday, January 21, 2010 11:57 AM
> To: Shashank KotaSathish
> Cc: linux-hotplug@vger.kernel.org
> Subject: Re: Monitoring attributes of the device
> 
> On Thu, Jan 21, 2010 at 10:57:26AM +0530, Shashank KotaSathish wrote:
> > Hi,
> >
> >       I wanted to know is it possible to write a rule for the udev which will run a program when the attribute of the device changes. For example if the ethernet plug is removed, the attribute "carriers" of net class will change from 1 to 0. To track this change i wrote the following rule in the /etc/udev/rules.d/70-persistent-net.rules file
> >
> > SUBSYSTEM="net", DRIVERS="?*", ATTR{carrier}="0", ATTR{address}="00:0c:29:27:a2:95", ATTR{dev_id}="0x0", ATTR{type}="1", KERNEL="eth*", RUN+="/bin/up.sh"
> >
> >  up.sh will echo some thing in to the text file  in my home directory.
> > But the up.sh is not getting executed.  Thanks in advance.
> 
> No sysfs event is getting emitted by the kernel when this attribute
> changes.  You need to modify the kernel to create such an event, and
> then your script can run.
> 
> Or you can just use ethtool and detect the carrier change that way, like
> the rest of the world does :)

Or monitor with netlink like proper tools do (see ip monitor, netlink, netplugd, quagga, ...)



-- 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-26  6:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-21  5:39 Monitoring attributes of the device Shashank KotaSathish
2010-01-21  6:26 ` Greg KH
2010-01-22  4:12 ` Shashank KotaSathish
2010-01-26  6:07 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).