LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 07-20-2010, 05:05 PM   #1
chuafengru
LQ Newbie
 
Registered: Jun 2010
Posts: 28

Rep: Reputation: 0
MySar Database


Hey,

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?

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

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
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, 04:16 PM   #3
chuafengru
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

Code:
// calculate the base path of the program
$basePath=realpath(dirname(__FILE__).'/../');

// Common tasks for both web and cmd
require($basePath.'/inc/common.inc.php');

require_once("gdgraph.php");
$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"';
$result1=db_select_all($allow);
$result2=db_select_all($deny);

$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
$gdg->pie_graph($arr);
//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, 04:58 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


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


All times are GMT -5. The time now is 08:15 PM.

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