コード例 #1
0
ファイル: Snmp.php プロジェクト: svennd/ServerStalker
 public function create($location, $options)
 {
     print_r($options);
     $result = rrd_create($location, $options);
     if ($result) {
         print rrd_error();
         return false;
     }
     return true;
 }
コード例 #2
0
 function execute()
 {
     if (file_exists($this->db_path)) {
         return true;
     }
     $return = rrd_create($this->db_path, $this->options, count($this->options));
     if (!$return) {
         throw new Rrdtool_Exception("rrd_create() ERROR: " . rrd_error());
     } else {
         return $return;
     }
 }
コード例 #3
0
ファイル: phprrd.php プロジェクト: TuffLuck/status2
 public function save()
 {
     $args = array();
     if ($this->start != 0) {
         $args[] = '--start';
         $args[] = $this->start;
     }
     if ($this->step) {
         $args[] = '--step';
         $args[] = $this->step;
     }
     $args = array_merge($args, $this->datastores, $this->archives);
     $res = rrd_create($this->path, $args);
     if (!$res) {
         $this->error = rrd_error();
     }
     return $res;
 }
コード例 #4
0
ファイル: class.graphing.php プロジェクト: rbott/homegear-web
 function checkAndCreateSources()
 {
     foreach ($this->devices as $device) {
         switch ($device["type"]) {
             case "valve":
                 $rrdPath = $this->rrdBasePath . "valves/peer_" . $device["peerId"] . ".rrd";
                 if (!file_exists($rrdPath)) {
                     rrd_create($rrdPath, $this->valveRrdOptions);
                 }
                 break;
             case "envsensor":
                 $rrdPath = $this->rrdBasePath . "sensors/peer_" . $device["peerId"] . ".rrd";
                 if (!file_exists($rrdPath)) {
                     rrd_create($rrdPath, $this->envSensorRrdOptions);
                 }
                 break;
         }
     }
 }
コード例 #5
0
ファイル: exec.rrd.php プロジェクト: brucewu16899/1.6.x
function rrd_xload()
{
    $filetime = "/etc/artica-postfix/pids/rrd.load.time";
    $unix = new unix();
    if (!$GLOBALS["FORCE"]) {
        $timeN = $unix->file_time_sec($filetime);
        if ($timeN < 120) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$timeN}/120, abroting\n";
            }
            return;
        }
    }
    @unlink($filetime);
    @file_put_contents($filetime, time());
    if (!is_dir("/usr/share/artica-postfix/ressources/databases/rrd")) {
        @mkdir("/usr/share/artica-postfix/ressources/databases/rrd", 0755, true);
    }
    if (!is_file("/usr/share/artica-postfix/ressources/databases/rrd/load.rrd")) {
        echo "Creating load.rrd\n";
        $opts = array("--step", "120", "--start", 0, "DS:load:GAUGE:120:U:U", "RRA:AVERAGE:0.5:1:1440", "RRA:AVERAGE:0.5:6:1800", "RRA:AVERAGE:0.5:24:1800", "RRA:AVERAGE:0.5:288:1800", "RRA:MIN:0.5:1:1440", "RRA:MIN:0.5:6:1800", "RRA:MIN:0.5:24:1800", "RRA:MIN:0.5:288:1800", "RRA:MAX:0.5:1:1440", "RRA:MAX:0.5:6:1800", "RRA:MAX:0.5:24:1800", "RRA:MAX:0.5:288:1800");
        $ret = @rrd_create("/usr/share/artica-postfix/ressources/databases/rrd/load.rrd", $opts, count($opts));
        if ($ret == 0) {
            $err = rrd_error();
            echo "Create error: {$err}\n";
        }
    }
    $array_load = sys_getloadavg();
    $internal_load = $array_load[0];
    $t = time();
    echo "Load:{$internal_load}\n";
    //$internal_load=str_replace(".", ",", $internal_load);
    $ret = rrd_update("/usr/share/artica-postfix/ressources/databases/rrd/load.rrd", "{$t}:{$internal_load}");
    if ($ret == 0) {
        $err = rrd_error();
        echo "update error: {$err}\n";
    }
    create_graph("/usr/share/artica-postfix/ressources/logs/web/load.png", "-1h", "Load Hourly");
}
コード例 #6
0
ファイル: LamPI-create.php プロジェクト: RobQuistNL/LamPI-2.0
<?php

require_once '../config/backend_cfg.php';
require_once '../daemon/backend_lib.php';
require_once '../daemon/backend_sql.php';
echo "LamPI-create is Starting";
$options = [];
if (!rrd_create("rrd_dbase.rrd", $options)) {
    echo "ERROR: Creating rrd database";
}
echo "LamPI-create is successful";
コード例 #7
0
ファイル: theme.php プロジェクト: npfriday/Tinyboard
 public function build($action, $settings)
 {
     global $config, $_theme, $argv;
     if (!$settings) {
         error('This theme is not currently installed.');
     }
     $this->boards = explode(' ', $settings['boards']);
     $this->spans = array('hour', 'day', 'week', 'month', 'year');
     // exclude boards from the "combined" graph
     $this->combined_exclude = array();
     if ($action == 'cron') {
         if (!file_exists($settings['path'])) {
             mkdir($settings['path']);
         }
         if (!file_exists($settings['images'])) {
             mkdir($settings['images']);
         }
         foreach ($this->boards as &$board) {
             $file = $settings['path'] . '/' . $board . '.rrd';
             if (!file_exists($file)) {
                 // Create graph
                 if (!rrd_create($file, array('-s 60', 'DS:posts:COUNTER:86400:0:10000', 'RRA:AVERAGE:0:1:60', 'RRA:AVERAGE:0:1:1440', 'RRA:AVERAGE:0:30:10080', 'RRA:AVERAGE:0:120:43829', 'RRA:AVERAGE:0:1440:525948', 'RRA:AVERAGE:0:2880:1051897', 'RRA:MAX:0:1:60', 'RRA:MAX:0:1:1440', 'RRA:MAX:0:30:10080', 'RRA:MAX:0:120:43829', 'RRA:MAX:0:1440:525948', 'RRA:MAX:0:2880:1051897'))) {
                     error('RRDtool failed: ' . htmlentities(rrd_error()));
                 }
             }
             // debug just the graphing (not updating) with the --debug switch
             if (!isset($argv[1]) || $argv[1] != '--debug') {
                 // Update graph
                 $query = query(sprintf("SELECT MAX(`id`) AS `count` FROM `posts_%s`", $board));
                 $count = $query->fetch();
                 $count = $count['count'];
                 if (!rrd_update($file, array('-t', 'posts', 'N:' . $count))) {
                     error('RRDtool failed: ' . htmlentities(rrd_error()));
                 }
             }
             foreach ($this->spans as &$span) {
                 // Graph graph
                 if (!rrd_graph($settings['images'] . '/' . $board . '-' . $span . '.png', array('-s -1' . $span, '-t Posts on ' . sprintf($config['board_abbreviation'], $board) . ' this ' . $span, '--lazy', '-l 0', '-h', $settings['height'], '-w', $settings['width'], '-a', 'PNG', '-R', 'mono', '-W', 'Powered by Tinyboard', '-E', '-X', '0', '-Y', '-v posts/' . $settings['rate'], 'DEF:posts-second=' . $file . ':posts:AVERAGE', 'CDEF:posts-minute=posts-second,60,*', 'CDEF:posts-hour=posts-minute,60,*', 'CDEF:posts-day=posts-hour,24,*', 'CDEF:posts-week=posts-day,7,*', 'CDEF:posts-month=posts-day,28,*', 'CDEF:posts-year=posts-day,365,*', 'DEF:posts=' . $file . ':posts:AVERAGE', 'LINE2:posts-' . $settings['rate'] . '#663300:Posts', 'GPRINT:posts-' . $settings['rate'] . ':MAX:Max\\: %5.2lf', 'GPRINT:posts-' . $settings['rate'] . ':AVERAGE:Average\\: %5.2lf', 'GPRINT:posts-' . $settings['rate'] . ':LAST:Current\\: %5.2lf posts/' . $settings['rate'], 'HRULE:0#000000'))) {
                     error('RRDtool failed: ' . htmlentities(rrd_error()));
                 }
             }
         }
         // combined graph
         foreach ($this->spans as &$span) {
             $options = array('-s -1' . $span, '-t Posts this ' . $span, '--lazy', '-l 0', '-h', $settings['height'], '-w', $settings['width'], '-a', 'PNG', '-R', 'mono', '-W', 'Powered by Tinyboard', '-E', '-X', '0', '-Y', '-v posts/' . $settings['rate']);
             $red = 0;
             $green = 0;
             $blue = 0;
             $c = 0;
             $cc = 0;
             $c = 1;
             $cc = 0;
             $red = 2;
             foreach ($this->boards as &$board) {
                 if (in_array($board, $this->combined_exclude)) {
                     continue;
                 }
                 $color = str_pad(dechex($red * 85), 2, '0', STR_PAD_LEFT) . str_pad(dechex($green * 85), 2, '0', STR_PAD_LEFT) . str_pad(dechex($blue * 85), 2, '0', STR_PAD_LEFT);
                 $options[] = 'DEF:posts' . $board . '-second=' . $settings['path'] . '/' . $board . '.rrd' . ':posts:AVERAGE';
                 $options[] = 'CDEF:posts' . $board . '-minute=posts' . $board . '-second,60,*';
                 $options[] = 'CDEF:posts' . $board . '-hour=posts' . $board . '-minute,60,*';
                 $options[] = 'CDEF:posts' . $board . '-day=posts' . $board . '-hour,24,*';
                 $options[] = 'CDEF:posts' . $board . '-week=posts' . $board . '-day,7,*';
                 $options[] = 'CDEF:posts' . $board . '-month=posts' . $board . '-day,28,*';
                 $options[] = 'CDEF:posts' . $board . '-year=posts' . $board . '-day,365,*';
                 $options[] = 'LINE2:posts' . $board . '-' . $settings['rate'] . '#' . $color . ':' . sprintf($config['board_abbreviation'], $board);
                 // Randomize colors using this horrible undocumented algorithm I threw together while debugging
                 if ($c == 0) {
                     $red++;
                 } elseif ($c == 1) {
                     $green++;
                 } elseif ($c == 2) {
                     $blue++;
                 } elseif ($c == 3) {
                     $green--;
                 } elseif ($c == 4) {
                     $red--;
                 }
                 $cc++;
                 if ($cc > 2) {
                     $c++;
                     $cc = 0;
                 }
                 if ($c > 4) {
                     $c = 0;
                 }
                 if ($red > 3) {
                     $red = 0;
                 }
                 if ($green > 3) {
                     $green = 0;
                 }
                 if ($blue > 3) {
                     $blue = 0;
                 }
             }
             $options[] = 'HRULE:0#000000';
             if (!rrd_graph($settings['images'] . '/combined-' . $span . '.png', $options)) {
                 error('RRDtool failed: ' . htmlentities(rrd_error()));
             }
         }
     }
 }
コード例 #8
0
ファイル: class.RRD.php プロジェクト: rchicoria/epp-drs
		/**
		 * Create new Round Robin database
		 *
		 * @param int $start Specifies the time in seconds since 1970-01-01 UTC when the first value should be added to the RRD. RRDtool will not accept any data timed before or at the time specified. 
		 * @param int $step Specifies the base interval in seconds with which data will be fed into the RRD. 
		 * @return bool
		 */
		function Create($start = false, $step = false)
		{
			$args = array();
			if ($start)
			{
				array_push($args, "--start");
				array_push($args, $start);
			}
			
			if ($step)
			{
				array_push($args, "--step");
				array_push($args, $step);
			}
			
			foreach($this->DSs as $DS)
				array_push($args, $DS->__toString());

			foreach($this->RRAs as $RRA)
				array_push($args, $RRA->__toString());
				
			if(rrd_create($this->DBPath, $args, count($args)))
				return true;
			else
				Core::RaiseError(_("Cannot create RRD: ".rrd_error()));
		}
コード例 #9
0
<?php

$path = "/home/rrd/rrd/";
$password = '******';
$url = 'http://speedport.ip/';
if (!file_exists($path . 'dsl.rrd')) {
    $options = array("--step", "60", "DS:uactual:GAUGE:120:0:100000", "DS:dactual:GAUGE:120:0:200000", "DS:uattainable:GAUGE:120:0:100000", "DS:dattainable:GAUGE:120:0:200000", "DS:uSNR:GAUGE:120:0:1000", "DS:dSNR:GAUGE:120:0:1000", "DS:uSignal:GAUGE:120:0:1000", "DS:dSignal:GAUGE:120:0:200000", "DS:uLine:GAUGE:120:0:2000", "DS:dLine:GAUGE:120:0:2000", "DS:uCRC:DERIVE:120:0:10000000", "DS:dCRC:DERIVE:120:0:10000000", "DS:uHEC:DERIVE:120:0:10000000", "DS:dHEC:DERIVE:120:0:10000000", "DS:uFEC:DERIVE:120:0:10000000", "DS:dFEC:DERIVE:120:0:10000000", "RRA:AVERAGE:0.5:1:2880", "RRA:MAX:0.5:1:2880", "RRA:AVERAGE:0.5:10:144", "RRA:MAX:0.5:10:144");
    rrd_create($path . 'dsl.rrd', $options);
}
if (!file_exists($path . 'lteinfo.rrd')) {
    $options = array("--step", "60", "DS:rsrp:GAUGE:120:-200:0", "DS:rsrq:GAUGE:120:-200:0", "RRA:AVERAGE:0.5:1:2880", "RRA:MAX:0.5:1:2880", "RRA:AVERAGE:0.5:10:144", "RRA:MAX:0.5:10:144");
    rrd_create($path . 'lteinfo.rrd', $options);
}
require_once '../SpeedportHybrid.class.php';
$sp = new SpeedportHybrid($url);
$sp->login($password);
$data = $sp->getData('dsl');
$options = array(time() . ':' . $data['Line']['uactual'] . ':' . $data['Line']['dactual'] . ':' . $data['Line']['uattainable'] . ':' . $data['Line']['dattainable'] . ':' . $data['Line']['uSNR'] . ':' . $data['Line']['dSNR'] . ':' . $data['Line']['uSignal'] . ':' . $data['Line']['dSignal'] . ':' . $data['Line']['uLine'] . ':' . $data['Line']['dLine'] . ':' . $data['Line']['uCRC'] . ':' . $data['Line']['dCRC'] . ':' . $data['Line']['uHEC'] . ':' . $data['Line']['dHEC'] . ':' . $data['Line']['uFEC'] . ':' . $data['Line']['dFEC']);
rrd_update($path . 'dsl.rrd', $options);
$data = $sp->getData('lteinfo');
$options = array(time() . ':' . $data['rsrp'] . ':' . $data['rsrq']);
rrd_update($path . 'lteinfo.rrd', $options);
$sp->logout();
コード例 #10
0
ファイル: RrdCreator.php プロジェクト: blar/rrd
 public function save()
 {
     $options = ['--start' => $this->getStart()->getTimestamp(), '--step' => $this->getStep()];
     foreach ($this->getDataSources() as $dataSource) {
         $options[] = sprintf('DS:%s', $dataSource);
     }
     foreach ($this->getArchives() as $archive) {
         $options[] = sprintf('RRA:%s', $archive);
     }
     $status = rrd_create($this->getFileName(), $this->convertOptions($options));
     if (!$status) {
         throw new RuntimeException(rrd_error());
     }
 }
コード例 #11
0
<?php

#date_default_timezone_set("America/Los_Angeles");
$fname = "/home/pi/temperature.rrd";
$opts = array("-s", "300", "DS:temp:GAUGE:600:U:U", "RRA:MAX:0.5:1:600", "RRA:MAX:0.5:6:700", "RRA:MAX:0.5:24:775", "RRA:MAX:0.5:288:797");
if (file_exists($fname)) {
    $datenow = date('U');
    $temp = exec('sudo python /home/pi/readtemp.py');
    $updatevalue = array($datenow . ":" . $temp);
    $ret = rrd_update($fname, $updatevalue);
    if ($ret == 0) {
        $err = rrd_error();
        echo "ERROR occurred: {$err}\n";
    } else {
        echo "Temperature " . $temp . " logged at " . $datenow;
    }
} else {
    $ret = rrd_create($fname, $opts);
    if ($ret == 0) {
        $err = rrd_error();
        echo "Create error: {$err}\n";
    } else {
        echo "Tempearture database created";
    }
}
?>
  
コード例 #12
0
 private function createRRDFile()
 {
     $options = array("--step", "60", "DS:memoryUsage:GAUGE:600:0:100", "DS:clients:GAUGE:600:0:U", "DS:rootfsUsage:GAUGE:600:0:100", "DS:loadavg:GAUGE:600:0:U", "DS:trafMgmtRxBy:COUNTER:600:0:U", "DS:trafMgmtRxPa:COUNTER:600:0:U", "DS:trafMgmtTxBy:COUNTER:600:0:U", "DS:trafMgmtTxPa:COUNTER:600:0:U", "DS:trafRxBy:COUNTER:600:0:U", "DS:trafRxPa:COUNTER:600:0:U", "DS:trafTxBy:COUNTER:600:0:U", "DS:trafTxPa:COUNTER:600:0:U", "DS:trafForwardBy:COUNTER:600:0:U", "DS:trafForwardPa:COUNTER:600:0:U", "RRA:AVERAGE:0.5:1:10080", "RRA:AVERAGE:0.5:60:8760", "RRA:AVERAGE:0.5:1440:5256");
     $ret = rrd_create($this->getRRDFileName(), $options);
     echo rrd_error();
 }
コード例 #13
0
 public static function createRRDFile($filename, $options)
 {
     $ret = rrd_create($filename, $options);
     echo rrd_error();
 }
コード例 #14
0
             //echo "<b>Graph error, </b>".rrd_error()."\n";
         }
     } else {
         // wenn das rrd file noch nicht vorhanden ist neues anlagen
         $options = array("--step", "5", "--start", "-30 days");
         $zaehler = $start + $anzahl;
         //echo("Start: ".$start."Ende: ".$zaehler."");
         for ($i = $start; $i < $zaehler; $i++) {
             // anzahl der trends Name ist aus Datenbanck IWx
             array_push($options, "DS:" . $art . $i . ":GAUGE:5:U:U");
         }
         array_push($options, "RRA:AVERAGE:0.5:1:17280");
         array_push($options, "RRA:AVERAGE:0.5:12:86400");
         array_push($options, "RRA:AVERAGE:0.5:720:8760");
         //print_r($options);
         $ret = rrd_create($filename, $options);
         // File erzeugen
         if (!$ret) {
             //echo "<b>Creation error: </b>".rrd_error()."\n";
         }
     }
     $w++;
 }
 //	sleep(3);
 gc_enable();
 System_Daemon::iterate(3);
 // check ob ein rrd File in der Datenbanck gelöscht wurde.
 mysql_free_result($result);
 $files1 = array();
 $files2 = array();
 if ($handle = opendir('https/rrd')) {
コード例 #15
0
ファイル: getpkg.php プロジェクト: retspen/swmon
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | Swmon: Solution For Switch Edge-Core ES3528M, ES3552M and ES3510        |
 +-------------------------------------------------------------------------+
 | This code is designed, written, and maintained by the X-sys Group. See  |
 | about.php and/or the AUTHORS file for specific developer information.   |
 +-------------------------------------------------------------------------+
 | http://www.x-sys.com.ua/                                                |
 +-------------------------------------------------------------------------+
*/
include dirname(__FILE__) . "/include/config.php";
/* Удалить все картинки с загрузками на портах */
system("rm {$homedir}/tmp/*");
/* Выводит список портов */
$sql = "SELECT d.id, d.ip, p.port\n\tFROM device d \n\tLEFT JOIN ports p \n\tON d.id=p.device_id \n\tWHERE d.state_id=1\n\tAND p.state_id=1\n\tAND p.trank=0\n\tAND p.name not like '%FAIL%' \n\tAND p.name not like '%rezerv%'";
$alldev = mysql_query($sql);
while ($rowoct = mysql_fetch_row($alldev)) {
    if (@fopen("{$homedir}/rrd/" . $rowoct[0] . "_" . $rowoct[2] . ".rrd", "r")) {
        /* Получить данные с порта */
        $getinoct = snmpget("{$rowoct['1']}", "public", "ifInOctets.{$rowoct['2']}");
        $strinoct = substr($getinoct, 11, strlen($getinoct) - 11);
        $getoutoct = snmpget("{$rowoct['1']}", "public", "ifOutOctets.{$rowoct['2']}");
        $stroutoct = substr($getoutoct, 11, strlen($getoutoct) - 11);
        /* Относительно пользователя, для относительно оборудования поменять местами $str*oct */
        rrd_update("{$homedir}/rrd/" . $rowoct[0] . "_" . $rowoct[2] . ".rrd", "N:{$stroutoct}:{$strinoct}");
    } else {
        $rrdadd = array("--step", "300", "--start", 0, "DS:in:COUNTER:600:U:U", "DS:out:COUNTER:600:U:U", "RRA:AVERAGE:0.5:1:600", "RRA:AVERAGE:0.5:6:700", "RRA:AVERAGE:0.5:24:775", "RRA:AVERAGE:0.5:288:797", "RRA:MAX:0.5:1:600", "RRA:MAX:0.5:6:700", "RRA:MAX:0.5:24:775", "RRA:MAX:0.5:288:797");
        rrd_create("{$homedir}/rrd/" . $rowoct[0] . "_" . $rowoct[2] . ".rrd", $rrdadd, count($rrdadd));
    }
}