using System.Text;
using System.Xml.Linq;

namespace GenerateYAMLforZabbix
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var list = new List<string[]>();
            var lines = File.ReadAllLines("listCam.txt", Encoding.UTF8);
            foreach (var line in lines)
            {
                var uzel = line.Split(';');
                list.Add(uzel);
            }
            foreach (var host in list)
            {
                //var act4 = host[0].Split(".")[3];
                var text = $"" +
                    $"    - host: {host[0]}\r\n" +
                    $"      name: (ВНК54){host[1]}\r\n" +
                    $"      templates:\r\n" +
                    $"        - name: 'SEC Dahua Camera SNMP'\r\n" +
                    $"      groups:\r\n" +
                    $"        - name: dahua.cam.vnk.54\r\n" +
                    $"      interfaces:\r\n" +
                    $"        - ip: {host[0]}\r\n" +
                    $"          interface_ref: if2\r\n" +
                    $"        - type: SNMP\r\n" +
                    $"          ip: {host[0]}\r\n" +
                    $"          port: '161'\r\n" +
                    $"          details:\r\n" +
                    $"            community: '{{$SNMP_COMMUNITY}}'\r\n" +
                    $"          interface_ref: if1\r\n" +
                    $"      inventory_mode: DISABLED\r\n";

                File.AppendAllText("hosts.yaml", text, Encoding.UTF8);
            }
        }        
    }
}
//    - host: 172.16.54.16
//name: 'Антресоль 3 1-56-T'
//      templates:
//-name: 'SEC Dahua Camera SNMP'
//      groups:
//-name: dahua.cam.vnk.54
//      interfaces:
//-ip: 172.16.54.16
//          interface_ref: if2
//        - type: SNMP
//          ip: 172.16.54.16
//          port: '161'
//          details:
//community: '{$SNMP_COMMUNITY}'
//          interface_ref: if1
//      inventory_mode: DISABLED