Example #1
0
 /**
  * As long as the oidList() function is implemented correctly, there is no need
  * to reimplement this in subclasses.
  * Take care: the logic in here comes from reverse engineerring of the snmpwalk
  * command and takes into account all corner cases.
  * @return an array with an oid value, null or true
  */
 public function getnext($oid)
 {
     $array = $this->oidList();
     // if it is not a scalar value, look first to see if the object exists
     // if it does, return its scalar value
     if (!preg_match('/\\.0$/', $oid)) {
         if (($pos = array_search($oid, $array)) !== false) {
             //return array( $array[$pos], $oid . '.0' );
             return $this->get($oid . '.0');
         }
     } else {
         // looking for next of a scalar val: remove the .0 suffix
         $oid = eZSNMPd::removeSuffix($oid);
     }
     // now search for an exact match with a known oid
     // if found, return the next oid in the list
     if (($pos = array_search($oid, $array)) !== false) {
         if ($pos + 1 < count($array)) {
             return $this->get($array[$pos + 1] . '.0');
         } else {
             // last oid in the tree: no more next
             return true;
         }
     }
     // last chance: maybe the searched oid is a node in the tree, not a leaf
     // a little bit of regexp magic here: if an oid begins with the searched
     // one, then it is its first ancestor
     $match = "/^" . str_replace('.', '\\.', $oid) . "/";
     foreach ($array as $anOid) {
         if (preg_match($match, $anOid)) {
             return $this->get($anOid . '.0');
         }
     }
     // but what about snmp walking the complete mib?
     if ('.' . $this->oidRoot() == $oid . '.' && count($array)) {
         return $this->get($array[0] . '.0');
     }
     return null;
 }
Example #2
0
<?php

/**
 * Allows display of OID values via GET queries
 *
 * @author Gaetano Giunta
 * @copyright (c) 2009-2012 G. Giunta
 * @license code licensed under the GPL License: see README
 */
$response = 'NONE';
$oid = $Params['oid'];
if ($oid != '') {
    $server = new eZSNMPd();
    $response = $server->get($oid);
}
header('Content-Type: text/plain');
echo "{$response}\n";
eZExecution::cleanExit();
Example #3
0
<?php

/**
 * Allows display of OID values via GET queries
 *
 * @author Gaetano Giunta
 * @copyright (c) 2009-2012 G. Giunta
 * @license code licensed under the GPL License: see README
 */
$response = 'NONE';
$name = $Params['name'];
if ($name != '') {
    $server = new eZSNMPd();
    $ini = eZINI::instance('snmpd.ini');
    $prefix = $ini->variable('MIB', 'PrefixName');
    $name = preg_replace("/^{$prefix}::/", '', $name);
    $response = $server->getByName($name);
}
header('Content-Type: text/plain');
echo "{$response}\n";
eZExecution::cleanExit();
Example #4
0
<?php

/**
 * A view to display the MIB - in various formats
 *
 * @author Gaetano Giunta
 * @copyright (c) 2009-2012 G. Giunta
 * @license code licensed under the GPL License: see README
 */
$server = new eZSNMPd();
switch ($Params['format']) {
    case 'html':
        $format = 'html';
        $mib = $server->getMIBArray();
        break;
    default:
        header('Content-Type: text/plain');
        echo $server->getFullMIB();
        eZExecution::cleanExit();
}
$tpl = eZsnmpdTools::eZTemplateFactory();
$tpl->setVariable('mib', $mib);
$Result = array();
$Result['content'] = $tpl->fetch("design:snmp/mib/{$format}.tpl");
//include_once( 'kernel/common/i18n.php' );
$Result['path'] = array(array('url' => '', 'text' => 'SNMP Monitoring'), array('url' => 'snmp/mib/html', 'text' => 'MIB'));
Example #5
0
<?php

/**
 * Allows setting OID values via GET queries
 *
 * @author Gaetano Giunta
 * @copyright (c) 2009-2012 G. Giunta
 * @license code licensed under the GPL License: see README
 */
$response = '';
$oid = $Params['oid'];
$type = $Params['type'];
$value = $Params['value'];
if ($oid != '' && $type != '') {
    $server = new eZSNMPd();
    $response = $server->set($oid, $value, $type);
}
header('Content-Type: text/plain');
echo "{$response}\n";
eZExecution::cleanExit();
Example #6
0
 function getMIBTree()
 {
     // build list of oids corresponding to order status
     $db = self::eZDBinstance();
     $orderStatusIdoids = array();
     $orderStatusNameoids = array();
     $orderStatusCountoids = array();
     $orderStatusArchiveCountoids = array();
     if ($db) {
         $status = $db->arrayQuery('select status_id, name from ezorder_status where is_active=1 order by id');
         $db->close();
         if (is_array($status)) {
             $i = 1;
             foreach ($status as $line) {
                 self::$orderstatuslist = array_merge(self::$orderstatuslist, array("2.1.5.1.1.1.{$i}" => $line['status_id'], "2.1.5.1.1.2.{$i}" => $line['name'], "2.1.5.1.1.3.{$i}" => $line['status_id'], "2.1.5.1.1.4.{$i}" => $line['status_id']));
                 $orderStatusIdoids[$i] = array('name' => 'orderStatusId' . $i, 'syntax' => 'INTEGER');
                 $orderStatusNameoids[$i] = array('name' => 'orderStatusname' . $i, 'syntax' => 'DisplayString');
                 $orderStatusCountoids[$i] = array('name' => 'orderStatusCount' . $i, 'syntax' => 'INTEGER');
                 $orderStatusArchiveCountoids[$i] = array('name' => 'orderStatusArchive' . $i, 'syntax' => 'INTEGER');
                 $i++;
             }
         }
         //var_dump($orderStatusArchiveCountoids);
         //die();
     } else {
         // what to do in this case? db is down - maybe we should raise an exception
         // instead of producing a shortened oid list...
     }
     // build list of oids corresponding to caches and store for later their config
     $i = 1;
     $cacheoids = array();
     foreach (eZCache::fetchList() as $cacheItem) {
         if ($cacheItem['path'] != false) {
             $id = $cacheItem['id'];
             self::$cachelist = array_merge(self::$cachelist, array("2.2.{$i}.1" => $id, "2.2.{$i}.2" => $id, "2.2.{$i}.3" => $id, "2.2.{$i}.4" => $id));
             $cachename = 'cache' . ucfirst(eZSNMPd::asncleanup($id));
             $cacheoids[$i] = array('name' => $cachename, 'children' => array(1 => array('name' => "{$cachename}Name", 'syntax' => 'DisplayString', 'description' => 'The name of this cache.'), 2 => array('name' => "{$cachename}Status", 'syntax' => 'INTEGER', 'description' => 'Cache status: 1 for enabled, 0 for disabled.'), 3 => array('name' => "{$cachename}Count", 'syntax' => 'INTEGER', 'description' => 'Number of files in the cache (-1 if current cluster mode not supported).'), 4 => array('name' => "{$cachename}Size", 'syntax' => 'INTEGER', 'description' => 'Sum of size of all files in the cache (-1 if current cluster mode not supported).')));
             $i++;
         }
     }
     // build list of oids corresponding to storage dirs
     /// @todo this way of finding storage dir is lame, as it depends on them having been created
     ///       it will also not work in cluster mode, as there will be no dirs on the fs...
     $storagedir = eZSys::storageDirectory();
     $files = @scandir($storagedir);
     $i = 1;
     $storagediroids = array();
     foreach ($files as $file) {
         if ($file != '.' && $file != '..' && is_dir($storagedir . '/' . $file)) {
             self::$storagedirlist = array_merge(self::$storagedirlist, array("2.3.{$i}.1" => $storagedir . '/' . $file, "2.3.{$i}.2" => $storagedir . '/' . $file, "2.3.{$i}.3" => $storagedir . '/' . $file));
             $storagedirname = 'storage' . ucfirst(eZSNMPd::asncleanup($file));
             $storagediroids[$i] = array('name' => $storagedirname, 'children' => array(1 => array('name' => "{$storagedirname}Path", 'syntax' => 'DisplayString', 'description' => 'The path of this storage dir.'), 2 => array('name' => "{$storagedirname}Count", 'syntax' => 'INTEGER', 'description' => 'Number of files in the dir (-1 if current cluster mode not supported).'), 3 => array('name' => "{$storagedirname}Size", 'syntax' => 'INTEGER', 'description' => 'Sum of size of all files in the dir (-1 if current cluster mode not supported).')));
             $i++;
         }
     }
     return array('name' => 'eZPublish', 'children' => array(2 => array('name' => 'status', 'children' => array(1 => array('name' => 'database', 'children' => array(1 => array('name' => 'dbstatus', 'syntax' => 'INTEGER', 'description' => 'Availability of the database.'), 2 => array('name' => 'content', 'children' => array(1 => array('name' => 'contentObjects', 'syntax' => 'INTEGER', 'description' => 'The number of content objects.'), 2 => array('name' => 'contentObjectAttributes', 'syntax' => 'INTEGER', 'description' => 'The number of content object attributes.'), 3 => array('name' => 'contentObjectNodes', 'syntax' => 'INTEGER', 'description' => 'The number of content nodes.'), 4 => array('name' => 'contentObjectRelations', 'syntax' => 'INTEGER', 'description' => 'The number of content object relations.'), 5 => array('name' => 'contentObjectDrafts', 'syntax' => 'INTEGER', 'description' => 'The number of content objects in DRAFT state.'), 6 => array('name' => 'contentObjectClasses', 'syntax' => 'INTEGER', 'description' => 'The number of content object classes.'), 7 => array('name' => 'contentObjectInfoCollections', 'syntax' => 'INTEGER', 'description' => 'The number of information collections.'), 8 => array('name' => 'contentObjectsPendingIndexation', 'syntax' => 'INTEGER', 'description' => 'The number of objects pending a search-engine indexation.'), 9 => array('name' => 'pendingNotificationEvents', 'syntax' => 'INTEGER', 'description' => 'The number of pending notification events.'))), 3 => array('name' => 'users', 'children' => array(1 => array('name' => 'registeredusers', 'syntax' => 'INTEGER', 'description' => 'The number of existing user accounts.'))), 4 => array('name' => 'sessions', 'children' => array(1 => array('name' => 'allSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active sessions.'), 2 => array('name' => 'anonSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active anonymous users sessions.'), 3 => array('name' => 'registeredSessions', 'syntax' => 'INTEGER', 'description' => 'The number of active registered users sessions.'))), 5 => array('name' => 'shop', 'children' => array(1 => array('name' => 'orderStatusTable', 'access' => eZMIBTree::access_not_accessible, 'syntax' => 'SEQUENCE OF OrderStatusEntry', 'description' => 'A table containing the number of orders per order state.', 'children' => array(0 => array('name' => 'OrderStatusEntry', 'syntax' => 'SEQUENCE', 'items' => array(1 => array('name' => 'orderStatusId', 'syntax' => 'INTEGER'), 2 => array('name' => 'orderStatusName', 'syntax' => 'DisplayString'), 3 => array('name' => 'orderStatusCount', 'syntax' => 'INTEGER'), 4 => array('name' => 'orderStatusArchiveCount', 'syntax' => 'INTEGER'))), 1 => array('name' => 'orderStatusEntry', 'access' => eZMIBTree::access_not_accessible, 'syntax' => 'OrderStatusEntry', 'description' => 'A table row describing the set of orders in status N.', 'index' => 'orderStatusId', 'children' => array(1 => array('name' => 'orderStatusId', 'syntax' => 'INTEGER (1..99)', 'description' => 'ID of this order status.', 'nochildreninmib' => true, 'children' => $orderStatusIdoids), 2 => array('name' => 'orderStatusName', 'syntax' => 'DisplayString', 'description' => 'The name of this order status.', 'nochildreninmib' => true, 'children' => $orderStatusNameoids), 3 => array('name' => 'orderStatusCount', 'syntax' => 'INTEGER', 'description' => 'Number of active orders in this status.', 'nochildreninmib' => true, 'children' => $orderStatusCountoids), 4 => array('name' => 'orderStatusArchiveCount', 'syntax' => 'INTEGER', 'description' => 'Number of archived orders in this status.', 'nochildreninmib' => true, 'children' => $orderStatusArchiveCountoids))))))), 6 => array('name' => 'asyncpublishing', 'children' => array(1 => array('name' => 'AsyncPublishingWorkingCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Working status'), 2 => array('name' => 'AsyncPublishingFinishedCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Finished status'), 3 => array('name' => 'AsyncPublishingPendingCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Pending status'), 4 => array('name' => 'AsyncPublishingDeferredCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Deferred status'), 5 => array('name' => 'AsyncPublishingUnknownCount', 'syntax' => 'INTEGER', 'description' => 'Number of Asynchronous Publication events in Unknown status'))))), 2 => array('name' => 'cache', 'children' => $cacheoids), 3 => array('name' => 'storage', 'children' => $storagediroids), 4 => array('name' => 'external', 'children' => array(1 => array('name' => 'ldap', 'syntax' => 'INTEGER', 'description' => 'Connectivity to LDAP server (-1 if not configured).'), 2 => array('name' => 'web', 'syntax' => 'INTEGER', 'description' => 'Connectivity to the web. (probes a series of webservers defined in snmpd.ini, returns -1 if not configured).'), 3 => array('name' => 'email', 'syntax' => 'INTEGER', 'description' => 'Connectivity to mail server (NB: will send a test mail when probed to a recipient defined in snmpd.ini, returns -1 if not configured).'))), 5 => array('name' => 'cluster', 'children' => array(1 => array('name' => 'clusterdbstatus', 'syntax' => 'INTEGER', 'description' => 'Availability of the cluster database (-1 for NA).')))))));
 }
Example #7
0
<?php

/**
 * Displays the equivalent of snmpwalk: a list of oid names and their types + values
 *
 * @author Gaetano Giunta
 * @copyright (c) 2009-2012 G. Giunta
 * @license code licensed under the GPL License: see README
 */
$next = $Params['oid'];
$server = new eZSNMPd();
$response = implode("\n", $server->walk($next));
header('Content-Type: text/plain');
echo "{$response}\n";
eZExecution::cleanExit();
Example #8
0
 public static function setDaemon($mode)
 {
     self::$daemon_mode = $mode;
 }