Unleash Zabbix Power: Server and mass agent install! Part 6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] it's your open source Advocate and I'm back with another video and today we're going to talk about zavix for monitoring all of your servers and services now I've done a video on zabic in the past and I've already got the show notes here so you can go check that out and in that video I showed you how to get zabic up and running in Docker now we're going to do that again it's changed a little bit since that first video last year so I'll go through those changes with you as well but this time we're going to set up zabic not just to set it up but we're going to set it up to monitor our MSP business servers and eventually our client servers and we'll be using our netb bird VPN to do that and we're going to try to get authentic set up in the future to make sure that we can authenticate the zabic through our authentication framework and we've got so many things that we want to do on this video it'll be a you know decent length video but it's going to give you all of the stuff you need to get started and get set up and I'll try to give you all the little tips I can think of as we go along now I've done this several times I've had a couple times where my audio just didn't record I don't know what's going on but I'm redoing it so it should be pretty straightforward on that first video I did the install and then one Mark 50 if you haven't checked out his channel I have links in the show notes in the descriptions but he actually did the follow-up video to this where you're going to look at monitoring and alerting an inventory in zabic itself so he helps you get all that stuff set up so I'll leave that because it's still valid for today's video and it's definitely worth you going and checking out if you never checked out his his channel he does some really incredible stuff so definitely get over there and check that out as well all right we're going to get into to zabic setup and installation right after this now in the previous video um I did show you how to do Docker install and all those kind of things if you don't have Docker already set up on your server if you haven't been following this series already this is part six of a series where we're trying to build an MSP type business on open source software so I've already given you a lot of this information on how to install Docker how to get it set up but it's the same process over and over really so I wrote a script that helps you get this done very easily and you can go get that so I have this in the show notes of course all the instructions you need to get this done you can get Docker Docker CE enginex proxy manager if you need a reverse proxy everything installed with that script it's very simple you just copy and paste a line change your permission run the script and answer a couple of questions and it'll do the rest for you and the questions are what is your distro and you just need to hit a number for the distribution you're using and then do you want to install Docker CE yes do you want to install Docker compose yes do you want to install inex proxy manager yes or no depending on what you have set up already and there's a few more apps that I have in there that you can install but you don't need for this particular video and then once you're done it's just going to get those things installed and up and running for you on your server makes it really straightforward so to install zabic we do need to do a few things and I've already got a server set up so I'm going to go back over here and show it to you so this is my tools server now I've got several servers set up already in my uh digital ocean VPC I've got my IDP server I've got my proxy server and then I've also got my netb bird VPN server and then this is my anable server here on my local local network but I'm going to show you how to use anible to push out the zabic agent to all of your various devices so that you don't have to do it one by one because if you're just doing it for a few machines today one by one might be fine but as you get where you're growing and you have clients who have hundreds of machines thousands of machines you don't want to have to do those one by one you want to be able to use something like ansible to push that out to all those machines at once and get them all set up so we'll go through that setup and what you're going to need for that as well so we're going to do a lot in this video today so stick with me we're going to just really get into this and really get into it deep but first I want to say thank you so very much to all of my patrons over at patreon all of my YouTube subscribers and all the people who buy me a beer or a coffee through PayPal I mean I just cannot tell you how much it means to me that you appreciate my content that you want to support me and continue to make that content every week it just it means so much if you haven't already done it get out there and like this video with a thumbs up subscribe if you haven't subscribe so you'll get the information about new videos that I'm putting out about amazing open source software I try to do a video every week and then just make sure to to tell other people about the channel if you have a chance because I really want my channel to grow I've been I've been having a lot of growth I make a little bit of money out of this and people ask me sometimes Hey whenever we do this on patreon or buy you a beer where does that money go honestly it goes to buy the hardware that I use to do these things to pay for digital ocean server space um I I I re I I contribute money back to open source uh constantly so I I added it up because somebody asked me it's a little over $2,000 a year us that I contribute back into open source projects that I love and that I use and you can see what those projects are over on my Wiki Pages here I've got a page that tells you just about that on top of that there's just one offs where I just give them a one-time donation things like that too so I'd say in a in a year I give away about probably $2500 to $3,000 uh not give away but but pay $2500 to $3,000 to open source projects because I love these projects and I want them to continue so me trying to support them monetarily helps that I can't do it all by myself for sure but you guys you know paying it in to me like this I want to give that back to the community and really I just I can't tell you how much I appreciate that so thank you so much now let's get into this installation of zabic so first a couple things you're going to need you're going to need a server it can be at home you can do this on your home network you don't have to do it in digital ocean like I am but if you want to I do have a affiliate link down there if you click on it you'll get a 60-day trial with $50 or $100 credit I don't remember which uh but it's for you to try out digital lotion if you like it and if you stay with the service and sign up and start paying them I'll get a credit that's all I get out of it if you don't it's okay I don't get a credit no big deal if you prefer lenoe go use them if you prefer hitner go use them if you prefer Oracle free tier go do that it's fine uh but you need a server of some kind that you can start with so we're going to have that you need to make sure you have git curl and WG installed and in my in my show notes right here I tell you how to do that for yuntu and Debian for Fedora SS and red hat for Arch and then if you're doing this for op sua I think it's zipper you'll use zipper hopefully you know how to install applications um already so once we've done that we want to have a Docker folder so I'll go back over here if you don't have one already just do mkd Docker hit enter and it'll create a Docker folder okay and then we're just going to move into that Docker folder and if I do an LS you'll see I've only got zamad running right now that's fine so we're going to just go grab the information that we need from the git repo for zabic so I'm just going to grab this address right here and command it says get clone and go get clone the zic stalker stuff I'm going to copy it I'm going to paste it right here and it's going to pull that down it's going to get everything pulled down for us and if we CD into that zabic folder now that zabic Docker folder we can LS and you'll see there's a lot of stuff here so the last time we did this I used this file here to actually get everything up and running but this time I'm going to use their compos file now this compos file has two other files that it kind of depends on so it pulls information from this and there's a few things we can do to start this up and we're going to start up in a couple of steps so the first thing we need to do is actually update some environment variables so let's do CD and Vore vars just like that and we'll clear this out and if I do an LS you don't see a lot there so we need to do ls- and you'll see there's a bunch of files that start with a DOT anything that starts with a DOT is a hidden file or hidden folder on the Linux systems so that's why you have to do that - A at the very least and- a will just make make some line up like this we get some details about them so we're going to edit this file here this MySQL password and this MySQL root password so I'm just going to clear this out and we're going to use a command and we're going to do um open SSL space r a n d which means random and then space-- base 64 Al together and then space 32 so we want it to create a random uh string of characters that are in base 64 and we want it to be 32 characters long so we just hit enter and it generates one for us and we're just going to do one more we're going to do open we're just going to repeat that command when you just hit the up arrow and do it again you see we get two different strings here that's great we're going to use the first one for our MySQL password and the second one for our MySQL root password so I'm just going to highlight and copy this first one I'm going to do control shift C to copy or you can right click and do copy whichever and I'm going to do Nano MySQL password like that and I'm just going to get rid of this zabic password right here and I'm just going to control shift V to paste like Victor now I don't know if my SQL likes some of these characters so we're just going to stick with uppercase lowercase and numers so I'm just going to change this to something else and I'll go change this slash to a number and make sure I don't see any other special characters mixed in there just so we don't have any trouble I'm going to save that with crl o hit enter and then contr X to exit now I'm going to do the same thing for this root password here so I'm going to use that for the root password I'm going to copy it and then I'm going to do Nano do MySQL uncore root and then password just like that and again I'm going to get rid of this one that they have I'm going to control shift V to paste in my other one and I'll get rid of that one and put in a number and I'll look for any other special characters here I don't see any I think we're set so I'm just going to do CR o to save CR X to exit and we've got that set we can do c C dot dot that'll take us back one level you should be back in the docker zabic Docker folder I'm going to do a contr l just to clear out my terminal there to make it easy for you and we're going to look at our Docker compose file we need to adjust some ports so I'm going to do sud sudu LS o f- little n-h capital p-h I think it's l pipe grip and I think that's listen is what we want I'm going to put in my super user password nope oh it did give me everything except it gave me too much I didn't want quite everything here um but what I'm looking for is these ports so you can see port 8080 is in use already I've already got it on being used inside of Docker so I can't uh can't keep using that one so I need to change something so that's that's one command you can do to see what port you have in use and if you see it's it's telling us hey this is in use already for docker so I'm do contr L just to clear that out again and I'm G to uh do an LS and I want to go and make an adjustment inside this file right here so we're going to do Nano composor zabic and it'll finish it if we just hit Tab and we're going to go way down to this part that says web engine X it's way down here I think if we type w web engine X yeah it'll jump us down there okay so control W is search in Nano and then you can type in what you're searching for and it's web- engine X and right here we've got this little Port mapping so it's got a placeholder for this environment variable but this environment variable is not defined anywhere so we're going to get rid of this guy we're going to leave the double quotes and we're going to put in 8052 and right here and it doesn't matter what port you pick it just needs to be a port that you're not already using uh same thing for this 8443 port we're just going to do 80 43 and that's fine and uh make sure I get an8 there 8043 there we go we're going to do crl o and enter to save our changes and then contrl X to exit we've now done everything we need to do to make the changes to these Docker compos files to get everything ready to bring it up now like I said there's two phases of this we're going to do the first phase which is going to bring down just the the stuff that we need so we're going to do Docker space compose and Pull and that should bring down all of the images we need now I may already have these images I can't remember I've know I've done testing but I can't remember if I got rid of them or not so we're going to do that when you hit enter it's going to go grab those ones that it needs all right so we got our Docker compos pull done now we want to bring everything up and watch the logs to make sure that things get started correctly so we're going to do Docker compos up- D two ampersands Docker compos logs DF just like that and this says I want Docker compos to go bring up those containers for the images I just pulled down I want it to run them in the background in a detached mode or as a Damon and then over here it says after that I want Docker compos to show me the log output of those things starting up so I can keep an eye on it so we're going to hit enter it's going to start these up it's going to wait for a few seconds until my SQL Server starts up and gets running where it can attach to it so just be patient now it's going to create this zabic schema in MySQL so again be patient this could take a while it just depends just let it run as long as you're not seeing errors Just Let It Go all right so once we've got zabic up and running we can just controll C to stop the logs from running clear out the terminal and let's go over to our browser let's get the IP address here ip- br- 4 a like this and we want this public IP address right here for E zero so we're going to grab that we'll just control shift C we'll go over to our browser open up a new tab and we'll paste it in and then we're going to go to 8052 is the port that we mapped and there's our zabic login now we can log into zabic with the default user and we'll go through that in a minute we want to change that but first let's go set this up with our reverse proxy so that we can actually access it through a domain name so if we go to our proxy server here we're just going to click on add a new host now what this is is this creates a a way that I can say I want something. mydomain.com to go to my public enginex proxy manager server it receives that request and it says do I have monitor do cism it.com in my list of domains if I do then I want to send it along to the right server on the right Port so that you can access it using this address so this reverse proxy just adds it acts exactly like what it sounds like you're going to go to monitor. it.com of course monitor whatever your domain is.com it's going to hit your reverse proxy your reverse proxy is going to look that up in its list and say do I have an address for that and if it does it'll send you along to that address if it doesn't it's going to give you a page that just says congratulations or maybe an error page if you set that up so it really helps a lot and you don't have to use enginex proxy manager I I use it I think it's a very easy when it set up there's uh traffic there's caddy there's straight up engine X if you just want to set it up in engine X config files if you know how to do that great uh there's also one called ZXI I've been looking at it I haven't gotten it working yet but I'm working on it so some some different options for you there so we're going to now I want to put in the private IP address of this server and I want to use my VPC servers IP address so I can go back over here uh into my terminal actually where I just brought up all my IP addresses and I can find this one that says eth one and that's the one I want to use so I'm just going to copy that one control shift C go back to my engine X proximator I'm going to paste that IP address right in here so monitor this this server on on tools and my proxy server and my netb bird server and my authentic server are all on the same internal virtual private Network um for for digital ocean a VPC as they call it so we've got that set and then I'm going to put in that Port 8052 I'm going to tell to block common exploits and websocket support and then we're going to jump to the SSL tab here and I'm going to tell it request a new certificate Force SSL http2 support and I agree to list of cryp in terms of service my email is there I'm just going to hit save now this can take a few seconds maybe 20 30 seconds sometimes just depends but if this dialogue just goes away with no error message we should be set and it did and we should now have monitor in our list and it's right here so if we click on that that's going to open us up and we've got our SSL certificate we're hitting it with https which is great so we've got a secure connection to our server so we can close this one that we opened with the IP address and we can just log in with our default credentials right here so I'm going to put in admin and zabic all lowercase and admin is an uppercase and now that's the default admin login we don't really want that but when you come in you you'll see you have a dashboard that's already set up now I've got this zoomed in to make it easier for you guys to see but if you zoom out this is what it generally looks like I'm just going to zoom it back up so you can see what I'm doing first thing I want to do is secure this I'm going to go over to users then I'm going to go down to the sub option of users as well and you'll see we've got that admin admin option there so I need to add a new user so to add things in zabic it's a little confusing sometimes you think oh I'm going to type here and click add no this is the search this is like your filter stuff to add stuff you usually go up to this upper right corner so click there and we're going to give this user a username I'm going to put in Brian it's already typed in for my testing so my first name do my last name and then my first my full name here group let's see there's you can select the group groups here so I want to go in the internal group and the zabic administrators group so if you don't know where I came up with this I'll show you in just a minute on the password I've already got a strong password set up for this site so I'll go grab it real quick Copy it out of my password manager and I'll paste it in here twice to confirm it uh theme I'll go ahead and just do Dark theme don't want to Auto log in if you want people to be auto logged out you can check this box and they'll get auto logged out after however many minutes you define now it has 15 in there by default that's a pretty good practice but for now you can leave it unchecked until we get everything set up refresh every 30 seconds so everything else here looks okay now we got to go up to the top there's some tabs here we don't need anything on this tab right now but in this permissions tab we do need to set up a roll and we want to be the Super administrator so type in Su and it should give you all of the stuff you need for that there's a super administrator everything should be set and gives us all of the details we need and now we can click on ADD and that added our new user and if you look the way that I knew what groups to grab um I looked here for the user role super administrator that's why I set that one and then the groups were internal and Zex administrators for that default admin so that's what I set now for this default admin we can click on the admin name to get into it and here we want to go and change the password we want to give it something that's stronger so we we definitely want to give it a a much better stronger password than it has all right so you type in the current password and then your new password twice and you can hit update now I log this out so I'm going to log back in with my new user all right I'm logged back in with my new user and everything seems to be working well now all right so you've got everything up and running we've got the dashboard going we're setting and we're accessing this through https so we're doing a pretty great job you'll notice here that it says we've already got one host but it's not available um this is going to be the server itself and the reason it's not available is that we don't have it running yet with the docker agent so let's go get that set up first it's a little bit kind of weird compared to the other setups and then we'll go through the regular proxy setup now one of the ways we can look at this is to go to Docker compose and do PS when we're in this folder and it's going to show us the different uh different containers that are out already running so we've got the server container and the the abic we've got the MySQL server the regular server the web engine X server um so we've got all those things running already but we actually need to get uh some more servers running so I'm going to clear this out and I'm just going to do a little bit of a different thing I'm going to do Docker compose and we're going to add a couple of tags here so d-h p r o f i l e so profile space all and then we're going to do pull so we're going to pull down everything so inside of those three different files that I talked about that have dependencies the composed. yo compos zabic components. yo and compos databases. yo there's some tags in there so if we put all it'll say hey pull down everything that has the tags in it so we're going to do that and you'll see it's going to start pulling a whole lot of containers for us here so we'll just be patient while it does that all right so once that finishes you'll notice one of the containers that it pulled is the agent container and that's great because it's going to run the agent inside of Docker which means it can connect to our server directly inside the docker Network we just need to figure out where that is is but before we do that we got to start all these containers running so we're just going to do Docker compose D- profile space all and then up- D so we're just telling it hey for everything I just pulled down I also want you to bring it up as a container now so we're going to hit enter it's going to check the check the ones we already had started but it's also going to start up some other containers for us so now we can do Docker compose PS again and now you can see we've got a lot more stuff running and if you look here you'll see up for 2 hours that's the first set of things that I started so all those say 2 hours and the rest of these say about 55 seconds 56 seconds if we clear that and we do it again we'll see now about a minute so a little over a minute something like that so these things are up and running which is great so we'll clear this out now we need to do Docker PS and we're going to get a bunch of information about all the containers and including the the the zamad containers but what we're looking for is first this Docker zabic agent one a Docker zabic server one so we've got this agent we're going to grab this key so here's the agent so it's right here is the key so I'm going to grab that copy it I'm going to do Docker inspect and then that key it's going to give me a bunch of output one of the things I'm looking for is the IP address of this particular container which is is 17226 2396 okay so I need to just keep that in mind so I'm just going to take that and I'm going to put it in a just a little text editor file so let's just do text edit so that's our agent and then let's go look at our actual server so if we do Docker PS again we're going to find our server in this list so here's zabic Docker zabic server one I know this is kind of weird cuz it wraps right there but here's our for that one so we're going to grab it and we're going to do and we'll do the same thing Docker inspect with that ID and then here we're going to grab this IP address so that's our server IP address so let's just grab that let's go put it into our file here and this is the server okay we're going to need these two IP addresses for the server configuration setup so we can clear this out and now we need to go into the actual agent itself so we're gon to say Docker exac dasit so it's gonna be zabic Docker D zabic agent one and we want our bash shell so we're telling it hey Docker I want you to put me into an interactive terminal and I want it to be on this container and I want you to give me a bash shell so we're going to do that we're going to hit enter and if you look up here it says Brian at tools and here we've got the ID of that container and here we're in a certain path now we need to go to we're going to CDC zabic and if we do an LS here's our zabic agent D and zabis agent d. comp we need to edit that comp file now there's no Nano inside of our Docker container so we're going to have to use VI so we're going to do VI zabic aent d.m like this now in VI you press I to get into insert mode so I'm going to press I and if you watch the bottom of the screen down here you'll see it change and you see how the little I came up that means we're in insert mode so we're just going to use the down arrow here we're going to move down until we see a piece that says Source IP it's not too far down right here we see this piece that says Source IP that's the IP address of our agent so we're going to go grab that from our little editor here we're going to copy that in in and we're just going to control shift V to paste it we're going to keep moving down and we've got to find the part that says server it's not too far down so here's our server and it's got zabic server automatically we don't want that we want to take that out and we want to grab this IP address that we just got for the server we're going to copy it and then control shift V we'll paste it in now we need to paste that IP address in one more spot for the active server so we're going to go down and we'll see one that says server active and right here where it says server active we want to change this we're just going to change this to control shift V for that IP address and we're going to hit contrl o or actually no we're going to do escape to get out of insert mode so when you do Escape you shouldn't see the little eye there anymore we're going to type in Colon WQ lowercase and that means write out my changes and then get out of VI so we're going to get out of it there we go so we've made our changes now we're still inside of our container so we need to exit that so we're type exit hit enter and should be back at your normal shell now now we're just going to restart that container so we're going to say Docker restart and we're going to type in zabic D A Docker d zabic - agent-1 and it restarts it for us and that should restart that service inside of that container so that it starts trying to connect to our server now it may take a few minutes it may take a minute may take a few seconds but it's going to it's going to take a little time but it should connect to our server here and this should change so if we go look at monitoring and hosts one other change we need to make before that's going to actually change is we need to click on this uh on this host and we need to go here to the host option in the popup menu and right here it has this IP address and it says 17.0.0 it's not on Local Host so we need to take that out we need to go back and grab that agent IP address right here we're just going to copy it we're going to go back right in here and we're just going to paste that in right there and then we're going to click on update and there it goes it's green so now we should be able to go back to our dashboards and we'll see that we've got a one and we're actually seeing some information now about our server showing up here in the CPU usage and it's extremely low which is great that's what we want so we're getting some information from our Docker agent that's great on our Docker server that's awesome but we also want to add our other machines to This Server so first I'm going to go through the manual setup on one server just so you can see it and then we'll go through using anible to push it out to multiple servers at once so you can see and understand that so we're going to add a machine uh just manually first so we can see how it's done now I'm going to just use my uh let's just use the netb bird VPN server because that's what we're going to start with for the rest of the machines anyways so I'm going to go back over to my terminal here and I'm going to go over to my net bird terminal and I'll just do an ip- br-4 A and that's going to show you all my IP addresses here so when we do that we've got the public IP address of our server here of course we've got the local host address our loot back address and then we've got the VPC address now I know what you're thinking well wait this is your netb bird server isn't it inside of your net bird Network somewhere and and it is um but it's inside of the docker container itself in this case because we've got netb bird running in Docker so not a big deal we're going to use the VPC address to set up our actual container communication between this uh server and our monitoring system so to do this we've got the we've got n bird running on you to server in this case so I'm just going to do sudu app update make sure I get all of the updates that it needs from all the package repositories real quick now we do have some upgrades available as well I'll do those after the video but for now we're just going to do sudu appt install zx- agent just like this and then we'll put a-y just so it we prompt us and we can just say okay and tab to okay there it's just restarting some services for us no big deal so now we're going to do the same thing we did on the other server we're going to go to we're going to do sudu Nano Etsy zabic uh and then zabic agent d.com like that so we're going to just edit that file and in here we're going to go down until we see the source IP address so we want to make sure we set that first so right here is Source IP so we'll just remove that hashtag in front of it like that and we'll save as we go so we just do contrl o and enter to save now we're going to go down and we're going to put in the actual IP address of our server so we're going to go down here and look for the one that says server IP and it always puts in Local Host in this case we don't want that so we're going to just go over to our server and we'll just do a contr L will'll do ip- br-4 a and again we're looking at this E1 address and it's right here we're just going to grab that with control shift C we'll go back to our netb bird server and we'll paste with control shift V and then we want to put that same address down here in the active server area server active we're just going to paste that in and then we need to take out that hashtag in front of it right there we're going to save with CR o and enter and then CR X to exit now we'll come right back to this but first we need to go to zabic we're going to go to monitoring and then hosts and we're going to add a new host remember if you type here you're filtering you want to go over here and click and we're going to call this our net bird server um we can give it a visible name so we can call this net bird VPN uh the templates we want you can pick from all kinds of templates but we want the Linux template by zabic agent right here Linux by zabic agent and in the host group we're going to put this in CIS main ID like that and it's new so we'll just click on new that's fine we need to add an interface so we're going to click on ADD and then we're going to click on agent and right here where it says 127.0.0.1 we're going to back that off and we're going to go grab that IP address from our netb bird server here so we want to get this same address that we already used we're just going to do control shift C and then we're going to do control V to paste it in make sure we have IP selected and then we've got the address this port here 1050 so one50 we don't really need any of this other information now there's other tabs up here so you can go in and put in other information on these tabs if you want to it's not something you have to do but it could help you track the machines as your number number of machines grows but for now we're good so we're just going to add that add that host and you'll see here we've got that host now it's red or it's black because it's trying to figure out like can I reach that host right now now we've set everything up over here on the terminal but we need to restart the zabic service so we're going to do sudu system CTL restart zabic D agent. service just like that we're going to let it restart and then we'll go back over here and if we just wait you know a few seconds depending on when it refreshes and when it grabs the information you should see this turn green all right so we've got our first server set up and you can see it shows up right here as twoo but you notice you don't see it in the CPU stuff that's just because there's a filter set here so if we go into the actual filters themselves it's looking for one called zabic server we don't want that we want Linux we want to go to the host groups and we want to do Linux servers right there we may need to go put that on our actual servers we're going to hit apply and yeah we don't see anything so we can go back to our hosts and we can add that to both of our hosts oh we didn't save our changes let's save our changes to our dashboard glad it warns us and then we'll go back to our hosts and we'll just click in and we'll go to host and right here in host groups we can also do Linux servers and update same way here hosts and on the host group we can do Linux servers and update and now if we go back to our dashboard now we can see the CPU information for both of those uh different servers so you can set this up to group and filter by a lot of things and you can rearrange this dashboard in lots of different ways so I'll showing you how to set up the actual doc agent itself and now just a server manually doing it now let's go and actually set up a couple of servers using anible and actually kind of showing you that you can do multiple servers at once and get them added to your system with all of the things that you want so I'm logged into my anible server and this is the server that I used on the last video and I've just I've gone into my anible home folder that I started with last video and I created a new one called anible zabic agents and if we do an LS you'll see here I've got a host file so we'll look at that first then I've got this file it says installs and install zabic agent. yaml and then I've got this one called ad zabic agent. yaml these are really um this is a copy of this one so I'll I'll probably use this one because I've made modifications and I need to just get rid of this one then I've got this remove zabic host so if you make a mistake or you see there's a problem you're trying to do something this is a a handy little tool that can help you remove it um if you need to and then of course we've got you know test of ours files so we can kind of see how we're coming across these things so I had to do some learning to get this down I'm sure some of you guys for more anable Pros can can give me some tips you've already given me some great tips just from the answerable video um I'll try to apply some of those here but let's just look at our host file first so if we just do cat hosts you'll see here I've just got a group called CIS main it and then I've got my actual file or or my actual server IDP do.com and proxy dosis man.com and for each of those I've created an anible host entry with their ual netb bird IP address so I just went to my netb bird system grabbed their VPN address off of that and then made sure my anable system was on the VPN so if I just do an ip- vr-4 a you'll see right here so I've got wt0 and there it is right there so there's my anible system running on my netb bird system which is great because that means I can reach them through the netb bird VPN and nothing's going out of the open internet and this is just my private land address down here so we're doing great so we'll just create a file here called ansible.cfg so we're just going to do Nano ansible.cfg and in here I'm just going to paste in something I've already got and we're just going to change this inventory we want this to be equal to hosts and our private key file is this file actually so that's that's what we want we want to use this anable key that we set up in the previous video uh so I'm just going to control o to save that crl X to exit and we just don't have to tell it which inventory and which private key file to use in this case it should just use that by default now we want to make sure that our hosts have our our public key on them already so I'm going to do SSH copy D ID and I want to send dasi till slash. SSH anible and I want to send that to Brian at and I want to go grab the correct netb bird IP address for these guys so I want to send the one for my proxy so I'm going to grab that and I'm just going to control shift V to paste it in and it's going to prompt me do I want to allow this yes and it's going to send my private key and it says I've got that key added now I'm going to do the same thing but I'm going to use the IP address of my IDP server so I'm going to grab that IDP servers address right here copy it just going to paste it in over here and I think I already have it on there so let's just see and it says it added the key so okay maybe it wasn't there yet so that's good so now I should be pretty well set but let's look at this uh add zabic agent yaml so I'm calling the host all I say become the actual super user okay then I give it a task my first task is install the Zab agent on your buntu so we're going to call the APT module we're going to use that to install a the file or the actual name of zabic agent so when we did it before it was apt install zabic agent remember so that's what we're doing and then we want to update the cache so that it makes sure that it's got the most reent version of it uh next we're going to configure the zabic agent so this is where I needed to make sure I could get those IP addresses so we're going to go in here and we're going to say okay I've got this path Etsy slz ab/ zabic agent.com that's where that file should exist on these servers and then I'm creating a couple of variables um so one is the item for regular expression and item for replace so what we're going to do is we're going to use a regular expression we're going to look for this line that says server equal 127.0.0.1 because that's what it says when it installs the ax agent by default if you'll remember so we're going to look for that and we're going to replace it with the server equals the zabic server so now this is my zabic server address so I'm actually going to get the right address and make sure it's in here but I believe this is the correct address so let's just go look that's going to be the one for tools so if we look at tools it is 118 so we've got that one set already so I'm going to scroll a little bit this is where we were right here so it's going to use that right here and right here now it's going to grab this thing when it gra gathers facts it's going to grab the host name of the server so it's going to be it's going to use that and it's anable host name now the one thing I can't just tell it because I have multiple times that we're going to run this on different machines is I I need the source IP so if you remember the source IP we want to find that we want to find that line that says hasht Source IP equals and it's just blank so we're going to go out there we're going to say replace that with source IP equals and we want it to grab anable fact the wt0 uh interface the ipv4 address for that interface so this is the name of our interface with a netb bird VPN it's wt0 that's really nice because we know what we're looking for we can tell it go grab that address and use that for our source IP so for each client when it connects it's going to say hey I've got that address let me just throw that in here for you and it'll get it set correctly every time for the server and the server active we already know that address it's the same for every machine so we can just put it here and then it'll grab it and use it so we're set for that to be able to go in and set up that configuration once it does that we want it to start the service so we're going to tell it hey use this module called service the service name is zabic Agent and we want it to be started and enabled so we're going to start the service and enable it which means one start it and make it run two if the system system reboots I want it to automatically start on its own that's the enabled part now we need an API token so I'll show you how to generate this token this is an old token it's not valid anymore but we're going to generate this token inside of our zabic server so it says set the API token we're going to use this built-in uh object called set fact and it's part of anible and it's going to be the anible zexor oore key so all of that stays the same between the quotes you would replace this key with your key of course so I'm just going to get rid of this because we're going to need a new key and then we're going to tell it Hey whenever you do this we also need you to create a new host in the zabic web user interface so we're going to use the zabic API for that that's why we're getting the API token so to do that it says hey here's the network that we're going to be working on so community. zx. zavix that's the network OS that's just this stays like that don't change it we're going to use the HTTP API it's going to be 443 we want to use SSL um we don't need to validate the certificate anable zavix URL path is just empty now I'll show you what this is about in a minute but it's important that you know that that just needs to be two quotes if you're setting this up not in Docker it might change and you'll have to kind of know how to figure that out but there's a special command we can use to try to try to work through it so this is the anable host is what it's called but this is actually looking for for the zabic host name so I want to give it monitor. cit.com so that it knows where to go to hit the API so it says become false it doesn't need to be super eer to do this it's going to use the zabic host information and we're going to scroll down and this is kind of Fillin the blank for you so I just put it in as IDP this isn't actually going to be the right host name so I could use just anore host and I could just do it again anible uncore host like that and then this doesn't have to have anything for description it's not required I'm going to go up and make sure I'm typing the anible host correctly but I think I am yeah anible host name that's what we want to use not anible host so so name and name and that needs to be curly braces so now we've got that set where it'll grab the host name for us the host groups uh mine is CIS main it like this let me go double check and make sure I've set it correctly with the spelling cuz it is spelling and capitalization dependent so we want to make sure we get it set right now if you don't know all your host groups you can go down here to uh data collection and this gives you a list of all your host groups that are available so I've got this one called Linux servers I'm just going to copy that so I can just use it over here and what I'll do is I'll go out to the end of the line here and I'll just paste that in like that and then over here we've got this Linux template so again this is uh capitalization dependent so make sure that you get this and you can copy it again you can go back here you can go to data collection you can go to your templates or your template groups either one but you can start filtering so if you just need to filter it by Linux and then hit filter you should get the Linux by zavix agent you can copy that and then you can go and paste it in just like we just did then you want status to be enabled status to be present which means it's going to be there if we change this to absent it means it'll remove it from the system so this is how we do the removal uh in the other yaml file inventory mode is manual that's fine inventory zabic so tags I just gave it a couple of tags here it's tag and it's Alias is fine we've got a few different things and then we've got yuntu 2204 it's a digital loce VPS these are all these are all correct for everything I've got and then again I'm telling it go grab that IP address that we need so there's the IP and then we've got the port that we want it to be running on so that's set and then we tell it hey once you've done all of those things restart the zabic agent we want to make sure that this the server talks to the agent correctly so we've got to restart that agent just like we did in real life so we've set up this nice little script that'll help us get all this stuff done so let's go grab an API key so we're going to go to users and then API tokens and you'll see I don't have any API tokens right now so I'm going to go up here and I'm going to add an API token I'm going to give it a name and this is going to be uh video test token the user is me so I can just start typing and then pick my name I can give it a description if I want to but it's not required but then I can also have it expire so I can say you know what today is the the second I expect to use it today so I'll let it expire on the 4th just to make sure it's not valid for anybody else when the video comes out and I'll hit add now when you get this little popup you need to copy this token right then and you can do it this way and copy or you can click copy to clipboard so I clicked it I'm not going to close that yet I'm going to go back over here and I'm going to do Nano add I'm going to go all the way down to that API token section and I'm just going to put that API token right there I'm going to save with CR o enter and CR X to exit now I can go back over here and I can close this and there's my API so now I'm going to hit that API whenever I run this so I'm going to do ansible-playbook I don't need to tell it what file apparently because I put it in the config and I don't need to tell it what key to use cuz I put it in the config but I need you to tell it uh which play to to run so I'm going to say add and then I'm going to say D- ask- become- pass let's see if it'll work this way so it asked me for the password oh it didn't like something so I think I need double quotes around this let me just put them here and then we'll just hit that again I'm going to get rid of that space we'll save CR X and let's just try this again all right let trying to gather facts it's going to install the the zabic agent so it tells us that it gathered the facts on proxy and IDP that's a good start all right it says it changed IDP so that one's done it's got the agent installed my proxy server is a little bit of a light server I might need to increase it a little bit but we'll see how it does it takes a little bit longer to run things for sure all right so fax did what it was supposed to do it worked on the IDP system but it failed on my proxy server now I do think I know what happened uh I have to go back and look but it's got all this uh jargon that it failed and it's like cash update time so it ran the update um I think it updated the cachee properly and then it prompted probably during the install like it put a prompt on the screen sometimes you see that when I do my videos and I don't know how to deal with that yet for anable so it timed out essentially so when it did it just kept running which was great because it said hey let's go ahead and configure the zabic agent so it configured on CIS main it and if you look it replaced this with the proper IP addresses that we needed and it replaced our source IP with the source IP for IDP and it gave it the host name uh IDP which is what we expect then it came on down and it said okay start the Zex agent service and then it created the got the API token created the new host inside of our zabic system and then it restarted the service and then it gave us our readout so the proxy agent didn't get there but there is a problem that's that's not an issue with anible that's an issue with my server so I need to go check that and fix it but I hope you get the gist of you could use anel to do a lot of these and even if they fail you've if youve if you're successful on 90% of them you've saved yourself a lot of work so let's go back over here and just go back to our dashboard and we do see that we now have three and we can see we've got IDP and it's showing us our output and we've got everything running so I've shown you how to set up zapex how to get the agent installed how to use asle to install the agent how to get some things going you can kind of go crazy checking out the zavix documentation it is really good and there's a ton of it so you can get really get out there and start setting things up to get red as you want it to be red um zabic can also deal with Windows hosts and Mac OS hosts and other types of hosts so definitely get out there and install that learn about it learn how to use it learn how to configure it so that you can make sure that you're giving your clients the absolute best capabilities out of the box with your MSP service and monitoring is such an important part of that that I wanted to make sure we had a really powerful tool to use and move forward with hope you enjoyed this if you did like subscribe tell your friends about it so they can come along on the open source Journey with us and I'll talk to you next time no [Music]
Info
Channel: Awesome Open Source
Views: 6,568
Rating: undefined out of 5
Keywords: open, source, opensource, open-source, self, hosted, selfhosted, self-hosted, free, libre, software, server, web, internet, browser, linux, mac, macos, os x, windows, microsoft, unix, bsd, ios, android, pi, raspberry, desktop, vps, tutorial, how to, setup, installation, instructions, cli, command line, terminal, interface, network, networking, news, projects, NetworkMonitoring, systemadministration, monitoring, zabbix, system, administration, agent, solution, management, guide, ops, tips, sys admin, sys, admin
Id: piVIj8UPLFI
Channel Id: undefined
Length: 51min 33sec (3093 seconds)
Published: Thu Jun 06 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.