connect HostMon with Cacti?

General chat about HostMonitor
Post Reply
mpilz
Posts: 6
Joined: Fri Sep 05, 2003 2:15 am

connect HostMon with Cacti?

Post by mpilz »

Hello,

I have some questions about your software ks Advanced Host Monitor. Is it possible to connect HostMon with Cacti? I wants to gather information with Hostmon and display (charts and reports) with cact.

Kind regards
Marko Pilz
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

What is Cacti?
http://www.cacti.net/ ?
Can it retrieve data from ODBC datasource?

Regards
Alex
mpilz
Posts: 6
Joined: Fri Sep 05, 2003 2:15 am

Post by mpilz »

Hello.
Sorry i was offline.....
Yes i mean www.cacti.net.
Cacti bases on the RRDTool.


Marko
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Hi,

I´m using hostmon to gather information an update an RRD database and using CGI pages to display the RRD graphs.

The steps are:

1 - RMA installed on the target machine retrieves information about the test every x seconds;

2 - Another test is configured in HM to run an action every x seconds using another RMA (installed on the same machine where the RRD base is) and update RRD using "Execute external program" action.

3 - CGI page is used to build a dynamic page based on RRD base;

Simple and works great. I believe you can use something like this with Cacti.

Regards,

Jromariz.
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

As I see Cacti does not work with ODBC data sources (or may be I missed that option?). I think method that Jromariz is using its probably the only solution -update RRD files using "Execute external program" action.

Regards
Alex
Antony

Post by Antony »

jromariz wrote:Hi,

I´m using hostmon to gather information an update an RRD database and using CGI pages to display the RRD graphs.

The steps are:

1 - RMA installed on the target machine retrieves information about the test every x seconds;

2 - Another test is configured in HM to run an action every x seconds using another RMA (installed on the same machine where the RRD base is) and update RRD using "Execute external program" action.

3 - CGI page is used to build a dynamic page based on RRD base;

Simple and works great. I believe you can use something like this with Cacti.

Regards,

Jromariz.
Jromariz: can you please help me do the same? My email is hehe at freemail.gr

Thanks in advance :wink:
jromariz
Posts: 264
Joined: Wed Apr 03, 2002 6:00 pm
Location: Brasil

Post by jromariz »

Hi Antony,


Of courde I can help you.

Just send you an e-mail.


Regards,

Jromariz.
mpilz
Posts: 6
Joined: Fri Sep 05, 2003 2:15 am

Post by mpilz »

really thx for the information.
i will test this next week.

marko
fzaleta
Posts: 2
Joined: Tue Nov 08, 2005 10:07 am
Location: Texas

Idea

Post by fzaleta »

I love HM... I think it's one of the best tools to collect performance data for servers. The reporting falls a bit short of what I am looking for though. I had had the idea of somehow merging HM with cacti but found no way of easily doing it without mucking with php code. Besides, all I need is the graphs...

Here's an idea that I am currently toying with... How about using a custom html report to generate XML files that the RRDTool in cacti can use to generate graphs?

According to this other post, you can generate an XML formatted report:

http://www.ks-soft.net/cgi-bin/phpBB/vi ... hlight=xml

Then using an external batch on a schedule task calling 'rrdtool restore' we can generate the rrd databases and the graphics. Maybe delete the xml file to conserve space.

http://people.ee.ethz.ch/~oetiker/webto ... re.en.html

Right now this is entirely theoretical as I've not tried it. But it's a way to look at it. One of the drawbacks I see is the size of the XML files, let's say, for a test you that runs every 5 minutes for 365 days a year (12 tests x 24hrs x 365 days = >100,000 tests)! However, daily and monthly graphs are manageable.

What do you guys think? If anyone's tried something like this or has any comments, please post back. Thanks!
Dag Ragnar Vikjord
Posts: 3
Joined: Wed May 10, 2006 5:48 am
Location: Norway
Contact:

Post by Dag Ragnar Vikjord »

jromariz wrote:Hi,

I´m using hostmon to gather information an update an RRD database and using CGI pages to display the RRD graphs.

The steps are:

1 - RMA installed on the target machine retrieves information about the test every x seconds;

2 - Another test is configured in HM to run an action every x seconds using another RMA (installed on the same machine where the RRD base is) and update RRD using "Execute external program" action.

3 - CGI page is used to build a dynamic page based on RRD base;

Simple and works great. I believe you can use something like this with Cacti.

Regards,

Jromariz.
Hi Jromariz. can you please help me do the same to? :oops:

Thanks in advance! :D
ironmike
Posts: 15
Joined: Sun Jun 22, 2003 6:00 pm
Contact:

Post by ironmike »

Using hostmonitor/cacti is possible (I currently have this setup on a Windows 2003 server). It does take a bit of doing. Basically, you use the MySQL server to hold the hostmonitor data (same server that host the cacti data).

You will need to create a new catalog (I called mine hostmonitor, and created a hmlog table within it that had the fields that I cared about (DateTime, Testname, StatusID, Reply) in the MySQL DB.

Create a user that has access to this catalog (Right now, the user has all privileges except drop and grant)

You will need to create a (system) ODBC source for the mySQL database (using the user created above).

Here's the overview on how it's done
1) Go into hostmonitor, advanced logs. Set the logging sql based on the fields that you want, for example:
Insert into hmlog (cDateTime, TestName, StatusID, Reply) VALUES (Now(), '%Folder%\\%TestName%','%StatusID%','%Reply_Number%')
2) You will need to use a script query to access the data. Here's some sample code to get you going... I am no PHP guru, BTW...

Code: Select all

 <?php	
	if ($argc < 2) {
		Die("Please specify a Testname to query.");
	}

	$TestName=$argv[1];

	$database="hostmonitor";
	$username="myuser";
	$password="mypassword";

	mysql_connect("localhost",$username,$password);
	@mysql_select_db($database) or die("Unable to select database");
	$query = "Select avg(Reply) as AvgReply from hmlog WHERE cDateTime > DATE_SUB(NOW(), INTERVAL 5 MINUTE) AND Testname='".$TestName."'";

	$qry_result=mysql_query($query);
	mysql_close();

	if (!$qry_result) {
		die("MSSQL Error: ".mysql_error());
	}

	$myReply = mysql_Result($qry_result,0,"AvgReply");
	if (strlen($myReply) < 1) {
		print Trim("0");
	}
	else {
		print trim($myReply);
	}
?>
3) Set up a data input method to run the script. Call it "Get HostMon Data"
  • Input type is "Script/Command"
    Input string is c:\php\php.exe c:\\cacti\scripts\hostmon.php <TestName>
    Create an input field ("Testname" in my example). I created template and put in "hostname" (without quotes) in the special type code text box. If you are not creating templates, you may not need to do this...
    Output field is set to some name (myResult, for example).
4) Add a Data source (no template need be selected). When you click on the "Create" button, you will see more choices in setting up the data source. You will need to choose the data input method as the one that we just atted in step 3 above.
5) Hit the "Create" button one more time after filling out the respective fields that you need and you will see a Custom data header that prompts you for the "Testname". This would be the full testname. Careful when naming the tests.
6) Click on the save button.
7) From there, you will need to create the graph under Graph management. I will not go into detail on this, as how to create (simple) graphs is documented in the manual/online/forum....

Some things that I found while doing this:
  • * When using the script server (not the script/query), spaces in the testname (from hostmonitor) are not a good thing. For example, "Yahoo Ping" is bad, but "YahooPing" is OK.
    * The mySQL query browser is a good tool to use in debugging queries to "feed" to cacti (when you are not getting any results back from cacti and wondering what is going on...).
    * I created a scheduled job to run a query every 30 minutes to delete record with a date/time older than 30 minutes:

    Code: Select all

    C:\mysql\bin\mysql.exe --database=hostmonitor --password=sql4u --user=root --execute="Delete from hmlog WHERE DATE_SUB(NOW(), INTERVAL '30' MINUTE) >`hostmonitor`.`hmlog`.`cDateTime`;"
    This keeps the mySQL Db catalog for hostmonitor reasonable in size.
Hope this helps some people out.

Mike
Dag Ragnar Vikjord
Posts: 3
Joined: Wed May 10, 2006 5:48 am
Location: Norway
Contact:

Post by Dag Ragnar Vikjord »

I will try it out!
Thanks! :D
Post Reply