Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See COPYING for the license under which php-weathermap is released.
There is much more information, tutorials and updates available at:
http://www.network-weathermap.com/

*IMPORTANT NOTE*: This version only works with Cacti 0.8.8 (not 1.x.x)
*IMPORTANT NOTE*: This version only works with Cacti 1.x.x

------

Expand Down
10 changes: 5 additions & 5 deletions lib/datasources/WeatherMapDataSource_cactithold.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ function ReadData($targetstring, &$map, &$item)
// use target aggregation to build these up into a 'badness' percentage
// takes the same two values that are visible in thold's own URLs (the actual thold ID isn't shown anywhere)

$rra_id = intval($matches[1]);
$data_id = intval($matches[2]);
$local_data_id = intval($matches[1]);
$data_template_rrd_id = intval($matches[2]);

$SQL2 = "select thold_alert from thold_data where rra_id=$rra_id and data_id=$data_id and thold_enabled='on'";
$SQL2 = "select thold_alert from thold_data where local_data_id=$local_data_id and data_template_rrd_id=$data_template_rrd_id and thold_enabled='on'";
$result = db_fetch_row($SQL2);
if(isset($result))
{
Expand Down Expand Up @@ -179,13 +179,13 @@ function ReadData($targetstring, &$map, &$item)
wm_debug("CactiTHold ReadData: Checking threshold states for host $id\n");
$numthresh = 0;
$numfailing = 0;
$SQL2 = "select rra_id, data_id, thold_alert from thold_data,data_local where thold_data.rra_id=data_local.id and data_local.host_id=$id and thold_enabled='on'";
$SQL2 = "select local_data_id, data_template_rrd_id, thold_alert from thold_data,data_local where thold_data.local_data_id=data_local.id and data_local.host_id=$id and thold_enabled='on'";
# $result = db_fetch_row($SQL2);
$queryrows = db_fetch_assoc($SQL2);
if( is_array($queryrows) )
{
foreach ($queryrows as $th) {
$desc = $th['rra_id']."/".$th['data_id'];
$desc = $th['local_data_id']."/".$th['data_template_rrd_id'];
$v = $th['thold_alert'];
$numthresh++;
if(intval($th['thold_alert']) > 0)
Expand Down
6 changes: 3 additions & 3 deletions lib/datasources/WeatherMapDataSource_rrd.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ function wmrrd_read_from_poller_output($rrdfile,$cf,$start,$end,$dsnames, &$data
// Include the local_data_id as well, to make life easier in poller_output
// (and to allow the cacti: DS plugin to use the same table, too)
wm_debug("RRD ReadData: poller_output - Adding new weathermap_data row for data source ID " . $result['local_data_id'] . "\n");
$statement_insert = $pdo->prepare("INSERT INTO weathermap_data (rrdfile, data_source_name, sequence, local_data_id) VALUES (?,?, 0,?)");
$statement_insert->execute(array($db_rrdname, $dsnames[$dir], $result['local_data_id']));
$statement_insert = $pdo->prepare("INSERT INTO weathermap_data (rrdfile, data_source_name, sequence, local_data_id, last_value) VALUES (?,?, 0,?,'')");
$statement_insert->execute(array($db_rrdname, $dsnames[$dir], $result['local_data_id']));

// $SQLins = "insert into weathermap_data (rrdfile, data_source_name, sequence, local_data_id) values ('".mysql_real_escape_string($db_rrdname)."','".mysql_real_escape_string($dsnames[$dir])."', 0,".$result['local_data_id'].")";
// db_execute($SQLins);
Expand Down Expand Up @@ -244,7 +244,7 @@ function wmrrd_read_from_real_rrdtool_aggregate($rrdfile,$cf,$aggregatefn,$start
$args[] = "graph";
$args[] = "/dev/null";
$args[] = "-f";
$args[] = "''";
$args[] = "'%s %lu %lu'";
$args[] = "--start";
$args[] = $start;
$args[] = "--end";
Expand Down
67 changes: 38 additions & 29 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,21 @@ function weathermap_setup_table()

if ( !in_array( 'weathermap_maps', $tables ) ) {
$sql[] = "CREATE TABLE weathermap_maps (
id int(11) NOT NULL auto_increment,
sortorder int(11) NOT NULL default 0,
group_id int(11) NOT NULL default 1,
active set('on','off') NOT NULL default 'on',
configfile text NOT NULL,
imagefile text NOT NULL,
htmlfile text NOT NULL,
titlecache text NOT NULL,
filehash varchar (40) NOT NULL default '',
warncount int(11) NOT NULL default 0,
config text NOT NULL,
thumb_width int(11) NOT NULL default 0,
thumb_height int(11) NOT NULL default 0,
schedule varchar(32) NOT NULL default '*',
archiving set('on','off') NOT NULL default 'off',
`id` int(11) NOT NULL auto_increment,
`sortorder` int(11) NOT NULL default 0,
`group_id` int(11) NOT NULL default 1,
`active` set('on','off') NOT NULL default 'on',
`configfile` text NOT NULL,
`imagefile` text NOT NULL,
`htmlfile` text NOT NULL,
`titlecache` text NOT NULL,
`filehash` varchar (40) NOT NULL default '',
`warncount` int(11) NOT NULL default 0,
`config` text NOT NULL,
`thumb_width` int(11) NOT NULL default 0,
`thumb_height` int(11) NOT NULL default 0,
`schedule` varchar(32) NOT NULL default '*',
`archiving` set('on','off') NOT NULL default 'off',
PRIMARY KEY (id)
) ENGINE=MyISAM;";
} else {
Expand Down Expand Up @@ -335,12 +335,12 @@ function weathermap_setup_table()
}
}

$sql[] = "update weathermap_maps set filehash=LEFT(MD5(concat(id,configfile,rand())),20) where filehash = '';";
$sql[] = "update weathermap_maps set `filehash`=LEFT(MD5(concat(id,configfile,rand())),20) where `filehash` = '';";

if ( !in_array( 'weathermap_auth', $tables ) ) {
$sql[] = "CREATE TABLE weathermap_auth (
userid mediumint(9) NOT NULL default '0',
mapid int(11) NOT NULL default '0'
`userid` mediumint(9) NOT NULL default '0',
`mapid` int(11) NOT NULL default '0'
) ENGINE=MyISAM;";
}

Expand All @@ -357,21 +357,30 @@ function weathermap_setup_table()

if ( !in_array( 'weathermap_settings', $tables ) ) {
$sql[] = "CREATE TABLE weathermap_settings (
id int(11) NOT NULL auto_increment,
mapid int(11) NOT NULL default '0',
groupid int(11) NOT NULL default '0',
optname varchar(128) NOT NULL default '',
optvalue varchar(128) NOT NULL default '',
`id` int(11) NOT NULL auto_increment,
`mapid` int(11) NOT NULL default '0',
`groupid` int(11) NOT NULL default '0',
`optname` varchar(128) NOT NULL default '',
`optvalue` varchar(128) NOT NULL default '',
PRIMARY KEY (id)
) ENGINE=MyISAM;";
}

if ( !in_array( 'weathermap_data', $tables ) ) {
$sql[] = "CREATE TABLE IF NOT EXISTS weathermap_data (id int(11) NOT NULL auto_increment,
rrdfile varchar(255) NOT NULL,data_source_name varchar(19) NOT NULL,
last_time int(11) NOT NULL,last_value varchar(255) NOT NULL,
last_calc varchar(255) NOT NULL, sequence int(11) NOT NULL, local_data_id int(11) NOT NULL DEFAULT 0, PRIMARY KEY (id), KEY rrdfile (rrdfile),
KEY local_data_id (local_data_id), KEY data_source_name (data_source_name) ) ENGINE=MyISAM";
$sql[] = "CREATE TABLE IF NOT EXISTS weathermap_data (
`id` int(11) NOT NULL auto_increment,
`rrdfile` varchar(255) NOT NULL,
`data_source_name` varchar(19) NOT NULL,
`last_time` int(11) NOT NULL DEFAULT -1,
`last_value` varchar(255) NOT NULL DEFAULT '',
`last_calc` varchar(255) NOT NULL DEFAULT '',
`sequence` int(11) NOT NULL DEFAULT 0,
`local_data_id` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY rrdfile (rrdfile(250)),
KEY local_data_id (local_data_id),
KEY data_source_name (data_source_name)
) ENGINE=MyISAM";
} else {
$stmt = $pdo->prepare( "show columns from weathermap_data" );
$stmt->execute();
Expand Down Expand Up @@ -733,7 +742,7 @@ function weathermap_poller_output( $rrd_update_array )
break;
}
}
db_execute( "UPDATE weathermap_data SET last_time=$newtime, last_calc='$newvalue', last_value='$newlastvalue',sequence=sequence+1 where id = " . $required[ 'id' ] );
db_execute( "UPDATE weathermap_data SET `last_time`=$newtime, `last_calc`='$newvalue', `last_value`='$newlastvalue',`sequence`=`sequence`+1 where `id` = " . $required[ 'id' ] );
if ( $logging >= POLLER_VERBOSITY_DEBUG ) cacti_log( "WM poller_output: Final value is $newvalue (was $lastval, period was $period)\n", TRUE, "WEATHERMAP" );
} else {
if ( 1 == 0 && $logging >= POLLER_VERBOSITY_DEBUG ) {
Expand Down
2 changes: 1 addition & 1 deletion weathermap-cacti-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ function weathermap_mapselector( $current_id = 0 )
}
?>
</select>
&nbsp;<input type="image" src="../../images/button_go.gif" alt="Go" border="0"
&nbsp;<input type="image" src="../../images/enable_icon.png" alt="Go" border="0"
align="absmiddle">
</td>
</tr>
Expand Down