Script to check mem paging with sar - no data in 1 field

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Ok, lvm remember this. G, edit the graph template and select each of the data sources. Verify that the right associated graph items is selected for each data source. Then save. See what happens. :(

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
guido90210
Posts: 14
Joined: Sun May 07, 2006 10:45 pm
Location: About 70cms from my screen

Post by guido90210 »

Hi TheWitness,

OK, did what you suggest and same result.

I have noticed, however, that it is not the *last* value that the poller isn't getting when it runs the script - it's the *first* value, but it thinks it is the first field... i.e.:

When I run the script from the command line, I get this:

paged_in:0.00 paged_out:135.88 page_faults:0.00 major_faults:0.00

The cacti log says this, however:

05/19/2006 11:15:06 AM - CMDPHP: Poller[0] Host[2] DS[22] CMD: sh /usr/local/inst/cacti-0.8.6h/scripts/memory_paging.sh, output: paged_in:135.88 paged_out:0.00 page_faults:0.00

It seems to be thinking the the '135.88' value is the value for 'paged_in', when it is actually the value for 'paged_out' when I run the script from the command line.

Thanks,
G.
guido90210
Posts: 14
Joined: Sun May 07, 2006 10:45 pm
Location: About 70cms from my screen

Post by guido90210 »

One thing I didn't mention is that the box that Cacti runs on is actually RHEL3 as a guest OS in VMWare ESX 2.5.3. Sorry, don't know how I failed to mention that 8-(

Anyway, I've done a bit more playing around, and in <cacti-home>/lib/poller.php, when it executes exec_poll for my script, it doesn't get the correct data. Instead, it gets this:

paged_in:103.73 paged_out:0.00 page_faults:0.00 major_faults:

(I determined this by putting a cacti_log line to log the value of $output right after the '$output = fgets($fp, 4096);' line in the exec_poll function in <cacti-home>/lib/poller.php .)

Running the script from the command line gives this:

paged_in:0.00 paged_out:103.73 page_faults:0.00 major_faults:0.00

So it's losing the first value (the value for 'paged_in'), and using the value for the second field ('paged_out') as the value for the first field ('paged_in'), and using the value for the third field ('page_faults') as the value for the second field ('paged_out'), and using the value for the fourth field ('major_faults') as the value for the third field ('page_faults').

If I get time next week, I'll run up Cacti, MySQL, Apache and RRDTool on a spare box with RHEL3 (but without VMWare) and see if the same thing happens. I may try it on the same box with PHP4 before all that...

Ciao,
G.
guido90210
Posts: 14
Joined: Sun May 07, 2006 10:45 pm
Location: About 70cms from my screen

Post by guido90210 »

Hello again,

I've found out what is happening...

The output of 'sar -B' is like this:

[ lots of stuff, and then... ]
12:54:01 PM 2.77 91.48 0.00 0.00
12:59:01 PM 0.15 79.59 0.00 0.00
01:04:01 PM 44.03 102.29 0.00 0.00
01:09:02 PM 0.08 102.89 0.00 0.00
01:14:01 PM 0.00 113.23 0.00 0.00
01:19:01 PM 0.15 138.57 0.00 0.00
Average: 0.48 95.82 0.00 0.00

My shell script uses awk to print the 3rd, 4th, 5th and 6th variables from the second-last line of the output above.

When I run my script from the command line, awk parses the variables 'correctly' (in my view), seeing '01:19:01' as $1, 'PM' as $2, and the four floating-point numbers as $3, $4, $5 and $6.

When this script gets run through the cronned poller.php, for some reason, awk sees '01:19:01 AM' as $1. Therefore, the four floating-point numbers are $2, $3, $4 and $5.

I've googled a bit using terms like 'php cli environment awk' etc., but can't find anything that might explain why this happens.

I'm going to try to find out why this happens, and if I do, I'll post it here.

In the meantime, thanks Reinhard and TheWitness for responding.

-- G.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests