0% found this document useful (0 votes)
55 views1 page

Linux Poller Time PL

This Perl script connects to a MySQL database and queries a settings table to retrieve a stats_poller value, extracting a numeric time value from the result.

Uploaded by

Israel P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Linux Poller Time PL

This Perl script connects to a MySQL database and queries a settings table to retrieve a stats_poller value, extracting a numeric time value from the result.

Uploaded by

Israel P
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/usr/bin/perl

use strict;
use warnings;
use DBI;

my $db_user = 'DBUSERNAME';
my $db_pass = 'DBPASSWORD';
my $sql = 'SELECT value FROM `settings` WHERE name="stats_poller" LIMIT 1';

my $dbh = DBI->connect('DBI:mysql:cacti', $db_user, $db_pass)


or die "Couldn't connect to database: " . DBI->errstr;

my $sth = $dbh->prepare($sql)
or die "Couldn't prepare statement: " . $dbh->errstr;

$sth->execute()
or die "Couldn't execute: " . $sth->errstr;

my $time = $sth->fetchrow();
chomp $time;
$time =~ m/^Time:([0-9]+\.[0-9]+)/;

defined($1) ? print $1 : print "0";

You might also like