Shell script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
elayaraja.s
Cacti User
Posts: 137
Joined: Mon Feb 11, 2008 3:46 am

Shell script

Post by elayaraja.s »

I have created one simple shell script as follows,

-------------------------
process.sh

ps -ef
-------------------------

I configure the same script(process.sh) in cacti by using DataInputMethod and created other stuffs DataTemplate,GraphTemplate.
The output of the process(process -ef) i would like to monitor in the graph... Any one could you please confirm whether i am doing correct...
Attachments
DataInputMethod.PNG
DataInputMethod.PNG (64.13 KiB) Viewed 6928 times
sigey
Posts: 25
Joined: Mon Feb 14, 2005 9:17 am
Location: MV
Contact:

Post by sigey »

do u want to graph the number of process, if so ur script should be able to list the number of process.

The approach u are trying with the data input method is the way to go.
sigey
Posts: 25
Joined: Mon Feb 14, 2005 9:17 am
Location: MV
Contact:

Post by sigey »

check this script originally from cacti package, called unix_process.pl

processes.pl

#!/usr/bin/perl

open(PROCESS, "ps ax | grep -c : |");
$output = <PROCESS>;
close(PROCESS);
chomp($output);
print $output;
elayaraja.s
Cacti User
Posts: 137
Joined: Mon Feb 11, 2008 3:46 am

Apache mod_status

Post by elayaraja.s »

Thanks for your reply. Its very usefull for me... Do u have any idea how to find the NumberOfThreads... from apche.. << mod_status >> ?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please search the Scripts and Templates forum for apache_stats templates. They are used quite often and should provide this information
Reinhard
elayaraja.s
Cacti User
Posts: 137
Joined: Mon Feb 11, 2008 3:46 am

Shell script not executed by poller.shp

Post by elayaraja.s »

I have configured the shell script(NoOfThread.sh) in DataInputMethod. Its just has the content of printf statement such as

----NoOfThread.sh start ----------
#!/bin/sh
printf '10'
printf '10'
printf '10'
printf '10'
printf '10' >> shellScriptStatus.log

----NoOfThread.sh End ----------


rrd files get generated by the poller. But there is no data in my graph. I verfied the degug link:http://docs.cacti.net/node/283

Note: I would like to confirm whether the shell script file is executed or not. My log file shellScriptStatus.log is not generated. How to execute this shell script through cacti poller.ph. I already have crontjob which my poller.php executes successfully.

Please advice if i am wrong. How to populate the data in my graph. Find the attached screenshots for my DataInputMethod configuration.
Attachments
screenShots.PNG
screenShots.PNG (91.43 KiB) Viewed 6552 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

You're completely wrong; sorry to mention this.
First, you're counting processes on local host only (the ps -ef is executed locally!).
Second, you did not follow my advice given at the first link of my sig (The Chapter on Creating a Script for Cacti). The data input method requires an output parm at least.

Please try to execute step by step of this howto. Hoepfully, everything will work. Afterwards, you may copy this example to solve your problem
Reinhard
elayaraja.s
Cacti User
Posts: 137
Joined: Mon Feb 11, 2008 3:46 am

Post by elayaraja.s »

Thanks for your info. I followed your instructions. I had configured the scirpt in DataInputMethod and i tried as follows

1) /bin/sh <path_cacti>/scripts/NoOfThread.sh
2) <path_cacti>/scripts/NoOfThread.sh

CrontJob executing the Poller file with user 'apache'. Whenever cronjob runs, the log file shows as

sh: /exec/products/apache/v223/www/html/cacti/scripts/NoOfThread.sh: Permission denied

Even i tired to change my script folder to chown -R apache:apache scripts/

but no updates. could any one guide for the same.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests