Community discussions

MikroTik App
 
Maxoni
just joined
Topic Author
Posts: 11
Joined: Thu Jan 30, 2014 3:03 pm

Disk Probe

Wed Feb 19, 2014 11:10 am

Hi everyone, i'm new on the dude, Thanks a lots for the probes thread and so on, it really help me.

I try to make a probe for free space left on disk, but i have a little problem.

This is my probe :

Function:
Name : hdd_gb
Code : (((((oid("1.3.6.1.2.1.25.2.3.1.5.1")-oid("1.3.6.1.2.1.25.2.3.1.6.1"))*oid("1.3.6.1.2.1.25.2.3.1.4.1"))/1024)/1024)/1024)

Probe :
Nom : Free space left
Type : Function
Disponible : hdd_gb()<>"False"
Erreur : if(hdd_gb()<>"False",if(hdd_gb() > 20, "", concatenate(" Free space low C: =", hdd_gb(), "Gb Left")), "Failed to read Drive")


My problem is that i have a result like 19.523645 Gb when the space left is under 20.
But i just want to have 19 Gb.
Someone have an idea ?


Sorry for my english :)
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: Disk Probe

Thu Feb 20, 2014 1:29 am

Function round return number rounded to nearest integer
 
Maxoni
just joined
Topic Author
Posts: 11
Joined: Thu Jan 30, 2014 3:03 pm

Re: Disk Probe

Thu Feb 20, 2014 9:24 am

So simple ...

I change my function to

round(((((oid("1.3.6.1.2.1.25.2.3.1.5.1")-oid("1.3.6.1.2.1.25.2.3.1.6.1"))*oid("1.3.6.1.2.1.25.2.3.1.4.1"))/1024)/1024)/1024)

It's work well ! :)

Thx lebowski !
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: Disk Probe

Thu Feb 20, 2014 4:13 pm

Your welcome :)
 
RichCowell
just joined
Posts: 5
Joined: Mon Mar 03, 2014 3:40 pm

Re: Disk Probe

Mon Mar 17, 2014 12:16 pm

Just tried adding this, but it keeps saying Failed to read Drive...

Are there any extra permissions needed to read the hard drives like this?
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: Disk Probe

Mon Mar 17, 2014 9:14 pm

Maxoni, The function you created does not handle the "False" case. (that means the probe will return 0 if the function doesn't work.
By adding code like below to your function

if(oid(x), return value, false)

you can determine if the oid is available, return the value, or false.

Keying on False in the error line will let you know the device is down. Where as keying on false in the available line will let you know if the oid is even readable. They are both useful to code for. Also a not false result on available is how the dude determines if it will install the probe when you use auto discovery to add probes.

if(oid("1.3.6.1.2.1.25.2.3.1.5.1"), round(((((oid("1.3.6.1.2.1.25.2.3.1.5.1")-oid("1.3.6.1.2.1.25.2.3.1.6.1"))*oid("1.3.6.1.2.1.25.2.3.1.4.1"))/1024)/1024)/1024), "False")


Rich, You probably do not have snmp setup on the computer you would like to get
 
RichCowell
just joined
Posts: 5
Joined: Mon Mar 03, 2014 3:40 pm

Re: Disk Probe

Tue Mar 18, 2014 10:00 am

Rich, You probably do not have snmp setup on the computer you would like to get
Hiya,

I do, or at least I think I do - it's showing all the servers, and detecting all relevant services (DNS/Ping/Disk etc.) I've set up a community just for The Dude and they're all working like that...

I'll try that code you edited though...
 
RichCowell
just joined
Posts: 5
Joined: Mon Mar 03, 2014 3:40 pm

Re: Disk Probe

Wed Mar 19, 2014 12:38 pm

Rich, You probably do not have snmp setup on the computer you would like to get
I do, or at least I think I do - it's showing all the servers, and detecting all relevant services (DNS/Ping/Disk etc.) I've set up a community just for The Dude and they're all working like that...
I'll try that code you edited though...
Tried changing the Function to the one you posted and it's still showing the same...

It's not a huge issue really, as I've edited the built in Disk service to show as down if the free space is less than 10GB, but it'd be nice to be able to do it with additional hard drives, not just the C Drive...
 
User avatar
stmx38
Long time Member
Long time Member
Posts: 617
Joined: Thu Feb 14, 2008 4:03 pm
Location: Moldova, Chisinau

Re: Disk Probe

Wed Mar 19, 2014 3:26 pm

RichCowell
It's not a huge issue really, as I've edited the built in Disk service to show as down if the free space is less than 10GB, but it'd be nice to be able to do it with additional hard drives, not just the C Drive...
In this post you can see drive C and D.
It depends of OID you use.
 
Maxoni
just joined
Topic Author
Posts: 11
Joined: Thu Jan 30, 2014 3:03 pm

Re: Disk Probe

Thu Mar 27, 2014 9:42 am

Rich, You probably do not have snmp setup on the computer you would like to get
I do, or at least I think I do - it's showing all the servers, and detecting all relevant services (DNS/Ping/Disk etc.) I've set up a community just for The Dude and they're all working like that...
I'll try that code you edited though...
Tried changing the Function to the one you posted and it's still showing the same...

It's not a huge issue really, as I've edited the built in Disk service to show as down if the free space is less than 10GB, but it'd be nice to be able to do it with additional hard drives, not just the C Drive...
Hi,
You just have to find the Oid of the Drive you want to monitor (Snmpwalk the device).
 
lebowski
Forum Guru
Forum Guru
Posts: 1619
Joined: Wed Aug 27, 2008 5:17 pm

Re: Disk Probe

Mon Apr 07, 2014 11:04 pm

If the dude is set to auto discover and you use -1 for false in the available line the probe will install on every device.
AVAILABLE: if((oid("1.3.6.1.2.1.25.2.3.1.6.1")/oid("1.3.6.1.2.1.25.2.3.1.5.1"))*100>0, 1, -1)
The available line is to determine if the OID exists on the device in question but negative one is not false in the available line...

It is way better to create a function that returns a value or False. Then call that function from a probe.
Function
disk03test
if(array_size(oid_column("1.3.6.1.2.1.25.2.3.1.6",10,5)),round((oid("1.3.6.1.2.1.25.2.3.1.6.3",10,5)/oid("1.3.6.1.2.1.25.2.3.1.5.3",10,5))*100),"False")

Another function to grabs the name of the disk then if it is in error the drive letter or unix name can be returned in the error message.
Funciton
disk03name
oid("1.3.6.1.2.1.25.2.3.1.3.3" ,10,5)

So now in the probe the available line is simplified to test for "False".
The error line can also detect if the probe can't read the disk or if the disk is full...
The Probe
Available: disk03test() <> "False"
Error: if(disk03test()<>"False",if(disk03test() < 90, "", concatenate("Warning: ", disk03name(), " is ", disk03test(),"%")), "Failed read 3rd disk")
Value: disk03test()
unit: %

HTH,
Lebowski

Who is online

Users browsing this forum: No registered users and 16 guests