public function createFile($start = null)
    {
        if (file_exists($this->_fileName)) {
            throw new Kwf_Exception("$this->_fileName already exists");
        }

        $initialValueDates = array();
        if (is_null($start)) {
            $initialValueDates = $this->_getInitialValueDates();
            if (!$initialValueDates) {
                $start = time()-1;
            } else {
                sort($initialValueDates);
                $start = $initialValueDates[0]-1;
            }
        }

        $cmd = "rrdtool create $this->_fileName ";
        $cmd .= "--start ".$start." ";
        $cmd .= "--step ".($this->_interval)." ";
        foreach ($this->_fields as $field) {
            if (!is_null($field->getHeartbeat())) {
                $heartbeat = $field->getHeartbeat();
            } else {
                $heartbeat = ($this->_interval*2);
            }
            $cmd .= "DS:".$field->getEscapedName().":".$field->getType().":".$heartbeat.":".$field->getMin().":".($field->getMax())." ";
        }
        foreach ($this->getRRAs() as $rra) {
            if (!isset($rra['method'])) $rra['method'] = 'AVERAGE';
            if (!isset($rra['xff'])) $rra['xff'] = '0.6';
            $cmd .= "RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] ";
        }
        //echo "$cmd<br>\n";
        system($cmd, $ret);
        if ($ret != 0) throw new Kwf_Exception("Command failed");

        foreach ($initialValueDates as $date) {
            $this->record($date, $this->getRecordValuesForDate($date));
        }
    }
public function createFile($start = null)
    {
        if (file_exists($this->_fileName)) {
            throw new Kwf_Exception("$this->_fileName already exists");
        }

        $initialValueDates = array();
        if (is_null($start)) {
            $initialValueDates = $this->_getInitialValueDates();
            if (!$initialValueDates) {
                $start = time()-1;
            } else {
                sort($initialValueDates);
                $start = $initialValueDates[0]-1;
            }
        }

        $cmd = "rrdtool create $this->_fileName ";
        $cmd .= "--start ".$start." ";
        $cmd .= "--step ".($this->_interval)." ";
        foreach ($this->_fields as $field) {
            if (!is_null($field->getHeartbeat())) {
                $heartbeat = $field->getHeartbeat();
            } else {
                $heartbeat = ($this->_interval*2);
            }
            $cmd .= "DS:".$field->getEscapedName().":".$field->getType().":".$heartbeat.":".$field->getMin().":".($field->getMax())." ";
        }
        foreach ($this->getRRAs() as $rra) {
            if (!isset($rra['method'])) $rra['method'] = 'AVERAGE';
            if (!isset($rra['xff'])) $rra['xff'] = '0.6';
            $cmd .= "RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] ";
        }
        //echo "$cmd<br>\n";
        system($cmd, $ret);
        if ($ret != 0) throw new Kwf_Exception("Command failed");

        foreach ($initialValueDates as $date) {
            $this->record($date, $this->getRecordValuesForDate($date));
        }
    }
public function createFile ( $ start = null ) { if ( file_exists ( $ this -> _fileName ) ) { throw new Kwf_Exception ( "$this->_fileName already exists" ) ; } $ initialValueDates = array ( ) ; if ( is_null ( $ start ) ) { $ initialValueDates = $ this -> _getInitialValueDates ( ) ; if ( ! $ initialValueDates ) { $ start = time ( ) - 1 ; } else { sort ( $ initialValueDates ) ; $ start = $ initialValueDates [ 0 ] - 1 ; } } $ cmd = "rrdtool create $this->_fileName " ; $ cmd .= "--start " . $ start . " " ; $ cmd .= "--step " . ( $ this -> _interval ) . " " ; foreach ( $ this -> _fields as $ field ) { if ( ! is_null ( $ field -> getHeartbeat ( ) ) ) { $ heartbeat = $ field -> getHeartbeat ( ) ; } else { $ heartbeat = ( $ this -> _interval * 2 ) ; } $ cmd .= "DS:" . $ field -> getEscapedName ( ) . ":" . $ field -> getType ( ) . ":" . $ heartbeat . ":" . $ field -> getMin ( ) . ":" . ( $ field -> getMax ( ) ) . " " ; } foreach ( $ this -> getRRAs ( ) as $ rra ) { if ( ! isset ( $ rra [ 'method' ] ) ) $ rra [ 'method' ] = 'AVERAGE' ; if ( ! isset ( $ rra [ 'xff' ] ) ) $ rra [ 'xff' ] = '0.6' ; $ cmd .= "RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] " ; } //echo "$cmd<br>\n"; system ( $ cmd , $ ret ) ; if ( $ ret != 0 ) throw new Kwf_Exception ( "Command failed" ) ; foreach ( $ initialValueDates as $ date ) { $ this -> record ( $ date , $ this -> getRecordValuesForDate ( $ date ) ) ; } }
erstellt rrd Datei

wenn kein start-timestamp übergeben wird dieser automatisch ermittelt
und per _getInitialValueDates die datei für die vergangenheit befüllt

@param int start-timestamp, sollte normalerweise null sein
erstellt rrd Datei