tl;dr: See solution at Update 2 below.
This is not really an answer sadly, or at least not good news: I'm getting the feeling that this can never work anyway — I just find that a little hard to believe since I surely think this has worked in the past!
This is what usually works, and why: Most laptop SD card readers. You'll find that you plug in an SD card, udev
sees it, Linux will scan it for partitions and automounting will just work. Why does this work? Look at lsusb
before and after inserting the card. You'll note that with no SD card plugged in, the USB device doesn't exist. So when you insert an SD card, there's a full-blown USB hotplug event.
The card reader in my monitor doesn't seem to work like this, it's always there. And I can't get it to generate any event when I insert an SD card. I started with looking at syslogs, then on to udevadm monitor
, then usbmon
for raw USB event logging. No luck, there doesn't seem to be any insert/eject notification/event at all, from either the card reader in my monitor or the cheap DealExtreme one in my PC.
The moment I try to access the raw device, the kernel wakes up and the partition appears. Similarly, call udevadm trigger
and it'll note the device. Take out the card and nothing happens until I try to access the device again and the kernel realises it's gone.
What I wonder myself now is, how could this ever have worked (that is, if I'm not making up this memory)? Maybe some daemon used to be polling the raw device every few seconds and stopped doing this? It's hard to find any documentation on this, really.
Update #1
Above is all with a Debian stock kernel. I've just done some experiments with an Ubuntu kernel, where SD card hotplugging appears to work. And not surprisingly, in usbmon
I see polls every two seconds. Which does also explain why the cards aren't detected immediately but with a slight delay.
The polling seems to be done by the kernel, since it happens even in single-user mode with no userland process doing anything other than being stuck in a select()
loop. I haven't been able to figure out where in the kernel this is done, I'll update this post if I find out.
Update #2
The important difference seems to be /sys/block/sd?/events_poll_msecs
. On my Debian box it's -1, on the Ubuntu box it's 2000. This udev
rule seems to do it:
# enable in-kernel media-presence polling
ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", ATTR{parameters/events_dfl_poll_msecs}="2000"
ACTION=="add", ATTR{removable}=="1", ATTR{events_poll_msecs}=="-1", ATTR{events_poll_msecs}="2000"
you can make a check on:
cat /sys/class/net/wlan0/carrier
where wlan0 is my internet interface. you can use whatever interface you are using , such as eth0 , eth1 , wlan0 for internet connectivity. if the output of that command is 1 then you are connected. otherwise not.so you may write script like this:
#!/bin/bash
# Test for network conection
for interface in $(ls /sys/class/net/ | grep -v lo);
do
if [[ $(cat /sys/class/net/$interface/carrier) = 1 ]]; then ; echo "online"; fi
done
you can also use the command:
#hwdetect --show-net
this script also works well:
#!/bin/bash
WGET="/usr/bin/wget"
$WGET -q --tries=20 --timeout=10 http://www.google.com -O /tmp/google.idx &> /dev/null
if [ ! -s /tmp/google.idx ]
then
echo "Not Connected..!"
else
echo "Connected..!"
fi
Best Answer
Looking at the sample
mcelog.conf
config file it looks to contain most if not all of the types of triggers it can deal with.DIMMs
Sockets
Cache
Page
Triggers
Triggers can be controlled in this section.
Sample triggers
There are some sample triggers here on the mcelog github page.
Sample trigger script,
dimm-error-triggers
:References