Add database functions and upgrade queries for uptime logging feature

pull/19/head
Perri 2014-02-26 21:06:33 +00:00
parent c1797b93ec
commit 7a91b8a3f3
2 changed files with 30 additions and 0 deletions

View File

@ -168,6 +168,26 @@ function psm_add_log($server_id, $type, $message, $user_id = null) {
);
}
/**
* This function adds the result of a check to the uptime table for logging purposes.
*
* @param int $server_id
* @param string $message
*/
function psm_log_uptime($server_id, $status, $latency) {
global $db;
$db->save(
PSM_DB_PREFIX.'uptime',
array(
'server_id' => $server_id,
'date' => date('Y-m-d H:i:s'),
'status' => $status,
'latency' => $latency,
)
);
}
/**
* Parses a string from the language file with the correct variables replaced in the message
*

View File

@ -130,6 +130,16 @@ class Queries {
}
if(version_compare($version_from, '2.1.0', '<=')) {
// 2.1 upgrade
$queries[] = "CREATE TABLE `" . PSM_DB_PREFIX . "uptime` (
`server_id` INT( 11 ) NOT NULL ,
`date` DATETIME NOT NULL ,
`status` INT( 1 ) NOT NULL ,
`latency` FLOAT( 9, 7 ) NULL
) ENGINE = MYISAM ;"
}
}
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value` = '{$version}' WHERE `key` = 'version';";
}
return $queries;