get_hint('dbplug_dbuser'); $database_pass = $map->get_hint('dbplug_dbpass'); $database_name = $map->get_hint('dbplug_dbname'); $database_host = $map->get_hint('dbplug_dbhost'); $key = mysql_real_escape_string($matches[1]); $SQL = "select in,out from table where host=$key LIMIT 1"; if(mysql_connect($database_host,$database_user,$database_pass)) { if(mysql_select_db($database_name)) { $result = mysql_query($SQL); if (!$result) { warn("dbsample ReadData: Invalid query: " . mysql_error()."\n"); } else { $row = mysql_fetch_assoc($result); $data[IN] = $row['in']; $data[OUT] = $row['out']; } } else { warn("dbsample ReadData: failed to select database: ".mysql_error()."\n"); } } else { warn("dbsample ReadData: failed to connect to database server: ".mysql_error()."\n"); } $data_time = now(); } debug ("RRD ReadData: Returning (".($data[IN]===NULL?'NULL':$data[IN]).",".($data[OUT]===NULL?'NULL':$data[IN]).",$data_time)\n"); return( array($data[IN], $data[OUT], $data_time) ); } } // vim:ts=4:sw=4: ?>
weathermap |
Subversion Repositories: |
Line No. | Rev | Author | Line |
---|