First of all, you need a script to gather the information. You already have one mostly built, so use it as a template:
cp unix_processes.pl unix_apache_processes.pl
Edit that file so that it looks like this:
open(PROCESS, "ps ax | grep httpd | grep -c : |");
Now you need to set up Cacti to use that script. Go into the Console tab in Cacti and click on "Data Input Methods". Click "Add", and use the following values:
Name: Unix - Get Apache Processes
Input Type: Script/Command
Input String: perl
Save it, then go back in and click on "Add" for "Output Fields". Use the following values:
Field [Output]: proc
Friendly Name: Number of Apache Processes
Update RRD File: (checked)
Go ahead and save it. Now go into "Graph Templates" and find the "Unix - Processes" template. Put a check next to it, go find the drop-down box next to "Choose an action", set it to "Duplicate" and click "go". Change the title to "Unix - Apache Processes" and save it.
Go back into "Graph Templates" and click on the "Unix - Apache Processes" template that you just created. Find everything that says "Processes" and change it to say "Apache Processes", then save it.
Go into "Data Templates" and find "Unix Processes". Duplicate it like you did with the Graph Template, calling the new template "Apache Processes". Then go back into it and change the "Data Input Method" drop-down to "Unix - Get Apache Processes".
Go back into "Graph Templates", then "Unix - Apache Processes" again and click on "Item # 1". Change the "Data Source" drop-down to "Apache Processes - (proc)" and hit "save". Do the same for "Item # 2", "Item # 3" and "Item # 4".
Now when you go into the "Devices" menu and click on one of your web servers, you should see "Unix - Apache Processes" show up on the drop-down box for "Associated Graph Templates". Go ahead and add it, then go up to the top of the device page and click "Create Graphs for this Host". Put a check next to "Unix - Apache Processes" and click "Create".
Setting up this graph may be pretty straight-forward for the average Cacti user, but there are a lot of steps, and it helps to do them in the right order. This walkthrough should give you a good start for adding more complex graphs to Cacti when you need to.
thank for helpful how-to.ReplyDelete
But, this method cannot monitoring apache process on another sever(cacti device, SNMP host).
Is there anyway to do that?
t a e: I have seen a script laying around that supports running tests via SSH. If you're willing to use a password-less key, that would probably be worth taking a look at.ReplyDelete
You can solve this with user added MIBs on snmp client side. As a result of querying user added MIB this kind of script which output will cacti use for populating it's rrd files ...