Esempio n. 1
0
 public void ActivateLLDPAgent()
 {
     try
     {
         _bash.Execute("lldpd -d");
     }
     catch (ProcessException processException)
     {
         if (processException.ExitCode != 1)
         {
             throw;
         }
     }
 }
Esempio n. 2
0
        public async Task <string> Handle(SNMPUser user)
        {
            try
            {
                bash.Execute("systemctl stop snmpd");
                bash.Execute($"net-snmp-config --create-snmpv3-user -A {user.Password} -X {user.Encryption} -a MD5 -x {user.EncryptionType} {user.UserName}");
                bash.Execute("systemctl start snmpd");
            }
            catch (ProcessException ex)
            {
                return(ex.Message);
            }

            return(null);
        }
Esempio n. 3
0
        public IEnumerable <EthernetInterface> GetEthernetInterfaces()
        {
            foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (networkInterface.IsEthernet())
                {
                    var output = _bash.Execute(
                        $"ip link show | grep {networkInterface.Name}| grep vlan | cut -d' ' -f9 | cut -d'n' -f2");

                    var appliedVLANs = output
                                       .Replace("\t", string.Empty)
                                       .Replace(networkInterface.Name, string.Empty)
                                       .Split('\n')
                                       .Select(vlan => vlan.Trim('.'))
                                       .Where(vlan => !string.IsNullOrWhiteSpace(vlan))
                                       .Where(vlan => !vlan.ToLower().Equals("down"))
                                       .ToList();

                    var isHostInterface = networkInterface
                                          .GetIPProperties()
                                          .UnicastAddresses
                                          .Any(info => info.Address.Equals(GetLocalIPAddress()));

                    yield return(new EthernetInterface
                    {
                        Name = networkInterface.Name,
                        Status = networkInterface.OperationalStatus,
                        VirtualLANs = appliedVLANs,
                        IsHostInterface = isHostInterface,
                        Tagged = IsTagged(networkInterface.Name),
                        Type = GetInterfaceType(networkInterface)
                    });
                }
            }
        }