mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
asdasdasd
This commit is contained in:
1 parent
c4182ec609
commit
9905cde527
76 files changed
+2895
-2529
No files matched your search
@@ -0,0 +1,32 @@
|
||||
using CartriX.Api.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CartriX.Api.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class SnmpController : ControllerBase
|
||||
{
|
||||
private readonly ISnmpService _snmpService;
|
||||
public SnmpController(ISnmpService snmpService)
|
||||
{
|
||||
_snmpService = snmpService;
|
||||
}
|
||||
[HttpGet(nameof(GetDataFromSnmp))] public async Task<IActionResult> GetDataFromSnmp([FromQuery] string IpOrHostname, [FromQuery] string Oid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(IpOrHostname) || string.IsNullOrEmpty(Oid))
|
||||
{
|
||||
return BadRequest("ipAddress и Oid обязательны");
|
||||
}
|
||||
try
|
||||
{
|
||||
var result = await _snmpService.GetDataFromSnmp(IpOrHostname, Oid);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(500, $"Ошибка: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user