Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-20-2010, 06:05 PM   #1
LQ Newbie
Registered: Jun 2010
Posts: 28

Rep: Reputation: 0
MySar Database


How can i query data to do a count on the number of 'TCP_Denied' traffics from mysar database, into my PHP file. Cause i need it to generate a pie chart. I have been analysing the /var/www/html/mysar/www/index.php file on the queries, but i cant seem to make it work even if i tried to emulate it.

Any suggestions?

Old 07-21-2010, 04:42 PM   #2
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347
MySar is not a data base. It's a MySql application and browser front-end to the underlying MySql db. So, to do what you want, you just need to write a SQL query against the actual data base, and run it in MySql. (Look in the MySar documentation to fine the MySql data base name and table layout(s).)
Old 07-21-2010, 05:16 PM   #3
LQ Newbie
Registered: Jun 2010
Posts: 28

Original Poster
Rep: Reputation: 0
PHP problem

Okay now that i know MySar database name and stuff, i start to query some data off the database and tries to plug the variable into the 'pie_graph_example.php'. However i am not able to get the graph to display correctly. Or im doing it wrong ?

FYI the pie graph php is located in the same directory as the index.php of mysar
This is the coding for pie_graph_example.php

// calculate the base path of the program

// Common tasks for both web and cmd

$gdg = new GDGraph(500,300,"Activity Summary");

$allow='SELECT COUNT(resultCode) FROM traffic WHERE resultCode="TCP_MISS/200"';
$deny='SELECT COUNT(resultCode) FROM traffic WHERE resultCode="TCP_DENIED/403"';

$arr = Array(
			'Allowed' => Array($result1,200,100,1000),
			'Denied' => Array($result2,200,200,10),

$arr_3D = Array(
			'First Trimester' => 15,
			'Second Trimester' => 0,

//Example 1
//print $result;

i tried to the print $result. But the webpage shows a 'Array' word only. Help will be appreciated, thanks!
Old 07-21-2010, 05:58 PM   #4
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
I think you should grab a good introductory book to
PHP, namely the handling of variables.


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
Squid Reports Using MySar and Dansguardian jvaldivia Linux - Server 1 04-04-2010 11:53 AM
NTOP Error Traversing Database for ipnum = - Perhaps database is corrupt? soslinux Linux - Networking 2 03-03-2010 07:28 AM
DBI Connect Failed:Access denied for user ''@'localhost' to database <database> error kaplan71 Linux - Software 3 06-05-2009 01:39 PM
Squid log with MYSAR nkutty Linux - Software 0 06-09-2008 07:40 AM
Database Programming (database to database transaction) johncsl82 Programming 7 02-02-2007 09:20 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:50 PM.

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