LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-30-2006, 06:12 AM   #31
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63

If it runs from the command line but not from cron, it's 99% likely that the script relies on some environment variable which is not set by cron. I didn't analyse the whole script.

Just try it from the command line. If it works there but not cron, look for environment problems.

By the way, if you're going to be executing from cron, you don't want your program to keep running, or you'll get multiple instances of it accumulating...

To see if there was an error running from cron, check the local mail of the user whose crontab it was in (look in /var/mail/username, or /var/spool/mail/username). Also look in the system logs.
 
Old 11-30-2006, 08:01 AM   #32
meniscus
Member
 
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
This is so weird!

I repeated the whole hdd graphing tutorial with the following perl script.


Code:
#!/usr/bin/perl -w

# Perl script for graphing CPU temperature
# rrd_cputemp.pl



use RRDs;

# define location of rrdtool databases
my $rrd = '/var/lib/rrd';
# define location of images
my $img = '/var/www/html/rrdtool';

# process data for CPU temperature
&ProcessCPU("CPU temp", "Intel Prescott");


sub ProcessCPU
{
# process HDD
# inputs: $_[0]: processor temperature
#         $_[1]: processor description



	my $output = `sensors`;
	my $temp;
	if ( $output =~ /CPU Temp:\s*\+(\d+)/ ) {
    	$temp = $1; }
	
	
	print "$_[1] ($_[0]) temp: $temp degrees C\n";

	# if rrdtool database doesn't exist, create it
	if (! -e "$rrd/$_[0].rrd")
	{
		print "creating rrd database for /$_[0]...\n";
		RRDs::create "$rrd/$_[0].rrd",
			"-s 300",
			"DS:temp:GAUGE:600:0:100",
			"RRA:AVERAGE:0.5:1:576",
			"RRA:AVERAGE:0.5:6:672",
			"RRA:AVERAGE:0.5:24:732",
			"RRA:AVERAGE:0.5:144:1460";
	}

	# insert value into rrd
	RRDs::update "$rrd/$_[0].rrd",
		"-t", "temp",
		"N:$temp";

	# create graphs
	&CreateGraph($_[0], "day", $_[1]);
	&CreateGraph($_[0], "week", $_[1]);
	&CreateGraph($_[0], "month", $_[1]);
	&CreateGraph($_[0], "year", $_[1]);
}

sub CreateGraph
{
# creates graph
# inputs: $_[0]: CPU temp
#         $_[1]: interval (ie, day, week, month, year)
#         $_[2]: CPU description

	RRDs::graph "$img/$_[0]-$_[1].png",
		"--lazy",
		"-s -1$_[1]",
		"-t CPU temperature :: $_[2] ($_[0])",
		"-h", "80", "-w", "600",
		"-a", "PNG",
		"-v degrees C",
		"DEF:temp=$rrd/$_[0].rrd:temp:AVERAGE",
		"LINE2:temp#0000FF:$_[2] (/$_[0])",
		"GPRINT:temp:MIN:  Min\\: %2.lf",
		"GPRINT:temp:MAX: Max\\: %2.lf",
		"GPRINT:temp:AVERAGE: Avg\\: %4.1lf",
		"GPRINT:temp:LAST: Current\\: %2.lf degrees C\\n";
	if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] graph: $ERROR\n"; }
}
The only thing that differs from the hddgraphing 1 is the code in red!

When i run rdd_cputemp.pl i get the following

Code:
Intel Prescott (CPU temp) temp: 44 degrees C
creating rrd database for /CPU temp...
meniscus@meniscot:/usr/local/bin$ sudo rrd_cputemp.pl
Intel Prescott (CPU temp) temp: 43 degrees C
meniscus@meniscot:/usr/local/bin$ sudo rrd_cputemp.pl
Intel Prescott (CPU temp) temp: 44 degrees C
meniscus@meniscot:/usr/local/bin$ sudo gedit rrd_cputemp.pl
meniscus@meniscot:/usr/local/bin$ sudo rrd_cputemp.pl
Intel Prescott (CPU temp) temp: 43 degrees C
meniscus@meniscot:/usr/local/bin$

But the graph (ie in /var/www/html/rrdtool/CPU temp-day.png)

didnt update until the last time a ran it manually from the command line 43

It showed "nan" degrees the 1st 3 times?

The lines in crontab seem to make no difference!

It seems its only allowing me to run (sudo rrd_cputemp.pl) every couple of mins manually

With the lines added to crontab and i leave it for ten mins nothing happens!

The folders /var/mail and var/spool/mail are empty

Thats everything!
 
Old 11-30-2006, 10:44 AM   #33
meniscus
Member
 
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
That script is def excecuted in the command line each time. Theres just a delay before it appears!


Where can i find error logs about the thing you were talking about for crontab before?
 
Old 11-30-2006, 11:15 AM   #34
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
I think the exact location depends on your configuration, and can vary from distro to distro. For me cron logging goes into /var/log/syslog, but there may be a log file in the /var/log directory specifically for it, or a sub-directory with cron logs.
 
Old 11-30-2006, 11:37 AM   #35
meniscus
Member
 
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
Heres whats in my /var/log/syslo


Code:
Nov 30 16:20:01 localhost /USR/SBIN/CRON[17207]: (root) CMD (/usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:20:01 localhost /USR/SBIN/CRON[17209]: (root) CMD (root /usr/local/bin/rrd_cputemp.pl > /dev/null)
Nov 30 16:20:01 localhost /USR/SBIN/CRON[17211]: (root) CMD (root /usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:20:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:20:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:20:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:20:02 localhost sensord:   M/B Temp: 37 C (min = 15 C, max = 40 C)
Nov 30 16:20:02 localhost sensord:   CPU Temp: 43 C (min = 15 C, max = 45 C)
Nov 30 16:21:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:21:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:21:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:21:02 localhost sensord:   M/B Temp: 37 C (min = 15 C, max = 40 C)
Nov 30 16:21:02 localhost sensord:   CPU Temp: 43 C (min = 15 C, max = 45 C)
Nov 30 16:22:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:22:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:22:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:22:02 localhost sensord:   M/B Temp: 37 C (min = 15 C, max = 40 C)
Nov 30 16:22:02 localhost sensord:   CPU Temp: 43 C (min = 15 C, max = 45 C)
Nov 30 16:23:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:23:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:23:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:23:02 localhost sensord:   M/B Temp: 37 C (min = 15 C, max = 40 C)
Nov 30 16:23:02 localhost sensord:   CPU Temp: 55 C (min = 15 C, max = 45 C)
Nov 30 16:24:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:24:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:24:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:24:02 localhost sensord:   M/B Temp: 39 C (min = 15 C, max = 40 C)
Nov 30 16:24:02 localhost sensord:   CPU Temp: 58 C (min = 15 C, max = 45 C)
Nov 30 16:25:02 localhost /USR/SBIN/CRON[17311]: (root) CMD (/usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:25:02 localhost /USR/SBIN/CRON[17315]: (root) CMD (root /usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:25:02 localhost /USR/SBIN/CRON[17313]: (root) CMD (root /usr/local/bin/rrd_cputemp.pl > /dev/null)
Nov 30 16:25:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:25:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:25:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:25:02 localhost sensord:   M/B Temp: 40 C (min = 15 C, max = 40 C)
Nov 30 16:25:02 localhost sensord:   CPU Temp: 60 C (min = 15 C, max = 45 C)
Nov 30 16:26:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:26:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:26:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:26:02 localhost sensord:   M/B Temp: 41 C (min = 15 C, max = 40 C)
Nov 30 16:26:02 localhost sensord:   CPU Temp: 60 C (min = 15 C, max = 45 C)
Nov 30 16:27:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:27:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:27:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:27:02 localhost sensord:   M/B Temp: 41 C (min = 15 C, max = 40 C)
Nov 30 16:27:02 localhost sensord:   CPU Temp: 61 C (min = 15 C, max = 45 C)
Nov 30 16:28:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:28:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:28:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:28:02 localhost sensord:   M/B Temp: 42 C (min = 15 C, max = 40 C)
Nov 30 16:28:02 localhost sensord:   CPU Temp: 62 C (min = 15 C, max = 45 C)
Nov 30 16:29:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:29:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:29:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:29:02 localhost sensord:   M/B Temp: 43 C (min = 15 C, max = 40 C)
Nov 30 16:29:02 localhost sensord:   CPU Temp: 62 C (min = 15 C, max = 45 C)
Nov 30 16:30:02 localhost /USR/SBIN/CRON[17383]: (root) CMD (/usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:30:02 localhost /USR/SBIN/CRON[17385]: (root) CMD (root /usr/local/bin/rrd_cputemp.pl > /dev/null)
Nov 30 16:30:02 localhost /USR/SBIN/CRON[17387]: (root) CMD (root /usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:30:03 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:30:03 localhost sensord: Adapter: ISA adapter
Nov 30 16:30:03 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:30:03 localhost sensord:   M/B Temp: 43 C (min = 15 C, max = 40 C)
Nov 30 16:30:03 localhost sensord:   CPU Temp: 62 C (min = 15 C, max = 45 C)
Nov 30 16:31:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:31:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:31:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:31:02 localhost sensord:   M/B Temp: 43 C (min = 15 C, max = 40 C)
Nov 30 16:31:02 localhost sensord:   CPU Temp: 53 C (min = 15 C, max = 45 C)
Nov 30 16:32:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:32:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:32:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:32:02 localhost sensord:   M/B Temp: 42 C (min = 15 C, max = 40 C)
Nov 30 16:32:02 localhost sensord:   CPU Temp: 50 C (min = 15 C, max = 45 C)
Nov 30 16:33:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:33:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:33:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:33:02 localhost sensord:   M/B Temp: 41 C (min = 15 C, max = 40 C)
Nov 30 16:33:02 localhost sensord:   CPU Temp: 47 C (min = 15 C, max = 45 C)
Nov 30 16:33:51 localhost kernel: [4463049.007000] end_request: I/O error, dev fd0, sector 0
Nov 30 16:34:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:34:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:34:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:34:02 localhost sensord:   M/B Temp: 40 C (min = 15 C, max = 40 C)
Nov 30 16:34:02 localhost sensord:   CPU Temp: 48 C (min = 15 C, max = 45 C)
Nov 30 16:35:01 localhost /USR/SBIN/CRON[17534]: (root) CMD (/usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:35:01 localhost /USR/SBIN/CRON[17536]: (root) CMD (root /usr/local/bin/rrd_cputemp.pl > /dev/null)
Nov 30 16:35:01 localhost /USR/SBIN/CRON[17538]: (root) CMD (root /usr/local/bin/rrd_hddtemp.pl > /dev/null)
Nov 30 16:35:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:35:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:35:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:35:02 localhost sensord:   M/B Temp: 40 C (min = 15 C, max = 40 C)
Nov 30 16:35:02 localhost sensord:   CPU Temp: 50 C (min = 15 C, max = 45 C)
Nov 30 16:36:02 localhost sensord: Chip: it8712-isa-0290
Nov 30 16:36:02 localhost sensord: Adapter: ISA adapter
Nov 30 16:36:02 localhost sensord: Algorithm: ISA algorithm
Nov 30 16:36:02 localhost sensord:   M/B Temp: 39 C (min = 15 C, max = 40 C)
Nov 30 16:36:02 localhost sensord:   CPU Temp: 45 C (min = 15 C, max = 45 C)


There are no errors i can see but then again i dont know what im looking at half time!
 
Old 11-30-2006, 11:40 AM   #36
meniscus
Member
 
Registered: May 2006
Posts: 70

Original Poster
Rep: Reputation: 15
Wait a sec!

Why is there 2 logs each time for rdd_hddtemp.pl yet only 1 for rdd_cputemp.pl?

Is that the reason rdd_cputemp.pl graph wont continually update?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 04:23 AM
Send string to std output without interpreting (script) ta0kira Programming 6 06-29-2005 09:50 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 11:22 AM
how to find the pid of a perl script from shell script toovato Linux - General 1 12-19-2003 07:25 PM
Including methods from a perl script into another perl script gene_gEnie Programming 3 01-31-2002 06:03 AM


All times are GMT -5. The time now is 04:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration