Example #1
0
        $last_index = substr($index, strrpos($index, '.') + 1);
        if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
            $toner_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.{$last_index}";
            $descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.{$last_index}";
            $capacity_oid = '';
            $descr = snmp_get($device, $descr_oid, '-Oqva');
            $raw_toner = snmp_get($device, $toner_oid, '-Oqv');
        } else {
            $toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.{$index}";
            $capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.{$index}";
            $descr = $data['prtMarkerSuppliesDescription'];
            $raw_toner = $data['prtMarkerSuppliesLevel'];
        }
        $type = 'jetdirect';
        $capacity = get_toner_capacity($data['prtMarkerSuppliesMaxCapacity']);
        $current = get_toner_levels($device, $raw_toner, $capacity);
        discover_toner($valid_toner, $device, $toner_oid, $last_index, $type, $descr, $capacity_oid, $capacity, $current);
    }
}
// Delete removed toners
d_echo("\n Checking valid toner ... \n");
d_echo($valid_toner);
$sql = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $test_toner) {
    $toner_index = $test_toner['toner_index'];
    $toner_type = $test_toner['toner_type'];
    if (!$valid_toner[$toner_type][$toner_index]) {
        echo '-';
        dbDelete('toner', '`toner_id` = ?', array($test_toner['toner_id']));
    }
}
Example #2
0
<?php

$toner_data = dbFetchRows('SELECT * FROM toner WHERE device_id = ?', array($device['device_id']));
foreach ($toner_data as $toner) {
    echo 'Checking toner ' . $toner['toner_descr'] . '... ';
    $raw_toner = snmp_get($device, $toner['toner_oid'], '-OUqnv');
    $tonerperc = get_toner_levels($device, $raw_toner, $toner['toner_capacity']);
    echo $tonerperc . " %\n";
    $tags = array('rrd_def' => 'DS:toner:GAUGE:600:0:20000', 'rrd_name' => array('toner', $toner['toner_index']), 'rrd_oldname' => array('toner', $toner['toner_descr']), 'index' => $toner['toner_index']);
    data_update($device, 'toner', $tags, $tonerperc);
    // Log empty supplies (but only once)
    if ($tonerperc == 0 && $toner['toner_current'] > 0) {
        log_event('Toner ' . $toner['toner_descr'] . ' is empty', $device, 'toner', $toner['toner_id']);
    }
    // Log toner swap
    if ($tonerperc > $toner['toner_current']) {
        log_event('Toner ' . $toner['toner_descr'] . ' was replaced (new level: ' . $tonerperc . '%)', $device, 'toner', $toner['toner_id']);
    }
    dbUpdate(array('toner_current' => $tonerperc, 'toner_capacity' => $toner['toner_capacity']), 'toner', '`toner_id` = ?', array($toner['toner_id']));
}
//end foreach
Example #3
0
                    //ricoh using private oids to expose toner levels
                    if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
                        $toner_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.{$index}";
                        $descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.{$index}";
                        $capacity_oid = '';
                    } else {
                        $toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.{$index}";
                        $descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.{$index}";
                        $capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.{$index}";
                    }
                    $descr = trim(str_replace("\n", '', preg_replace('/[^ \\w]+/', '', snmp_get($device, $descr_oid, '-Oqva'))));
                    if ($descr != '') {
                        $oid_toner = snmp_get($device, $toner_oid, '-Oqv');
                        $oid_capacity = snmp_get($device, $capacity_oid, '-Oqv');
                        $capacity = get_toner_capacity($device, $oid_capacity);
                        $current = get_toner_levels($device, $oid_toner, $oid_capacity);
                        $type = 'jetdirect';
                        discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current);
                    }
                }
            }
        }
    }
}
// Delete removed toners
d_echo("\n Checking ... \n");
d_echo($valid_toner);
$sql = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $test_toner) {
    $toner_index = $test_toner['toner_index'];
    $toner_type = $test_toner['toner_type'];