1. Go to this page and download the library: Download epiecs/mikodo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
[
'Hostname_1' => [
'date' => "
Wed Jul 24 15:48:36 CEST 2019
"
'ping -c 2 8.8.8' => "
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=64 time=10.706 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=64 time=11.214 ms
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 10.706/10.960/11.214/0.254 ms
"
]
'Hostname_2' => [
'date' => "
Wed Jul 24 15:48:36 CEST 2019
"
'ping -c 2 8.8.8.8' => "
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=64 time=54.188 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=64 time=11.252 ms
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 11.252/32.720/54.188/21.468 ms
"
]
]
$mikodo->print($results);
use Epiecs\Mikodo\Mikodo;
use Epiecs\Mikodo\InventoryProviders\BaseInventory;
$baseInventory = new BaseInventory();
// Sethosts is used here but you can always use the constructor if you'd like
$baseInventory->setGroups([
'core_switches' => [
'device_type' => "cisco_ios",
],
'lab_switches' => [
'username' => 'lab_username',
'password' => 'lab_password',
'port' => 2020
]
]);
$baseInventory->setDefaults([
'port' => 22,
'username' => "defaultusername",
'password' => "defaultpassword"
]);
$baseInventory->setHosts([
'Hostname_1' => [
'device_type' => 'junos',
'port' => 22,
'username' => 'my_default_username',
'password' => 'my_default_password',
'hostname' => '192.168.0.1',
'groups' => [
'core_switches',
],
],
'Hostname_2' => [
'device_type' => 'junos',
'port' => 22,
'username' => 'my_default_username',
'password' => 'my_default_password',
'hostname' => '192.168.0.1',
'groups' => [
'core_switches'
]
],
'Hostname_3' => [
'device_type' => 'cisco_ios',
'port' => 22,
'hostname' => '172.16.2.10',
'groups' => [
'lab_switches',
'core_switches'
]
],
]);
$mikodo = new Mikodo();
$mikodo->inventory($baseInventory->getGroups(['lab_swithches', 'core_switches']));
$baseInventory = new BaseInventory(array $hosts = array(), array $groups = array(), array $defaults = array());
// Setting the inventory
$baseInventory->setHosts(array $hosts);
$baseInventory->setGroups(array $groups);
$baseInventory->setDefaults(array $defaults);
// Get all hosts
$baseInventory->getHosts(array $hosts);
// Get all groups provided in the $groups array
$baseInventory->getGroups(array $groups);
// Get all groups provided in the $groups array and reduce with the groups within the $filterGroups array
$baseInventory->getGroups(array $groups, array $filterGroups);
// Get the full inventory. Usefull if you need to modify it yourself.
$baseInventory->getInventory();