jale
Joined: 18 Apr 2007 Posts: 3
|
Posted: Wed May 16, 2007 4:30 am Post subject: Script to update Weathermap graphs (for Boost users) |
|
|
Here's little script for Boost users who also want to use Weathermap plugin.
This script accesses graphs in Weathermap configs, so Boost will update those.
It uses url in OVERLIBGRAPH statement in links, every link MUST have OVERLIBGRAPH for this script to work.
This Script needs:
Perl
Perl LWP::Simple package
Guest access to graphs
Copy script to server, run it from crontab 5 min interval:
*/5 * * * * root perl <path_to_script>/script.pl >> /dev/null 2>&1
Modify config lines and perl path in script.
| Code: |
#!/usr/bin/perl
### <CONFIG> ###
my $config_path = '/var/www/html/cacti/plugins/weathermap/configs'; # Path to config files
my @config_files = ('config1.conf','config2.conf'); # Array of config files
### </CONFIG> ###
use LWP::Simple;
foreach (@config_files) {
open CMD, "grep OVERLIBGRAPH $config_path/$_|";
while (<CMD>) {
my $content = get($1) if /OVERLIBGRAPH\s+(.*)$/;
if (defined $content) { print "Graph access OK\n"; }
else { print "Graph access FAILED\n"; }
}
}
|
|
|