You are not logged in.

#1 2013-02-12 11:19:13

kaszak696
Member
Registered: 2009-05-26
Posts: 543

[Nonsense][Python] Using inotify events to monitor temperature changes

Hai thar,

I'm trying to write a little dongle that does magic when the file in /sys changes. I want it to go like this:

  1. Watch the file, let's say '/sys/devices/platform/coretemp.0/temp2_input'.

  2. When the file content was modified, open that file and yank the current value and do magic.

  3. Rinse, repeat

I'm using pyinotify library for this, and there is the code snip i'm testing currently:

wm = pyinotify.WatchManager()
notify = pyinotify.Notifier(wm)
wm.add_watch('/sys/devices/platform/coretemp.0/temp2_input', pyinotify.ALL_EVENTS)
notify.loop()

The problem is, i can't seem to get any kind of response out of this. The file content keeps changing, but inotify is dead silent. When i cat this file, it shows all events like it should, but it's not what i want obviously.

Is that even possible? If yes, can you give me a hint about what i'm doing wrong?

Last edited by kaszak696 (2013-02-12 15:53:49)


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#2 2013-02-12 11:32:22

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,221
Website

Re: [Nonsense][Python] Using inotify events to monitor temperature changes

You need to use inotifywait instead.

Offline

#3 2013-02-12 11:48:08

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: [Nonsense][Python] Using inotify events to monitor temperature changes

Ashren wrote:

You need to use inotifywait instead.

Same behavior.
I'm wondering if it's because these are not the 'real' files, just a representation of data from the kernel.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#4 2013-02-12 15:47:16

Stebalien
Member
Registered: 2010-04-27
Posts: 1,227
Website

Re: [Nonsense][Python] Using inotify events to monitor temperature changes


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#5 2013-02-12 15:52:33

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: [Nonsense][Python] Using inotify events to monitor temperature changes

I see, thanks.
I'm gonna stick with reading the file at interval inside a while loop.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

Board footer

Powered by FluxBB