rrd.php 12.1 KB
Newer Older
冯超鹏's avatar
冯超鹏 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
<?php
/**
 * Stubs for PECL/rrd extension
 * Description taken from official documenation
 * @link     https://php.net/manual/en/book.rrd.php
 * @author   Olegs Capligins <shader@dautkom.lv>
 */

// start of PECL/rrd v1.0

/**
 * Returns latest global rrd error message.
 * @link https://php.net/manual/en/function.rrd-error.php
 * @return string Latest error message.
 * @since PECL rrd >= 0.9.0
 */
function rrd_error() {}

/**
 * Creates rrd database file
 * @link https://php.net/manual/en/function.rrd-create.php
 * @param string $filename <p>
 * Filename for newly created rrd file.
 * </p>
 * @param array $options <p>
 * Options for rrd create - list of strings. See man page of rrd create for whole list of options.
 * </p>
 * @return bool TRUE on success or FALSE on failure.
 * @since PECL rrd >= 0.9.0
 */
function rrd_create($filename, $options) {}

/**
 * Gets data for graph output from RRD database file as array. This function has same result as rrd_graph(), but fetched data are returned as array, no image file is created.
 * @link https://php.net/manual/en/function.rrd-fetch.php
 * @param string $filename <p>
 * RRD database file name.
 * </p>
 * @param array $options <p>
 * Array of options for resolution specification.
 * </p>
 * @return array Array with information about retrieved graph data.
 * @since PECL rrd >= 0.9.0
 */
function rrd_fetch($filename, $options) {}

/**
 * Gets the timestamp of the first sample from from the specified RRA of the RRD file.
 * @link https://php.net/manual/en/function.rrd-first.php
 * @param string $file <p>
 * RRD database file name.
 * </p>
 * @param int $raaindex <p>
 * The index number of the RRA that is to be examined. Default value is 0.
 * </p>
 * @return int|false Integer as unix timestamp, FALSE if some error occurs.
 * @since PECL rrd >= 0.9.0
 */
function rrd_first($file, $raaindex = 0) {}

/**
 * Creates image from a data.
 * @link https://php.net/manual/en/function.rrd-graph.php
 * @param string $filename <p>
 * The filename to output the graph to. This will generally end in either .png, .svg or .eps, depending on the format you want to output.
 * </p>
 * @param array $options <p>
 * Options for generating image. See man page of rrd graph for all possible options. All options (data definitions, variable defintions, etc.) are allowed.
 * </p>
 * @return array|false If image is created successfully an array with information about generated image is returned, FALSE when error occurs.
 * @since PECL rrd >= 0.9.0
 */
function rrd_graph($filename, $options) {}

/**
 * Returns information about particular RRD database file.
 * @link https://php.net/manual/en/function.rrd-info.php
 * @param string $filename <p>
 * RRD database file name.
 * </p>
 * @return array|false Array with information about requsted RRD file, FALSE when error occurs.
 * @since PECL rrd >= 0.9.0
 */
function rrd_info($filename) {}

/**
 * Returns the UNIX timestamp of the most recent update of the RRD database.
 * @link https://php.net/manual/en/function.rrd-last.php
 * @param string $filename <p>
 * RRD database file name.
 * </p>
 * @return int Integer as unix timestamp of the most recent data from the RRD database.
 * @since PECL rrd >= 0.9.0
 */
function rrd_last($filename) {}

/**
 * Gets array of the UNIX timestamp and the values stored for each date in the most recent update of the RRD database file.
 * @link https://php.net/manual/en/function.rrd-lastupdate.php
 * @param string $filename <p>
 * RRD database file name.
 * </p>
 * @return array|false Array of information about last update, FALSE when error occurs.
 * @since PECL rrd >= 0.9.0
 */
function rrd_lastupdate($filename) {}

/**
 * Restores the RRD file from the XML dump.
 * @link https://php.net/manual/en/function.rrd-restore.php
 * @param string $xml_file <p>
 * XML filename with the dump of the original RRD database file.
 * </p>
 * @param string $rrd_file <p>
 * Restored RRD database file name.
 * </p>
 * @param array $options <p>
 * Array of options for restoring. See man page for rrd restore.
 * </p>
 * @return bool Returns TRUE on success, FALSE otherwise.
 * @since PECL rrd >= 0.9.0
 */
function rrd_restore($xml_file, $rrd_file, $options = array()) {}

/**
 * Change some options in the RRD dabase header file. E.g. renames the source for the data etc.
 * @link https://php.net/manual/en/function.rrd-tune.php
 * @param string $filename <p>
 * RRD database file name.
 * </p>
 * @param array $options <p>
 * Options with RRD database file properties which will be changed. See rrd tune man page for details.
 * </p>
 * @return bool Returns TRUE on success, FALSE otherwise.
 * @since PECL rrd >= 0.9.0
 */
function rrd_tune($filename, $options) {}

/**
 * Updates the RRD database file. The input data is time interpolated according to the properties of the RRD database file.
 * @link https://php.net/manual/en/function.rrd-update.php
 * @param string $filename <p>
 * RRD database file name. This database will be updated.
 * </p>
 * @param array $options <p>
 * Options for updating the RRD database. This is list of strings. See man page of rrd update for whole list of options.
 * </p>
 * @return bool Updates the RRD database file. The input data is time interpolated according to the properties of the RRD database file.
 * @since PECL rrd >= 0.9.0
 */
function rrd_update($filename, $options) {}

/**
 * Returns information about underlying rrdtool library.
 * @link https://php.net/manual/en/function.rrd-version.php
 * @return string String with rrdtool version number e.g. "1.4.3".
 * @since PECL rrd >= 1.0.0
 */
function rrd_version() {}

/**
 * Exports the information about RRD database file. This data can be converted to XML file via user space PHP script and then restored back as RRD database file.
 * @link https://php.net/manual/en/function.rrd-xport.php
 * @param array $options <p>
 * Array of options for the export, see rrd xport man page.
 * </p>
 * @return array|false Array with information about RRD database file, FALSE when error occurs.
 * @since PECL rrd >= 0.9.0
 */
function rrd_xport($options) {}

/**
 * Close any outstanding connection to rrd caching daemon <p>
 * This function is automatically called when the whole PHP process is terminated. It depends on used SAPI. For example, it's called automatically at the end of command line script.</p><p>
 * It's up user whether he wants to call this function at the end of every request or otherwise.</p>
 * @link https://php.net/manual/en/function.rrdc-disconnect.php
 * @return void
 * @since PECL rrd >= 1.1.2
 */
function rrd_disconnect() {}

/**
 * Close any outstanding connection to rrd caching daemon.
 * This function is automatically called when the whole PHP process is terminated. It depends on used SAPI.
 * For example, it's called automatically at the end of command line script.
 * It's up user whether he wants to call this function at the end of every request or otherwise.
 */
function rrdc_disconnect(){}

/**
 * Class for creation of RRD database file.
 * @link https://php.net/manual/en/class.rrdcreator.php
 * @since PECL rrd >= 0.9.0
 */
class RRDCreator {

    /**
     * Adds RRA - archive of data values for each data source. <p>
     * Archive consists of a number of data values or statistics for each of the defined data-sources (DS). Data sources are defined by method RRDCreator::addDataSource(). You need call this method for each requested archive.
     * </p>
     * @link https://php.net/manual/en/rrdcreator.addarchive.php
     * @see RRDCreator::addDataSource()
     * @param string $description <p>
     * Class for creation of RRD database file.
     * </p>
     * @return void
     * @since PECL rrd >= 0.9.0
     */
    public function addArchive($description) {}

    /**
     * Adds data source definition for RRD database.<p>
     * RRD can accept input from several data sources (DS), e.g incomming and outgoing traffic. This method adds data source by description. You need call this method for each data source.
     * </p>
     * @link https://php.net/manual/en/rrdcreator.adddatasource.php
     * @param string $description <p>
     * Definition of data source - DS. This has same format as DS definition in rrd create command. See man page of rrd create for more details.
     * </p>
     * @return void
     * @since PECL rrd >= 0.9.0
     */
    public function addDataSource($description) {}

    /**
     * Creates new RRDCreator instance.
     * @link https://php.net/manual/en/rrdcreator.construct.php
     * @param string $path <p>
     * Path for newly created RRD database file.
     * </p>
     * @param string $startTime <p>
     * Time for the first value in RRD database. Parameter supports all formats which are supported by rrd create call.
     * </p>
     * @param int $step <p>
     * Base interval in seconds with which data will be fed into the RRD database.
     * </p>
     * @since PECL rrd >= 0.9.0
     */
    public function __construct($path, $startTime='', $step=0) {}

    /**
     * Saves the RRD database into file, which name is defined by RRDCreator::__construct()
     * @link https://php.net/manual/en/rrdcreator.save.php
     * @see RRDCreator::__construct()
     * @return bool TRUE on success or FALSE on failure.
     * @since PECL rrd >= 0.9.0
     */
    public function save() {}

}

/**
 * Class for exporting data from RRD database to image file.
 * @link https://php.net/manual/en/class.rrdgraph.php
 * @since PECL rrd >= 0.9.0
 */
class RRDGraph {

    /**
     * Creates new RRDGraph instance. This instance is responsible for rendering the result of RRD database query into image.
     * @link https://php.net/manual/en/rrdgraph.construct.php
     * @param string $path <p>
     * Full path for the newly created image.
     * </p>
     * @since PECL rrd >= 0.9.0
     */
    public function __construct($path) {}

    /**
     * Saves the result of RRD database query into image defined by RRDGraph::__construct().
     * @link https://php.net/manual/en/rrdgraph.save.php
     * @return array|false Array with information about generated image is returned, FALSE if error occurs.
     * @since PECL rrd >= 0.9.0
     */
    public function save() {}

    /**
     * Saves the RRD database query into image and returns the verbose information about generated graph. <p>
     * If "-" is used as image filename, image data are also returned in result array.
     * </p>
     * @link https://php.net/manual/en/rrdgraph.saveverbose.php
     * @return array|false Array with detailed information about generated image is returned, optionally with image data, FALSE if error occurs.
     * @since PECL rrd >= 0.9.0
     */
    public function saveVerbose() {}

    /**
     * Sets the options for rrd graph export
     * @link https://php.net/manual/en/rrdgraph.setoptions.php
     * @param array $options <p>
     * List of options for the image generation from the RRD database file. It can be list of strings or list of strings with keys for better readability. Read the rrd graph man pages for list of available options.
     * </p>
     * @return void
     * @since PECL rrd >= 0.9.0
     */
    public function setOptions($options) {}

}

/**
 * Class for updating RDD database file.
 * @link https://php.net/manual/en/class.rrdupdater.php
 * @since PECL rrd >= 0.9.0
 */
class RRDUpdater {

    /**
     * Creates new RRDUpdater instance. This instance is responsible for updating the RRD database file.
     * RRDUpdater constructor.
     * @link https://php.net/manual/en/rrdupdater.construct.php
     * @param string $path <p>
     * Filesystem path for RRD database file, which will be updated.
     * </p>
     * @since PECL rrd >= 0.9.0
     */
    public function __construct($path) {}

    /**
     * Update the RRD file defined via RRDUpdater::__construct(). The file is updated with a specific values.
     * @link https://php.net/manual/en/rrdupdater.update.php
     * @param array $values <p>
     * Data for update. Key is data source name.
     * </p>
     * @param string $time <p>
     * Time value for updating the RRD with a particulat data. Default value is current time.
     * </p>
     * @return bool TRUE on success or FALSE on failure.
     * @throws \Exception on error
     * @since PECL rrd >= 0.9.0
     */
    public function update($values, $time='') {}

}

// end of PECL/rrd v1.0