Re: KDE and hdparm (was: Re: [gentoo-user] Disable fcron logging)

2010-08-30 Thread Mick
On 24 August 2010 14:31, Alex Schuster wo...@wonkology.org wrote:
 Mick writes:

 On Sunday 22 August 2010 22:39:47 Alex Schuster wrote:

  BTW, my two additional drives spin up when I log into KDE. Weird,
  they are not even mounted.

 From KDE-4.4.4 the start up interferes with the hard drives:

 http://thread.gmane.org/gmane.linux.gentoo.user/232044

 I don't why but it does, messes up any settings that hdparm may have
 set up and p*sses me off.  o_O

 As soon as KDE starts up (even when waking up from suspend to ram) it
 resets the drives.  I haven't found a way of telling it how to behave
 (i.e. by respecting existing settings in hdparm).

 Argh, that's annoying. Thanks for the information. O well, first I
 setuid'ed hdparm to make it work as a user, then I reverted that back as I
 started it in /etc/init.d/local, and now I'm again setuid'ing it so I can
 set the settings from /etc/conf.d/hdparm in ~/.kde4/Autostart/.

 I filed a bug: https://bugs.kde.org/show_bug.cgi?id=248905
 You might want to vote for it so it gets some attention and will hopefully
 be fixed soon.

Thanks Wonko,

As reported on https://bugs.gentoo.org/show_bug.cgi?id=334393 the workaround of:

touch /etc/pm/power.d/harddrive

stops KDE4.4.4/5 from messing up the existing hdparm settings (at
least as far as acoustic management is concerned).  At least now I
don't have to listen this Seagate sata rattling all day!  :-)
-- 
Regards,
Mick



Re: [gentoo-user] Disable fcron logging

2010-08-24 Thread Alan McKinnon
Apparently, though unproven, at 00:12 on Tuesday 24 August 2010, Alex Schuster 
did opine thusly:

  Configure your syslogger to devnull these specific entries.
  All three common sysloggers (syslogd,syslog-ng,rsyslog) all come with
  extensive documentation on how to do this.
 
 Hmm, okay. I think there is no perfect solution. When I disable logging of 
 this PAM stuff, I can only disable it completely, but what if I want to 
 keep the logging from other jobs that are not run that often? Although for 
 this case I can use the direct logging of fcron (without nolog), so this 
 is quite academic. Can anybody still follow me? But thanks for the 
 clarification.


I use syslog-ng and that allows you to write a custom rule looking for the app 
that generated the log [fcron] and a string in the log entry 
pam_unix(fcron:session). You can then filter it out.

However you do it, the solution is quite fragile and very specific to your 
setup. A general solution that works everywhere will be difficult to form.

-- 
alan dot mckinnon at gmail dot com



KDE and hdparm (was: Re: [gentoo-user] Disable fcron logging)

2010-08-24 Thread Alex Schuster
Mick writes:

 On Sunday 22 August 2010 22:39:47 Alex Schuster wrote:

  BTW, my two additional drives spin up when I log into KDE. Weird,
  they are not even mounted.
 
 From KDE-4.4.4 the start up interferes with the hard drives:
 
 http://thread.gmane.org/gmane.linux.gentoo.user/232044
 
 I don't why but it does, messes up any settings that hdparm may have
 set up and p*sses me off.  o_O
 
 As soon as KDE starts up (even when waking up from suspend to ram) it
 resets the drives.  I haven't found a way of telling it how to behave
 (i.e. by respecting existing settings in hdparm).

Argh, that's annoying. Thanks for the information. O well, first I 
setuid'ed hdparm to make it work as a user, then I reverted that back as I 
started it in /etc/init.d/local, and now I'm again setuid'ing it so I can 
set the settings from /etc/conf.d/hdparm in ~/.kde4/Autostart/.

I filed a bug: https://bugs.kde.org/show_bug.cgi?id=248905
You might want to vote for it so it gets some attention and will hopefully 
be fixed soon.

Wonko



Re: [gentoo-user] Disable fcron logging

2010-08-23 Thread Stroller


On 22 Aug 2010, at 22:39, Alex Schuster wrote:

Stroller writes:


The script with which you reply is missing the sleep 60 loop.


No, it's only the script that outputs the drive's state. It's called  
by

~/.kde4/Autostart/hdstate:

#!/bin/bash

while :
do
   /usr/local/sbin/hdstate  ~/log/hdstate.log
   sleep 10
done


You wrote to the list telling us that you were running a script from  
cron every minute, and that this was causing your log file to fill up  
with messages from cron.


That is what I replied to.

Please do not move the goalposts halfway through the thread, and make  
it about something else unrelated. That is the perfect way to annoy  
people who are trying to help you.



Stroller.



Re: [gentoo-user] Disable fcron logging

2010-08-23 Thread Alex Schuster
Stroller writes:

 On 22 Aug 2010, at 22:39, Alex Schuster wrote:
 Stroller writes:

 The script with which you reply is missing the sleep 60 loop.

 No, it's only the script that outputs the drive's state. It's called  
 by ~/.kde4/Autostart/hdstate:

 #!/bin/bash

 while :
 do
/usr/local/sbin/hdstate  ~/log/hdstate.log
sleep 10
 done
 
 You wrote to the list telling us that you were running a script from  
 cron every minute, and that this was causing your log file to fill up  
 with messages from cron.
 
 That is what I replied to.

Yes, I know. You had the good idea of simply putting the script into a
loop, and I actually followed your advice by now. When I posted my first
script in response to yours, I just wanted to show how I got the
relevant information in a more convenient format, using hdparm and
hddtemp, than using the direct output of smartctl. Just in case someone
else also likes this. Of yourse the outer loop was missing, but I did
not bother to add this trivial addition just for the posting here. It's
just the script I was already using in cron. And later in the posting I
mentioned that the script itself should be run in a loop instead of
cron, also because I could decrease the update interval.

Sorry, I probably should have made clear that the original question was
sort of solved.

 Please do not move the goalposts halfway through the thread, and make  
 it about something else unrelated. That is the perfect way to annoy  
 people who are trying to help you.

I'm sorry about this, I did not mean to annoy anyone. But I still do not 
really seewhat the problem is. You had the idea to do this without cron, 
and so I did. Well, I forgot a 'thank you' for the loop idea, this is 
true. Sorry again. Your ideas were appreciated as always.

Wonko



Re: [gentoo-user] Disable fcron logging

2010-08-23 Thread Alex Schuster
Alan McKinnon writes:

 Apparently, though unproven, at 15:25 on Saturday 21 August 2010, Alex
 Schuster did opine thusly:

  There is a nolog option for fcrontab, but I still get this output
  every minute:
 That will tell fcron not to log stuff.
 It will not tell other apps to not stuff

Right. But I did not know that there are more things involved than cron 
itself and the command I am calling. This PAM stuff is new to me, but 
maybe I just never noticed it before in my logs. It's no problem when it's 
not coming every minute.

  Aug 21 15:10:06 [fcron] pam_unix(fcron:session): session opened for
  user root by (uid=0) Aug 21 15:10:08 [fcron]
  pam_unix(fcron:session): session closed for user root
  
  Hmmm... could it be that these entries do not come from fcron itself,
  but from PAM?
 
 Yes.
 
 Configure your syslogger to devnull these specific entries.
 All three common sysloggers (syslogd,syslog-ng,rsyslog) all come with
 extensive documentation on how to do this.

Hmm, okay. I think there is no perfect solution. When I disable logging of 
this PAM stuff, I can only disable it completely, but what if I want to 
keep the logging from other jobs that are not run that often? Although for 
this case I can use the direct logging of fcron (without nolog), so this 
is quite academic. Can anybody still follow me? But thanks for the 
clarification.

Meanwhile, I have the script running in /etc/conf.d/local.start, so I have 
no syslog output at all and I also can have more updates than only once 
per minute.

Wonko



Re: [gentoo-user] Disable fcron logging

2010-08-22 Thread Alex Schuster
Stroller writes:

 On 21 Aug 2010, at 14:25, Alex Schuster wrote:
  ...
  I want to monitor the power status of my hard drives, so I wrote a
  little
  script that gives me this output:
  
  sda: standby
  sdb: standby
  sdc: active/idle 32°C
  sdd: active/idle 37°C
  
  This script is called every minute via an fcron entry, output goes
  into a log file, and I use the file monitor plasmoid to watch this log
  file in KDE.
  
  It's working fine, but  also monitor my syslog in another file
  monitor plamoid, and now I get lots of these entries:
  
  Aug 21 14:21:06 [fcron] pam_unix(fcron:session): session opened for
  user root by (uid=0)
  Aug 21 14:21:06 [fcron] Job /usr/local/sbin/hdstate  /var/log/
  hdstate started for user root (pid 24483)
  Aug 21 14:21:08 [fcron] Job /usr/local/sbin/hdstate  /var/log/
  hdstate completed
  Aug 21 14:21:08 [fcron] pam_unix(fcron:session): session closed for
  user root
 
 #!/bin/bash
 while true
 do
for drive in a b c d
do
   /usr/sbin/smartctl /dev/sd$drive --whatever  /var/log/hdstate
done
 sleep 60
 done

I use hdparm and hddtemp:

for hd in sda sdb sdc sdd
do
str=$( /sbin/hdparm -C /dev/$hd )
state=${str##*is:  }
if [[ $state == active/idle ]]  [[ $hd =~ sd[c] ]]
then
temp=$( /usr/sbin/hddtemp -q /dev/$hd )
temp=${temp% or *}
temp=${temp##* }
else
temp=
fi
echo $hd: $state $temp
done

Unfortunately, reading the temperature makes a drive in standby spin up, 
and prevents automatic spindown after a while of idle time. So now I ask 
for the temperature only on my system drive, the others should sleep most 
of the time anyway.


 I would personally update more often than this, and my concern would
 be that if the process fails then your plasmoid isn't showing the
 correct data.
 
 I presume this is the same with your current setup: if cron dies then
 the current temperature will not be read to file, and the plasmoid
 will continue reading the last lines in /var/log/hdstate - the drive
 can overheat without you knowing about it.

Nah, it's really not that important for me. I show the temperature just 
for the fun of it, and for extreme temperatures I have smartd running, see 
below.
I'm more interested in the active/standby state. I just added two old 
additonal IDE drives for additional backups, and I want them to be silent 
most of the time. So I wrote a little script to show the status so I see 
when they spin up again (and they do this sometimes), and used fcron to 
get the data into a log file that the plasmoids shows.

The problem with cron is that I get those cron logs I do not like, and 
that the update time of 60 seconds is a little long. Running the script in 
a loop, started in .kde4/Autostart, would be better, but as a user I have 
no permission to call hdparm or hdtemp. I do not want to be part of the 
disk group, and when using sudo I would get the logs by sudo I wanted to 
avoid. So now I SUID'ed hdparm and hddtemp, changed the group to wheel and 
disabled execution for others. cron problem not solved, but workarounded.


 So I would expect there to be a better plasmid for this task. I'm
 completely unfamiliar with plasmids, but what you really want is a
 plasmid that itself runs a script and displays the stdout on your
 screen. That way if there's no data, or an error, then _you see that
 in the plasmid_, instead of silently ignoring it (as you may be at
 present).
 
 The easiest (but dumb) way to handle this is to add the date to your
 plasmid's display so that at least you can see that something's wrong
 if it doesn't match the clock. A better way is not to have to watch a
 status monitor at all, and just have a script running that emails you
 if the temperature is above a specified range.

I have smartd running, which should send me mails about such things. For 
each drive, I have a line like this in /etc/smartd.conf:

/dev/sdc -a -n standby -o on -S on -W 5,40,45 \
 -s (S/../.././12|L/../../06/06) -m r...@wonkology.org

This does some regular health checks on the drive, when it is not in 
standby mode. Temperature changes of more than 5 degrees and temperatures 
of 40 degrees or more are logged. I will receive an email when the 
temperature reaches 45 degrees, or when it reaches a new maximum. The 
maximum values are preserved across boot cycles (option -S). Every day at 
12:00, a short self test is scheduled, and a long self test each sunday on 
06:00.

Wonko



Re: [gentoo-user] Disable fcron logging

2010-08-22 Thread Stroller


On 22 Aug 2010, at 20:00, Stroller wrote:

On 22 Aug 2010, at 11:26, Alex Schuster wrote:

Stroller writes:



#!/bin/bash
while true
do
 for drive in a b c d
 do
/usr/sbin/smartctl /dev/sd$drive --whatever  /var/log/hdstate
 done
sleep 60
done


I use hdparm and hddtemp:

for hd in sda sdb sdc sdd
do
...
echo $hd: $state $temp
done


The script with which you reply is missing the sleep 60 loop.


...
The problem with cron is that I get those cron logs I do not like,  
and
that the update time of 60 seconds is a little long. Running the  
script in
a loop, started in .kde4/Autostart, would be better, but as a user  
I have
no permission to call hdparm or hdtemp. I do not want to be part of  
the
disk group, and when using sudo I would get the logs by sudo I  
wanted to
avoid. So now I SUID'ed hdparm and hddtemp, changed the group to  
wheel and
disabled execution for others. cron problem not solved, but  
workarounded.


Running a script which contains `while true ... sleep 60` will cause  
only a single logging action. You can run it as root at startup  
using /etc/conf.d/local.start and have the file world readable.


Sorry, this wasn't very clear:

If your script contains `while true ... sleep 60` then you'll only  
need to run it once.


Stroller.




Re: [gentoo-user] Disable fcron logging

2010-08-22 Thread Alex Schuster
Stroller writes:

 The script with which you reply is missing the sleep 60 loop.

No, it's only the script that outputs the drive's state. It's called by 
~/.kde4/Autostart/hdstate:

#!/bin/bash

while :
do
/usr/local/sbin/hdstate  ~/log/hdstate.log
sleep 10
done

 Running a script which contains `while true ... sleep 60` will cause
 only a single logging action. You can run it as root at startup using /
 etc/conf.d/local.start and have the file world readable.

Yeah, local.start woudl also be a good idea, without the need to setuid 
things. Maybe I'll change this.

BTW, my two additional drives spin up when I log into KDE. Weird, they are 
not even mounted.

Wonko



Re: [gentoo-user] Disable fcron logging

2010-08-22 Thread Mick
On Sunday 22 August 2010 22:39:47 Alex Schuster wrote:
 Stroller writes:
  The script with which you reply is missing the sleep 60 loop.
 
 No, it's only the script that outputs the drive's state. It's called by
 ~/.kde4/Autostart/hdstate:
 
 #!/bin/bash
 
 while :
 do
 /usr/local/sbin/hdstate  ~/log/hdstate.log
 sleep 10
 done
 
  Running a script which contains `while true ... sleep 60` will cause
  only a single logging action. You can run it as root at startup using /
  etc/conf.d/local.start and have the file world readable.
 
 Yeah, local.start woudl also be a good idea, without the need to setuid
 things. Maybe I'll change this.
 
 BTW, my two additional drives spin up when I log into KDE. Weird, they are
 not even mounted.

From KDE-4.4.4 the start up interferes with the hard drives:

http://thread.gmane.org/gmane.linux.gentoo.user/232044

I don't why but it does, messes up any settings that hdparm may have set up 
and p*sses me off.  o_O

As soon as KDE starts up (even when waking up from suspend to ram) it resets 
the drives.  I haven't found a way of telling it how to behave (i.e. by 
respecting existing settings in hdparm).
-- 
Regards,
Mick


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] Disable fcron logging

2010-08-21 Thread Alan McKinnon
Apparently, though unproven, at 15:25 on Saturday 21 August 2010, Alex 
Schuster did opine thusly:

 Hi there!
 
 I want to monitor the power status of my hard drives, so I wrote a little
 script that gives me this output:
 
 sda: standby
 sdb: standby
 sdc: active/idle 32°C
 sdd: active/idle 37°C
 
 This script is called every minute via an fcron entry, output goes into a
 log file, and I use the file monitor plasmoid to watch this log file in
 KDE.
 
 It's working fine, but  also monitor my syslog in another file monitor
 plamoid, and now I get lots of these entries:
 
 Aug 21 14:21:06 [fcron] pam_unix(fcron:session): session opened for user
 root by (uid=0) Aug 21 14:21:06 [fcron] Job /usr/local/sbin/hdstate 
 /var/log/hdstate started for user root (pid 24483) Aug 21 14:21:08 [fcron]
 Job /usr/local/sbin/hdstate  /var/log/hdstate completed Aug 21 14:21:08
 [fcron] pam_unix(fcron:session): session closed for user root
 
 There is a nolog option for fcrontab, but I still get this output every
 minute:

That will tell fcron not to log stuff. 
It will not tell other apps to not stuff

 Aug 21 15:10:06 [fcron] pam_unix(fcron:session): session opened for user
 root by (uid=0) Aug 21 15:10:08 [fcron] pam_unix(fcron:session): session
 closed for user root
 
 Hmmm... could it be that these entries do not come from fcron itself, but
 from PAM? 

Yes. 

Configure your syslogger to devnull these specific entries.
All three common sysloggers (syslogd,syslog-ng,rsyslog) all come with 
extensive documentation on how to do this.



-- 
alan dot mckinnon at gmail dot com



Re: [gentoo-user] Disable fcron logging

2010-08-21 Thread Stroller


On 21 Aug 2010, at 14:25, Alex Schuster wrote:

...
I want to monitor the power status of my hard drives, so I wrote a  
little

script that gives me this output:

sda: standby
sdb: standby
sdc: active/idle 32°C
sdd: active/idle 37°C

This script is called every minute via an fcron entry, output goes  
into a
log file, and I use the file monitor plasmoid to watch this log file  
in

KDE.

It's working fine, but  also monitor my syslog in another file monitor
plamoid, and now I get lots of these entries:

Aug 21 14:21:06 [fcron] pam_unix(fcron:session): session opened for  
user root by (uid=0)
Aug 21 14:21:06 [fcron] Job /usr/local/sbin/hdstate  /var/log/ 
hdstate started for user root (pid 24483)
Aug 21 14:21:08 [fcron] Job /usr/local/sbin/hdstate  /var/log/ 
hdstate completed
Aug 21 14:21:08 [fcron] pam_unix(fcron:session): session closed for  
user root



#!/bin/bash
while true
do
  for drive in a b c d
  do
 /usr/sbin/smartctl /dev/sd$drive --whatever  /var/log/hdstate
  done
sleep 60
done


I would personally update more often than this, and my concern would  
be that if the process fails then your plasmoid isn't showing the  
correct data.


I presume this is the same with your current setup: if cron dies then  
the current temperature will not be read to file, and the plasmoid  
will continue reading the last lines in /var/log/hdstate - the drive  
can overheat without you knowing about it.


So I would expect there to be a better plasmid for this task. I'm  
completely unfamiliar with plasmids, but what you really want is a  
plasmid that itself runs a script and displays the stdout on your  
screen. That way if there's no data, or an error, then _you see that  
in the plasmid_, instead of silently ignoring it (as you may be at  
present).


The easiest (but dumb) way to handle this is to add the date to your  
plasmid's display so that at least you can see that something's wrong  
if it doesn't match the clock. A better way is not to have to watch a  
status monitor at all, and just have a script running that emails you  
if the temperature is above a specified range.


Stroller.