// DynTemplate creates a template for regular ingestion by PRTG
DynTemplate creates a template for regular ingestion by PRTG
// DynTemplate creates a template for regular ingestion by PRTG
func (c *Client) DynTemplate(tags []string, Age time.Duration, tplate string) error {
	d := NewDeviceTemplate(Age, strings.Join(tags, ","))
	tm := NewTagMap()
	err := c.list(tags, tm)
	if err != nil {
		return err
	}
	for _, tag := range tags {
		err := c.getObjIds(tag, tm)
		if err != nil {
			return fmt.Errorf("%v", err)
		}
	}
	moidNames := newMoidNames(c)
	meta, err := c.obMeta(tm, moidNames, Age)
	if err != nil {
		return err
	}
	for _, v := range meta.Items {
		c := Check{
			ID:       v.Name,
			Kind:     "exexml",
			Meta:     "",
			Requires: "ping",
			Createdata: Createdata{Name: v.Name, Tags: strings.Join(tags, ","), Errorintervalsdown: "5",
				Autoacknowledge: v.Autoacknowledge, Priority: "3", Exefile: filepath.Base(os.Args[0]), Mutex: "prtgvmware",
				Exeparams: v.Params,
			},
		}
		err = d.add(c)
		if err != nil {
			return err
		}
	}
	err = d.save(tplate)
	if err != nil {
		return fmt.Errorf("failed to save file %v", err)
	}
	return nil
}
func ( c * Client ) DynTemplate ( tags [ ] string , Age time . Duration , tplate string ) error { d := NewDeviceTemplate ( Age , strings . Join ( tags , " " ) ) tm := NewTagMap ( ) err := c . list ( tags , tm ) if err != nil { return err } for _ , tag := range tags { err := c . getObjIds ( tag , tm ) if err != nil { return fmt . Errorf ( " " , err ) } } moidNames := newMoidNames ( c ) meta , err := c . obMeta ( tm , moidNames , Age ) if err != nil { return err } for _ , v := range meta . Items { c := Check { ID : v . Name , Kind : " " , Meta : " " , Requires : " " , Createdata : Createdata { Name : v . Name , Tags : strings . Join ( tags , " " ) , Errorintervalsdown : " " , Autoacknowledge : v . Autoacknowledge , Priority : " " , Exefile : filepath . Base ( os . Args [ 0 ] ) , Mutex : " " , Exeparams : v . Params , } , } err = d . add ( c ) if err != nil { return err } } err = d . save ( tplate ) if err != nil { return fmt . Errorf ( " " , err ) } return nil }
DynTemplate creates a template for regular ingestion by PRTG
DynTemplate creates a template for regular ingestion by PRTG
// save to disk