Hi All,
I'm very new to cacti. Anyhow I was able to successfully setup cacti on my centos server and started monitoring other servers which most of them are Linux/Unix servers.
I need to monitor
Load average,
Mem usage,
Process information
Apart from this there are 3 servers which run glassfish V3. I need to get specific values from the server.log in those 3 servers.
To do that With the help of my fellow perl guy, I used the following script. This searchinfo.pl script is in the local-cacti server and it doesn't have the glassfish installed on it.
This script suppose to get average, maximum and minimum values which can get from the server.log.
I've created new DataInput method, Data Template and graph template for this.
But unfortunately nothing is displaying in the graphs.
I've attached my script and some screenshots from cacti.
Please can anyone help me to getover with this..?
Is this possible method of collecting desired data from remote hosts..?
The scrip is in the <path_cacti>/scripts/searchinfo.pl
But when i ran the searchinfo.pl script at the remote server as..
(remote_server)$ ./searchinfo.pl /usr/local/user/glassfishv3/glassfish/domains/My_t/logs/ TST MAX 50
it giving me the expected values.
If i put ALL insted of MAX, AVG or MIN, in above scenario, it also giving 3 out put as expected.
Where I went wrong...? I have no idea at all now..
Many many thanks in advanced
====================This is the searchinfo.pl script=========================================
#!/usr/bin/perl
use Time::Local ;
$DEBUG = 1;
$log = shift @ARGV;
$param = shift @ARGV;
$mode = shift @ARGV;
$inteval = shift @ARGV;
$currentTime = time;
$startTime = $currentTime - ( $inteval * 60 );
if ( $DEBUG )
{
print LOG $startTime . " " . $currentTime . "\n";
}
($sec, $min, $hour, $day, $month, $year) = localtime ( $startTime );
$month += 1;
$year += 1900;
if ( $month < 10 )
{
$month = "0" . $month;
}
if ( $day < 10 )
{
$day = "0" . $day;
}
$log = $log . "/dashboard_" . $day . $month . $year . ".log";
if ( $DEBUG )
{
($sec, $min, $hour, $day, $month, $year) = localtime ( $startTime );
print $year . " " . $month . " " . $day . " " . $hour . " " . $min . " " . $sec . " " . $msec . "\n";
print $log . "\n";
}
$count = 0;
$total = 0;
$max = 0;
$min = 9999999;
open ( FH, "< $log" );
while (<FH>)
{
print "File Read\n";
$line = $_;
if ( $line =~ /.*SEARCHINFO[_WSDP]*\s*([0-9]+).*$param=([0-9]+)/ )
{
if ( $DEBUG )
{
print $1 . " " . $2 . "\n";
}
$stime = $1;
$val = $2;
if ( $stime =~ /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{3})/ )
{
$year = $1 - 1900;
$month = $2 - 1;
$day = $3;
$hour = $4;
$minutes = $5;
$sec = $6;
$msec = $7;
$secSinceEpoch = timelocal ( $sec, $minutes, $hour, $day, $month, $year );
if ( $DEBUG )
{
print $year . " " . $month . " " . $day . " " . $hour . " " . $minutes . " " . $sec . " " . $msec . "\n";
print LOG $secSinceEpoch . " - " . ($secSinceEpoch >= $startTime) . "-" . ($secSinceEpoch < $currentTime) . "\n";
}
if ( $secSinceEpoch >= $startTime && $secSinceEpoch < $currentTime )
{
if ( $DEBUG )
{
print LOG $val . "\n";
}
$count++;
if ( $mode eq "ALL" )
{
$total += $val;
if ( $max < $val )
{
$max = $val;
}
if ( $min > $val )
{
$min = $val;
}
}
elsif ( $mode eq "AVG" )
{
$total += $val;
}
elsif ( $mode eq 'MAX' )
{
if ( $max < $val )
{
$max = $val;
}
}
elsif ( $mode eq 'MIN' )
{
if ( $min > $val )
{
$min = $val;
}
}
}
}
}
}
close FH;
if ( $count > 0 )
{
if ( $mode eq "ALL" )
{
$avg = $total / $count;
print "average:" . $avg . " maximum:" . $max . " minimum:" . $min . "\n";
}
elsif ( $mode eq "AVG" )
{
$avg = $total / $count;
print $avg . "\n";
}
elsif ( $mode eq "MAX" )
{
print $max . "\n";
}
elsif ( $mode eq "MIN" )
{
print $min . "\n";
}
}
if ( $DEBUG )
{
print "RESULT : $count $avg $max $min";
}
===============================================================================
custom script to get remote server log details
Moderators: Developers, Moderators
custom script to get remote server log details
- Attachments
-
- Graph template
- 4.png (162.42 KiB) Viewed 684 times
-
- Data template
- 3.png (157.62 KiB) Viewed 685 times
-
- data input method
- 2.png (104.56 KiB) Viewed 686 times
-
- remote server 97 showing no data in its graph
- 1.png (118.46 KiB) Viewed 687 times
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
Re: custom script to get remote server log details
Which of those parameters are fixed values? Which are "variable"? Where should cacti get the values for those "variables"?./searchinfo.pl /usr/local/user/glassfishv3/glassfish/domains/My_t/logs/ TST MAX 50
R.
Who is online
Users browsing this forum: No registered users and 3 guests