mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	* feature: Allow customisation of rrd step/heartbeat when creating new rrd files * revert defaults * added docs + webui config option * Move RrdDefinition to an Object to make them easier to create and remove the possibility of typos. * Fix style/lint issues and missing use statements * 3 more missing use statements * updated doc + moved schema file
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use LibreNMS\RRD\RrdDefinition;
 | 
						|
 | 
						|
$diskio_data = dbFetchRows('SELECT * FROM `ucd_diskio` WHERE `device_id`  = ?', array($device['device_id']));
 | 
						|
 | 
						|
if (count($diskio_data)) {
 | 
						|
    $diskio_cache = array();
 | 
						|
    $diskio_cache = snmpwalk_cache_oid($device, 'diskIOEntry', $diskio_cache, 'UCD-DISKIO-MIB');
 | 
						|
 | 
						|
    foreach ($diskio_data as $diskio) {
 | 
						|
        $index = $diskio['diskio_index'];
 | 
						|
 | 
						|
        $entry = $diskio_cache[$index];
 | 
						|
 | 
						|
        echo $diskio['diskio_descr'].' ';
 | 
						|
 | 
						|
        d_echo($entry);
 | 
						|
 | 
						|
        $tags = array(
 | 
						|
            'rrd_name'  => array('ucd_diskio', $diskio['diskio_descr']),
 | 
						|
            'rrd_def'   => RrdDefinition::make()
 | 
						|
                ->addDataset('read', 'DERIVE', 0, 125000000000)
 | 
						|
                ->addDataset('written', 'DERIVE', 0, 125000000000)
 | 
						|
                ->addDataset('reads', 'DERIVE', 0, 125000000000)
 | 
						|
                ->addDataset('writes', 'DERIVE', 0, 125000000000),
 | 
						|
            'descr'     => $diskio['diskio_descr'],
 | 
						|
        );
 | 
						|
 | 
						|
        $fields = array(
 | 
						|
            'read'    => $entry['diskIONReadX'],
 | 
						|
            'written' => $entry['diskIONWrittenX'],
 | 
						|
            'reads'   => $entry['diskIOReads'],
 | 
						|
            'writes'  => $entry['diskIOWrites'],
 | 
						|
        );
 | 
						|
 | 
						|
        data_update($device, 'ucd_diskio', $tags, $fields);
 | 
						|
    }//end foreach
 | 
						|
 | 
						|
    echo "\n";
 | 
						|
}//end if
 | 
						|
 | 
						|
unset($diskio_data);
 | 
						|
unset($diskio_cache);
 |