Atom Feed
Comments Atom Feed

Similar Articles

2016-03-12 15:33
PHP Zend opcache on Cacti via SNMP
2009-11-22 16:49
Postfix stats on Cacti (via SNMP)
2015-01-08 22:58
Nginx on Cacti via SNMP
2009-11-14 13:46
Apache stats on Cacti (via SNMP)
2015-01-08 22:59
php-fpm on Cacti via SNMP

Recent Articles

2019-07-28 16:35
git http with Nginx via Flask wsgi application (git4nginx)
2018-05-15 16:48
Raspberry Pi Camera, IR Lights and more
2017-04-23 14:21
Raspberry Pi SD Card Test
2017-04-07 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
2017-03-28 13:07
Kubernetes to learn Part 4

Glen Pitt-Pladdy :: Blog

SMART stats on Cacti (via SNMP)

Update: This was originally one of my first articles on Cacti stats via SNMP, and subsequently I have built an ever growing collection of templates and extension scripts based on the same approaches. Originally this was done as 2-disk templates which where fine for the machines I was working with - my server here is a basic 2-disk setup, so why would I need more. Since that I've worked with all sorts of different disk arrangements and had to fudge things to make useful templates. This update fixes that by bringing things down to two basic templates and switching to indexed SNMP allowing an arbitrary number of disks to be used. As of version 20121214 you can also easily edit the script to index by devices or serial numbers.

This follows on from the basics of SNMP I did previously, this article adds a set of SNMP extension scripts, config, and Cacti templates to monitor hard drives.


Self Monitoring, Analysis, and Reporting Technology is contained in most hard drives these days. It provides a number of built in tests to evaluate the health of a drive and hopefully predict many failures.

Linux has a suite of tools called "smartmontools" which provides a comprehensive set of utilities and a monitoring daemon for checking drives. Configuration of regular testing and monitoring (smartd) is beyond this article and there are plenty of docs around for that already, but what is often useful is to graph key parameters to spot anomalies with parameters which would otherwise go unnoticed.

After installing smartmontools, you can check the basic parameters that drives have with the command:

smartctl -a DEVICE

Where DEVICE is the device for the drive (not a partition). Typically this would be something like /dev/sda (first drive), /dev/sdb (second drive) etc. or /dev/hda (first drive), /dev/hdb (second drive), or some combination of both.

If a drive does not have SMART enabled it will say that in the output of the above. To enable SMART on the drive:

smartctl -s on DEVICE

Note that USB drives do not currently allow SMART data, even though the physical drives inside the boxes are SMART capable. I have no idea why this is the case, and USB drives are the ones I would really like to monitor as they get bashed about more and have poor cooling compared to fixed drives in a system.

Getting SMART over SNMP

Like discussed previously, SMART data requires root privilege to access, and snmpd runs as a low privilege user. What I do is have a CRON job that reads this data and stores it in files for snmpd to access via extension scripts.

Download:  Scripts and Cacti Templates for SMART are on GitHub

If you are using the same config I described previously, then simply take the cron script smart-cron, make it executable and add the lines to your /etc/snmp/local-snmp-cronjob file to make it run this as one of the tasks:

# collect SMART DATA

This code in smart-cron simply runs through devices matching /dev/sd? (ie. /dev/sda, /dev/sdb etc.) and dumps their SMART data to a file in /var/local/snmp as described previously.  From here extension scripts for snmpd can pick it up without requiring privilege.

A special case here is if you have a situation where devices get re-ordered on boot (eg. two controllers which may be detected in different order) and you need to force an fixed ordering. Edit smart-cron and uncomment the SMARTLIST variable, and add in all the device paths that will not change (suggest using /dev/disk/by-id/*). You should go clear out any smart-* files in /var/local/snmp if they have already been created or if you change config to avoid invalid data being left behind.

At this point STOP. Wait for the smart-* files to be created in /var/local/snmp. I suspect a lot of problems reported relate to not getting an early part of the chain working fully before moving on. Don't move on until the files exists.

SMART parameters are numbered and it made sense to me to exploit the numbering in a universal script instead of having to treat each parameter on it's own.

I place the parameter parsing script smart-generic (make it executable first: chmod +x smart-generic) in /etc/snmp

This script takes one argument of the SMART parameter number and outputs the difference (remaining life) between the current value and the threshold for that parameter. It is worth noting that different manufacturers (and even different models and revisions of drives) create these values differently so the value is of little interest on it's own, but unusual fluctuations or downward trends are worth taking note of. For temperatures it is normally necessary to take the raw data which can be done by prefixing the parameter ID with a 'R'.

This is another good time to STOP. Test that the smart-generic script is actually picking up the data:

# /etc/snmp/smart-generic 1

In /etc/snmp/snmpd.conf add the following lines (or others if you want to monitor them):

extend smartdevices /etc/snmp/smart-generic devices
extend smartdescriptions /etc/snmp/smart-generic description
extend smart1 /etc/snmp/smart-generic W1
extend smart3 /etc/snmp/smart-generic 3
extend smart4 /etc/snmp/smart-generic 4
extend smart5 /etc/snmp/smart-generic 5
extend smart7 /etc/snmp/smart-generic 7
extend smart9 /etc/snmp/smart-generic 9
extend smart10 /etc/snmp/smart-generic 10
extend smart12 /etc/snmp/smart-generic 12
extend smart170 /etc/snmp/smart-generic 170
extend smart171 /etc/snmp/smart-generic 171
extend smart172 /etc/snmp/smart-generic 172
extend smart177 /etc/snmp/smart-generic 177
extend smart178 /etc/snmp/smart-generic 178
extend smart179 /etc/snmp/smart-generic 179
extend smart180 /etc/snmp/smart-generic 180
extend smart181 /etc/snmp/smart-generic 181
extend smart182 /etc/snmp/smart-generic 182
extend smart183 /etc/snmp/smart-generic 183
extend smart184 /etc/snmp/smart-generic 184
extend smart187 /etc/snmp/smart-generic 187
extend smart189 /etc/snmp/smart-generic 189
extend smartR190 /etc/snmp/smart-generic R190
extend smartR194 /etc/snmp/smart-generic R194
extend smart195 /etc/snmp/smart-generic W195
extend smart196 /etc/snmp/smart-generic 196
extend smart198 /etc/snmp/smart-generic 198
extend smart199 /etc/snmp/smart-generic 199
extend smart203 /etc/snmp/smart-generic 203
extend smart226 /etc/snmp/smart-generic 226
extend smart230 /etc/snmp/smart-generic 230
extend smart231 /etc/snmp/smart-generic 231
extend smart232 /etc/snmp/smart-generic 232
extend smart233 /etc/snmp/smart-generic 233
extend smart235 /etc/snmp/smart-generic 235
extend smart241 /etc/snmp/smart-generic 241

There are many other parameters which you could also monitor and as can be seen, they are easily added by simply referencing the parameter ID and updating templates to match.

Note that the config presented here only looks at /dev/sd? devices. If your system has /dev/hd? devices then you will need to modify the scripts accordingly.

Once you have added all this restart snmpd.

This is another good point to STOP. You can test smart-generic by running it from the command line with appropriate parameters, and via SNMP by appending the appropriate SNMP OID to the "snmpwalk" commands shown in previous articles. Ensure that you get valid output on "snmp" related fields when you walk the extended OID: NET-SNMP-EXTEND-MIB::nsExtendOutLine

Cacti Templates

I have generated some basic Cacti Templates for these SMART parameters with one graph for temperatures and another for health parameters. They are easily extended for more parameters.

For indexed SNMP, Cacti requires an XML file describing how to map the SNMP data to each drive. As this is a local (unpackaged) version I have done my configuration around putting this file in /usr/local/share/cacti/resource/snmp_queries/ and you will need to alter the templates if you put the file elsewhere.

Put the data query XML disk_smart.xml in /usr/local/share/cacti/resource/snmp_queries/ or wherever appropriate for your system. Note that if you change the location then you will also need to update the path to this file in the Cacti Data Query for this template.

Simply import the Cacti template cacti_host_template_smart_parameters.xml, and add the data query to the hosts you want to monitor then you should see disks available to monitor and be able to add graphs you want in Cacti. It should just work if your SNMP is working correctly for that device (ensure other SNMP parameters are working for that device).

SSD Support

The big improvement as of version 20121214 is that there are a load of new parameters and templates to support for SSDs. While HDDs have mostly the same stuff from model to model and make to make, every SSD manufacturer has their own ideas on what SMART parameters matter, and that's not surprising since the chipsets are also very different.

I have provided a generic SSD template with everything that seemed to matter on the SSDs I've encournterded, but if you use this template directly then you will end up with loads of nan values. The idea is that you can duplicate this template and then prune that down for the specific model of SSD you are monitoring. I have done this for OCZ Agility-3 and Samsung 830 series devices, but you are free to do this for whatever model you have.

Scaling / normalisation

In many cases different manufacturers (and sometimes even models) have different starting values and thresholds for their parameters. As of version 20121214, the smart-generic script assumes that all parameters start at 100 (mostly the case) and scales them to an graph value of zero at the threshold.

This is however not always the case. Typically a few parameters on most drives may have a different starting or normal value so there is now a pair of hashes (%SCALEBYFAMILY and %SCALEBYMODEL) which provide custom overrides on a device family or device model basis.

Additionally occasionally parameters need ignoring as they are there for informational purposes (via raw values) rather than indicating the drive health and will typically have all zero health values. You can set a scaling of 'U' to hide these values.

Graph Screen Shots

Generic temperature template:

SMART over SNMP on Cacti : Temperatures

Generic HDD template:

SMART over SNMP on Cacti : HDD Health

Samsung 830 series SSD template:

SMART over SNMP on Cacti : Samsung 830 SSD Health

OCZ Agility-3 template:

SMART over SNMP on Cacti : OCZ Agility-3 SSD Health


Scott Image  2010-03-10 15:55 :: Scott

Hi Glen,
great work you've done.  I had never got my head around populating the SNMP MIB with an external process until now.  It always looks easy when it's in front of you!
I modified your Perl script and created an SNMP Query XML which will handle any numbers of drives.  It uses only two graph templates, one for errors and the other for temperatures.  Basically you get 2 graphs per drive.  I have a server with 10 drives and did not want to do all the work to add 8 more data sources!  And I thought it would be better to make it handle any number of drives.  If you're interested I can send you my XML templates.

Glen Pitt-Pladdy Image  2010-03-20 09:28 :: Glen Pitt-Pladdy

Hi Scott

Sorry for the delay getting back to you about your post on my blog.  It did take a while to pull all the fragments of info together to get SNMP working neatly.

Your approach sounds interesting and I'm sure would help lots of people who have servers with more than 2 disks to monitor.

I am happy for you to post a URL on my blog linking to your code & templates, else I am happy to host them off my server.

Either way, please make sure you give yourself credit for the extra work you have put into the template and scripts - I would suggest a comment in the code about the enhancements with your name and a URL.



Pablolibo Image  2010-06-09 05:34 :: Pablolibo

Could Scot send me your templates, thank a lot
Pitt-Pladdy, thank for it template :D

Anthony Image  2011-04-15 23:01 :: Anthony

Thanks for these, I've also altered your templates to support 4 drives if you'd like a copy of these let me know

Summerborn Image  2011-12-25 08:58 :: Summerborn

First -thank oyu very much for this, I was strugling to make this for past few weeks and even started writing smart mib and net-snmp smart extension.....
If I may make two points. First, I had to rewrite the path inside the big xml file cact.... to read my directory for disk_smart.xml file. Second, this line posted above:

extend smartreaderr /etc/snmp/smart-generic devices
has to be rewritten as follows:
extend smartdevices /etc/snmp/smart-generic devices

Glen Pitt-Pladdy Image  2011-12-25 12:31 :: Glen Pitt-Pladdy

Yes, you are quite right about the snmpd.conf line - have updated this. You should only need to change paths if you are putting the file in a different place.

Amine Image  2012-01-24 15:24 :: Amine

I am trying to use your tutorial to get smart infos via snmp

i am getting :
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smarttemp".1 = STRING: NA
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smarteccrec".1 = STRING: NA
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartairflow".1 = STRING: NA
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: /dev/sda
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartreaderr".1 = STRING: NA
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartrealloc".1 = STRING: NA
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartseekerr".1 = STRING: NA

would you please tell me how can i fix this , so i do not get any more NA

Glen Pitt-Pladdy Image  2012-01-24 17:51 :: Glen Pitt-Pladdy

Looking at the script, NA is output when it can't get the data about the drive. I would suggest starting by looking at the data file: /var/local/snmp/smart-sda

Check that the cron job is creating it properly with valid data in it.

Vampire1984 Image  2012-02-28 13:01 :: Vampire1984

Hello. I have got this error in Console->Devices->Edit   "Data Query Debug Information"
+ Running data query [13].
+ Found type = '3' [snmp query].
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/disk_smart.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'
+ No SNMP data returned
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/disk_smart.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/disk_smart.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/disk_smart.xml'

I tried runing it on windows machine but i think this instruction is for linux becaues it doesnt work. Or i have do a mistake somewhere in steps above?

Glen Pitt-Pladdy Image  2012-02-28 13:13 :: Glen Pitt-Pladdy

These instructions are for Debian or Ubuntu though should work on other Linux distros though may need a few changes. The important thing to note is that using snmpd on the Linux/Unix host we are monitoring and are adding extensions to snmpd to collect the data using smartmontools.

With monitoring Windows hosts you would have to extend the SNMP service in a similar way to provide the same data then you may be able to use this template or adapt this template for Windows use.

I am not sure if there are any implications to running Cacti on Windows and monitoring an Linux/Unix host with the extensions. That may well be possible without to much trouble.

From the error logs you give it looks like Cacti found the data query OK and is trying to check the SNMP where it is failing. My guess is that the host you are trying to monitor is not running the snmpd extensions given here (or Windows equivalent) correctly and that is why it is failing.

I hope that is useful to you.

Vampire1984 Image  2012-02-28 17:31 :: Vampire1984

No no:), I have got virtual machine which is on debian. Cacti snmp php apache are installed the newest from version stable. Snmp works, cacti draws some graphs on other default settings + template with processes(on windows host). This error log is from creating graph for windows host. My question was is this instruction only for linux hosts/servers or this script can 'catch' windows hosts too?

Glen Pitt-Pladdy Image  2012-02-28 18:04 :: Glen Pitt-Pladdy

Ah! So if I understand right:
* running Cacti on a Debian VM
* monitoring disks on a Windows host via SNMP

If that's the case then this is not going to work without a whole lot of extra stuff on the Windows host.

The way that this monitoring works is that Cacti acts as a SNMP client (no need to install anything extra on the Cacti box/VM), collecting remote data and graphing. The remote host you are monitoring has to be an SNMP server (in the case of Linux running snmpd).

Stock SNMP servers (Linux or Windows) will not give the SMART data needed for this. In order to send the SMART data over SNMP, we have to extend the SNMP server on the host we are monitoring with a load of scripts. That is described here for monitoring Linux hosts running snmpd only.

It may be possible to extend the Windows SNMP service in a similar way, but that's beyond my Windows knowledge so I can't help with that.

I hope I understood right this time  :)

Vampire1984 Image  2012-02-28 19:41 :: Vampire1984

Yes, Youre right. Cacti installed and configured on debian virtual machine vmware(created on vsphere 1.0, running on vserver 2.0). I monitor debian vm, some printers, router, 2 servers(SLES[yet snmp cannot connect to him but working on that]+W2K8R2), windows xp hosts. On windows hosts is installed smartmon tools for windows. smartctl -a /dev/sda recognizes the hdd and writes on cmd cli values of smart so it works directly on host. Maybe is it possible to rewrite script to work with smartctl on windows host?

Glen Pitt-Pladdy Image  2012-02-28 20:03 :: Glen Pitt-Pladdy

It does appear it is possible to extend the Windows SNMP service but it requires writing a .dll - see:

Another possibility is that NetSNMP (what we use on Linux) is also available for Windows:

The extension scripts are all designed around snmpd on Linux/Unix and will likely need modifying to work with Windows Net-SNMP.

That's not something I can help with - I mainly do Linux/Unix work.

Vampire1984 Image  2012-02-28 21:03 :: Vampire1984

OK thank u very much for tips, i will look at those links and figure something out;)You helped me:) Cheers:)

nA ni sivAm Image  2012-03-05 10:25 :: nA ni sivAm

Is there any possibility that I can get a template that can be imported by cacti Version 0.8.7d
I would like to get this smartmon work desperately... If you can get me a cacti 0.8.7d template I would be thankful...

Thanks again!

Glen Pitt-Pladdy Image  2012-03-05 10:35 :: Glen Pitt-Pladdy

This question comes up regularly enough that I have just created an article about it. See:

nA ni sivAm Image  2012-03-05 12:10 :: nA ni sivAm

okay. I tried this- updated the global_arrays.php.... now I get a different error:

"Error: XML: Generated with a newer version of Cacti."

Earlier i got this one- "Error: XML: Hash version does not exist." Can you please help me matey!

Glen Pitt-Pladdy Image  2012-03-06 08:58 :: Glen Pitt-Pladdy

That's a very old version of Cacti so it's possible it's simply too old. I might well be a whole lot less work just to upgrade Cacti to a more recent version.

nA ni sivAm Image  2012-03-06 10:26 :: nA ni sivAm

Thanks mannn...
Anyways if anybody wants to try importing, the trick is to change the hash numbers the numbers from the 3rd to 6th pos represent the version that the cacti supports min. If you change it manually it will be imported. But whether it will work or not will be dependent on the features used in that template!

with respect to this template it works with 0.8.7d...

nA ni sivAm Image  2012-03-06 10:27 :: nA ni sivAm

But soon after that I just got NaN everywhere, not something I would expect! :(

Reading thru the comments, I found out that
1. the local-snmp-cronjob file had to be modified - for some reason 'sed' in the way mentioned doesnt work in mine (both red hat/ suse)
2. smart-generic must have the valid path, i.e., if u hav not used the default path /var/local/snmp then u need to change $FILE in smart-generic

After these changes were made, it works.... partially!

nA ni sivAm Image  2012-03-06 10:27 :: nA ni sivAm

This is where I need your help... again!

-The first graph looks fine the temp is 25-30 and the airflow is 100 (always, is this ok?)
-The second graph has only 3 values, rest are nan. (ie., Reallocated Sectors, Seek Errors and ECC Recovered have values. The other fields- Raw errors, Poweron Hours, High Fly Writes are NaN)

is the smart-generic not parsing properly? may be the smartmonctl has a different output? may be becos of different version? i have my manual unix thing graphing poweron hrs. So it is there, it is just some text parsing issues right matey?

Glen Pitt-Pladdy Image  2012-03-06 10:57 :: Glen Pitt-Pladdy

SMART does vary between different drives. Check your snmpd.conf the spec for which parameter airflow is referencing. If there is an "R" in front of the parameter number then it takes the RAW_VALUE column rather than the VALUE column. For temperatures I would normally take the RAW_VALUE which on all my drives is the actual measured temperature, hence airflow is R190.

It sounds like you may have a drive that is putting a processed number into the RAW_VALUE field for airflow. Have a look at the cache files generated by the cron job and see what is in those parameters for your drives. On almost all my drives temp and airflow are very close.

For "nan" fields, your drives may have fewer and/or different parameters. Again, check the cache file for the drive. Since all the parameters are referenced by their number, you can add more to snmpd.conf, update the .xml with them, and then in Cacti update the Data Template, Graph Template and the Data Query accordingly, then re-add the graphs.

nA ni sivAm Image  2012-03-06 11:03 :: nA ni sivAm

thanks for the reply... will look at the cache files tonight and try to get some positive reply mate!
i am pretty sure I will have some q's for you!! thanks again

nA ni sivAm Image  2012-03-06 11:35 :: nA ni sivAm

had a quick look at the cache file and the data template... why is the airflow min max set to 0-1000 and others 0-100? any idea? could it be the reason why airflow is always 1000? the cache shows identical airflow and temp readings.

the other values are pretty high in the cache file.. however the data template is set to expect values between 0-100. could it be why i get NaN?

nA ni sivAm Image  2012-03-06 11:43 :: nA ni sivAm

please ignore the post above...

had a quick look at the cache file and the data template... why is the airflow min max set to 0-1000 and others 0-100? any idea? could it be the reason why airflow is always 100? the cache shows identical airflow and temp readings around 25-30.

the other values are pretty high in the cache file.. for eg. Power on hrs=382. Seekerror Rate=21639493. However the data template is set to expect values between 0-100. could it be why i get NaN?

Regd. using R as a prefix in snmpd.conf, are you saying R190 gets the RAW_VALUE. Using just 190 gets me the VALUE? I will try few things tonight and get back to you with details.

Glen Pitt-Pladdy Image  2012-03-06 11:51 :: Glen Pitt-Pladdy

There is a chance that the data is not being picked up correctly by smart-generic. Try running it manually and see what you get:

$ /etc/snmp/smart-generic R190

The limits could be responsible for the NaNs but again smart-generic should be picking up the VALUE (remaining life / health) field for that and that is normally in the range 0-100 on my drives. Again different drives may report different numbers.

You can also try running smart-generic for the parameters you are getting NaN on and see what happens, but make sure you run it exactly as in snmpd.conf so that it picks up RAW_VALUE or VALUE as snmpd would. Running an snmpwalk may also be useful to know what Cacti is receiving via snmp.

nA ni sivAm Image  2012-03-06 11:57 :: nA ni sivAm

extend smartdevices /etc/snmp/smart-generic devices
extend smartreaderr /etc/snmp/smart-generic 1
extend smartrealloc /etc/snmp/smart-generic 5
extend smartseekerr /etc/snmp/smart-generic 7
extend smartseekerr /etc/snmp/smart-generic 9
extend smartairflow /etc/snmp/smart-generic 189
extend smartairflow /etc/snmp/smart-generic R190
extend smarttemp /etc/snmp/smart-generic R194
extend smarteccrec /etc/snmp/smart-generic 195

are respectively:

    The device list used as the index
    Airflow_Temperature_Cel (RAW)
    Temperature_Celsius (RAW)

Are you sure there are two smartairflow and 2 smartseekerr

extend smartseekerr /etc/snmp/smart-generic 7
extend smartseekerr /etc/snmp/smart-generic 9

extend smartairflow /etc/snmp/smart-generic 189
extend smartairflow /etc/snmp/smart-generic R190

Glen Pitt-Pladdy Image  2012-03-06 12:07 :: Glen Pitt-Pladdy

Wow! Well spotted! I must have messed that up when I updated this article with the new indexed template.

I have updated the article with the correct entries for snmpd.conf (pasted directly from the server I develop the template on).

nA ni sivAm Image  2012-03-06 12:11 :: nA ni sivAm

I ran smart-generic for all the parameters needed by graph.. they are right.

I highly doubt that there is some typo in the extend thing done in snmpd.conf. shudnt there be any connection between the snmpd.conf and the data template? can u please recheck?

How should i read these extends using snmpwalk? can u please show me an example mate!

Glen Pitt-Pladdy Image  2012-03-06 12:57 :: Glen Pitt-Pladdy

For an Indexed template the entries in snmpd.conf are connected to the Data Sources via the .xml file and the associated Data Query in the template. As some of your graphs are working I think it's likely the .xml and the Data Query are working.

I definitely think it's worth running a snmpwalk against NET-SNMP-EXTEND-MIB::nsExtendOutLine (like described in my "SNMP basics" article) to see if all the SMART parameters are being reported correctly - at least then we know if the problems are SNMP or Cacti. You should get stuff like:

NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartpwrcyc".2 = STRING: 77
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartairflow".1 = STRING: 35
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartairflow".2 = STRING: 34
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: /dev/sda

Check all the problem parameters are being reported correctly. You may want to pipe the command through "grep smart" to extract only the SMART lines.

nA ni sivAm Image  2012-03-06 18:30 :: nA ni sivAm

All good matey! thanks for all the help...

pm pet Image  2012-06-28 15:49 :: pm pet


I can't retvieve any numbers via snmpwalk.  When I run "smart-generic 7", it nicely print numbers.  But something between snmpd and smart-generic is some problem, I think.

All paths are ok.

extend smartdevices /etc/snmp/smart-generic devices
extend smartreaderr /etc/snmp/smart-generic 1
extend smartrealloc /etc/snmp/smart-generic 5
extend smartseekerr /etc/snmp/smart-generic 7

All privileges are fine and everything.  And when I'm creating graphs in cacti, there's is just millions rows showing zeros.  Nothing human-readable.  Any advice?

Glen Pitt-Pladdy Image  2012-06-28 19:24 :: Glen Pitt-Pladdy

When you say you can't retrieve any numbers with snmpwalk, are the OIDs present in the output, just with invalid data, or are the OIDs missing all together?

pm pet Image  2012-06-28 21:11 :: pm pet

All are missing.  I'm using snmpwalk -v2c -c public <ip>, isn't that correct?

Glen Pitt-Pladdy Image  2012-06-28 21:15 :: Glen Pitt-Pladdy

By default snmpwalk will walk up the enterprises MIB so for checking these extended entries you will need to specify those:

$ snmpwalk -v2c -c public <ip> NET-SNMP-EXTEND-MIB::nsExtendOutLine

Then see if the data is being delivered correctly by snmpd and that will tell us if the problem is on the snmpd side or Cacti.

pm pet Image  2012-06-29 00:15 :: pm pet

Hy.  That did help.  And, debian stable doesn't have MIB-stuff in stable repository.  So for all you Stable-users, you need to download package snmp-mibs-downloader from and install it to use Extend mibs.  now it works, thank you!

pm pet Image  2012-06-29 00:29 :: pm pet

OK I had fun way too early. snmpwalk now works and shows correct information.  But still, in Cacti, when I click devices, add "Disk SMART Parameters" data query and click Create graphs.  In column "Data Query [Disk SMART Parameters]" it just shows 230 rows, mostly numbers between 0-10.  But also there are results like "_linkUpDown", "_triggerFail" etc.  You have any idea what I'm doing wrong?  I just can't figure out.

Glen Pitt-Pladdy Image  2012-06-29 08:10 :: Glen Pitt-Pladdy

I believe you can add the non-free section into your sources.list in order to install snmp-mibs-downloader. This applies to Ubuntu as well.

As for the remaining problems, it sounds as if there is some problem with the index. In the snmpwalk output check the "smartdevices" lines and see that they are all valid. That should be where Cacti picks up the list of devices from. It's also possible it's cached a bad list so also try clicking the green circle to update it.

pm pet Image  2012-06-29 13:42 :: pm pet

Heh I wrote so long message that I couldn't post it here, so here's my answer:


Glen Pitt-Pladdy Image  2012-06-29 17:32 :: Glen Pitt-Pladdy

I have to agree, the snmpd side looks all good. Not all drives support all the parameters graphed hence the NA. So long as most parameters are valid it should be good. One thing that may have some effect - are you running the snmpwalk on the cacti server?

I would also suspect some sort of problem relating to Cacti - it seems to pick up the necessary stuff from the XML (which I should actually tidy up a bit), but with the snmpwalk it does to pick up the devices logging everything, it looks like that's where it goes wrong. That's why I think it's worth verifying the exact snmpwalk from the cacti server:

$ snmpwalk -v2c -c public <ip> 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'

Check that against the same command on the server you are trying to monitor and see if there are differences.

pm pet Image  2012-06-30 16:56 :: pm pet

Both are same:

cacti $ snmpwalk -v2c -c public server 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: /dev/sda
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".2 = STRING: /dev/sdb
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".3 = STRING: /dev/sdc

server $ snmpwalk -v2c -c public server 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: /dev/sda
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".2 = STRING: /dev/sdb
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".3 = STRING: /dev/sdc

I don't really know where to find problem anymore, I'm not so familiar with cacti's XML-stuff and ways to collect snmp-information. :(

Glen Pitt-Pladdy Image  2012-06-30 18:26 :: Glen Pitt-Pladdy

I think that proves the snmp stuff is right which only leaves what is going on in Cacti. Details on XML queries are at

Can you confirm what version of Cacti you are using and where it came from? Is it the one that ships in Debian stable or some other version from elsewhere? Has it been modified/patched in any way? The reason I ask is that my verbose query is subtly different other than only finding 4 indexes:

+ Running data query [11].
+ Found type = '3' [snmp query].
+ Found data query XML file at '/usr/local/share/cacti/resource/snmp_queries/disk_smart.xml'
+ XML file parsed ok.
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'
+ Index found at OID: .......

pm pet Image  2012-07-02 01:00 :: pm pet

Cacti is version 0.8.8a and downloaded from cacti's site, I didn't use Debian's package.  It has no mods/patches, pure install and added only monitor&Settings&thold -plugins.

This version is pretty new, have they changed way to get data?

pm pet Image  2012-07-02 01:15 :: pm pet

Sorry for multiple posts but, graphs just started to work.  I didn't touch anything, I don't really know what happen.  Now everything works fine.  I still would like to know why those didn't work in the beginning.  Even though now it works, it still says this:

+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries

But still everything works and it doesn't print all snmpwalk-stuff.  Strange, duh, atleast it works.  Thank you really much!

Glen Pitt-Pladdy Image  2012-07-02 08:13 :: Glen Pitt-Pladdy

It does seem a little peculiar. I'm not familiar with all the changes in newer versions and there is a chance that there is something not quite working with the newer version and older templates/queries, or perhaps just it cached some invalid data for some reason.

The good thing is it's working.

Karel Image  2012-10-26 10:17 :: Karel

Hi, I'm using regular debian cacti 0.8.7g and it seems I have the same problem as "pm pet".
The Data Query for Disk SMART Parameters has [274 Items, 274 Rows]

smptwalk is giving  me a regular
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: /dev/sda
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".2 = STRING: /dev/sdb
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".3 = STRING: /dev/sdc
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".4 = STRING: /dev/sdd
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".5 = STRING: /dev/sde

Glen Pitt-Pladdy Image  2012-10-26 18:36 :: Glen Pitt-Pladdy

Ok - this does seem like a bit of a bizarre one. Let's first see if we can flush anything in Cacti that may be upsetting things. Try this:

1) Go to Data Queries->Disk Smart Parameters, check that it says "Successfully located XML file", Click save

2) Click Smart Health and check that all the drop-downs are valid

3) Go to New Graphs and select the relevant host, find the Disk Smart Parameters and click the green circle to refresh it - is it now working?

4) If not then go to System Utilities and click "Rebuild Poller Cache" - repeat 3 and see if it's working.

Let me know if at any stage it starts working again when doing that. I'm beginning to wonder if Cacti is doing something unexpected and caching the bad data the first time round.

mancy Image  2013-01-11 14:05 :: mancy

All working perfectly, I love you Glen :D

On Debian Squeeze, remember to install the package snmp-mibs-downloader
and comment the line in /etc/snmp/snmp.conf accordingly
as documented for example here:

Thank you Glen!!

zchef2k Image  2013-02-21 20:32 :: zchef2k

No matter what I try, I get the following in debug:

+ Running data query [11].
+ Found type = '4' [Script Query].
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/disk_smart.xml'
+ Error parsing XML file into an array.
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/disk_smart.xml'
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/disk_smart.xml'
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/disk_smart.xml'

Using 0.8.8a on el6.

Thanks for the hard work on this. Can't wait to get it workingon my end.

Glen Pitt-Pladdy Image  2013-02-22 07:22 :: Glen Pitt-Pladdy

The thing that looks suspicious is "Script Query" - this is SNMP and not Script. The real question is how it's managing that as all that should be in the template bundle. That's the thing I would suggest investigating first.

zchef2k Image  2013-02-22 14:48 :: zchef2k

Sorry. That selection was from desparation. I have managed to get the templates working. I deleted them and reimported them. Cacti seems to be happy ath the moment. Hoever, my graphs are showing 'nan' but acti has been polling for about 14 hours. In the polling logs I can see there's SNMP values being collected, but the graphs don't reflect the data. I do not see any rows in the mysql poller table. FOrgive my cacti n00bness.

Glen Pitt-Pladdy Image  2013-02-22 21:26 :: Glen Pitt-Pladdy

As always with diagnostics, look at a stage in the process which will yeild maximum information and divide the problem into clear parts to break down further. I would suggest checking with snmpwalk if valid data is available via SNMP - that neatly cuts between a Cacti and snmpd. This is described in the snmp basics article linked above.

Karel Image  2013-02-28 13:58 :: Karel

it seems that i'm getting only "U" from smart-generic script

my disc smartctl: http://pastbin<DOT>com/3WTAxux0

i believe that the script should be somehow updated for this disc

Glen Pitt-Pladdy Image  2013-02-28 22:09 :: Glen Pitt-Pladdy

I've put your smart data into a test setup and it works perfectly for me. I suspect the problem may relate to a discrepancy in config.

Karel Image  2013-03-04 08:21 :: Karel

you're right, it was a problem in smart-generic - it was unable to locate the exported files


scott Image  2013-03-28 19:57 :: scott

This is great stuff, and works flawlessly with direct attached drives. However, I have several systems with 3ware raid cards. Can you suggest how to modify your cacti scripts to make these drives available for graphing?

Glen Pitt-Pladdy Image  2013-03-28 21:44 :: Glen Pitt-Pladdy

Thanks for the feedback. I don't have any 3ware based systems, but I believe smartctl is capable of interrogating devices behind them so you would need to modify the cronjob to also collect SMART info for all the devices behind the 3ware, and then modify smart-generic to pick those files up as well.

Looking at the smartctl man page suggests that the particular way each model needs to be handled is different - that is certainly beyond the scope of what is practical for me to include in this standard version.

K0tz13 Image  2013-04-20 14:26 :: K0tz13

I have the same problem Karel and pm pet have/had, [504 Items, 252 Rows]. When I do verbose query in cacti I get the following:

+ Running data query [11].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/usr/share/cacti/resource/snmp_queries/disk_smart.xml'
+ XML file parsed ok.
+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"' Index Count: 5734
+ Index found at OID: '' value: 'Linux watson 3.5.0-27-generic #46~precise1-Ubuntu SMP Tue Mar 26 19:33:21 UTC 2013 x86_64'
+ Index found at OID: '' value: 'OID: .'
+ Index found at OID: '' value: '360548'
+ Index found at OID: '' value: 'Me'

followed by all OID entries possible. I'm using cacti 0.8.8a and cacti-spine 0.8.7i. Snmpwalk as above works fine.

Glen Pitt-Pladdy Image  2013-04-20 15:55 :: Glen Pitt-Pladdy

To debug the problem you have to check things at stages along the way that yield useful diagnostic information, hence all the talk in these articles about running snmpwalk and the snmpd scripts manually (ie. from the command line).

I suspect these problems relate to not having data coming through before tackling later steps. I've updated the smart-generic script (version 20130420) to give some useful information when it can't read the data files rather than the normal 'U'. Use this new version and take things step by step.

Start with running the snmpd-generic script with relevant arguments for the parameter you want to see, then run snmpwalk from the command line on the host you are monitoring, then on the Cacti server, checking the output at each stage.

K0tz13 Image  2013-04-21 10:18 :: K0tz13

I think I found the cause the problem; the default ubuntu snmpd.conf ships with the following lines enabled:

#  Arbitrary extension commands
extend    test1   /bin/echo  Hello, world!
extend-sh test2   echo Hello, world! ; echo Hi there ; exit 35
# extend-sh test3   /bin/sh /tmp/shtest

and those hello-world's are also printed when doing a:

snmpwalk -v2c -c <com> <ip> 'NET-SNMP-EXTEND-MIB::nsExtendOutLine'

When I commented those lines out (and restarted snmpd) everything started working! What I don't understand is why those test-extensions  cause Cacti to fail. The verbose query now shows what I would have expected the 1st time:

+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"' Index Count: 4
+ Index found at OID: '' value: 'sda'


adinovic Image  2013-05-02 13:21 :: adinovic

thx for the great script!
the scripts work for monitoring my centos box, but on my thecus-nas (n8800), when smart-generic executed by perl module (, the output are:
Use of uninitialized value $param in pattern match (m//) at ./smart-generic line 123.
Use of uninitialized value $param in substitution (s///) at ./smart-generic line 125.
Use of uninitialized value $param in pattern match (m//) at ./smart-generic line 127.
Use of uninitialized value $param in lc at ./smart-generic line 129.
Use of uninitialized value $param in lc at ./smart-generic line 129.
FATAL-need the numeric parameter or 'description' to show
snmpwalk -v1 -cmon ip-host NET-SNMP-EXTEND-MIB::nsExtendOutLine does vomit output, but the string only show value 101/100/U, cacti also don't generate rrd, i guess it's parsing problem by smart-generic being executed unproperly in thecus, but i dont really know the problem, i'm not a perl programmer :D

Glen Pitt-Pladdy Image  2013-05-02 17:49 :: Glen Pitt-Pladdy

In this case $param is the command line parameter passed to the script and tells it what info to return. In the snmpd.conf lines that have to be added the parameter is passed to the script, but based on what you have here it looks extremely likely that the script is not being run with a parameter or something about the version of Perl is discarding the parameter. As the script says "FATAL-need the numeric parameter or 'description' to show"

I would need to see the full output of the snmpwalk relating to SMART (ie. run "snmpwalk -v1 -cmon ip-host NET-SNMP-EXTEND-MIB::nsExtendOutLine | grep smart") to be able to see if it's working as expected within snmpd.

adinovic Image  2013-05-03 03:01 :: adinovic

i've pasted the output here http://pastbin<DOT>com/NZPc4EyT, hope it can help you. thx!

Glen Pitt-Pladdy Image  2013-05-03 06:22 :: Glen Pitt-Pladdy

To me that looks like it totally is working. What I suspect is happening though is that rather than using udev, it's got a bunch of static device files which go beyond sdz (ie. sdaa, sdab etc.) and that is confusing sorting and resulting in the U values in the devices output. That's just untidy rather than a real problem.

I see no reason why this won't work with Cacti unless it's got a quirk about indexes with U values. I see good data for 7 drives - sda through sdg.

To improve things you could hard-code the drives you have: in smart-generic "my @drives = ('sda','sdb'...'sdg');" and remove the other code from opendir to closedir, and in smart-cron "for devfull in /dev/sda /dev/sdb ... /dev/sdg; do"

adinovic Image  2013-05-06 19:03 :: adinovic

thx for your guidance sir. anyway,i finally get my thecus cacti smartmon work, i'm not sure what's happened. the things i did, i delete all the smart data sources, and then create graphs with smart health hdd template first, after the rrd came out, i create graphs from smart temperature template. also,i just realized,i get the same perl error in centos box which is run fine, so i think it's not a problem at all

Ethan Image  2013-05-21 16:14 :: Ethan

I have run in to a bit of a snag. When I do a verbose query in cacti this is what I get:

+ Running data query [10].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/usr/local/share/cacti/resource/snmp_queries/disk_smart.xml'
+ XML file parsed ok.
+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"' Index Count: 0
+ No SNMP data returned

I can see the extends with an snmpwalk: http://pastbin<DOT>com/SrAikDUE

However if I try to walk just the descriptions I get an index out of range error:

$ snmpwalk ... NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdescriptions"

NET-SNMP-EXTEND-MIB::nsExtendOutLine.smartdescriptions: Unknown Object Identifier (Index out of range: smartdescriptions (nsExtendToken))

Any ideas?


Glen Pitt-Pladdy Image  2013-05-24 06:37 :: Glen Pitt-Pladdy

Hi Ethan

The "Unkown Object Identifier" is likely the shell processing the quotes - try putting the whole of the OID in single quotes to stop that, or escape (with a backslash) each double quote so it's passed to snmpwalk unaltered.

To me everything looks in order from the output of snmpwalk, so I would next verify that the .xml file has not been modified/corrupted in some way that it no longer matches, and that the query matches the path to that file, and stuff like around that area. This looks like it comes down to something around Cacti not being able to match up the output of snmpwalk with the query xml.

Szymon Image  2013-06-17 01:21 :: Szymon


I can't get it working on Debian Squeeze with 0.8.7g-1+squeeze1. I have the data query associated with a host and it finds the devices and descriptions properly. However, when I click 'Create Graphs for this Host', select one of the devices and create graph type 'SMART Temperatures' I end up with graphs associated with some crippled datasources for R190 and R194. Namely in the Custom Data section I get an empty text box for Index Value (normally it's a drop-down select by the way) and next to Output Type ID and Index Type the text 'Data query data sources must be created through New Graphs.' is displayed.

I'm puzzled because New Graphs is exactly the way I created the graph. I spend half of the night trying to get this working but I'm out of ideas now. What can possibly be wrong if it works for other people? I'm using SNMP v3 if that's of any relevance. The values are definitely there (at least for R194) when I do snmpwalk across NET-SNMP-EXTEND-MIB::nsExtendOutLine.

Szymon Image  2013-06-18 01:54 :: Szymon

It seems that Cacti get's confused by multiple "U" in indexes, although it looks fine at the stage of the query and graph creation. I guess if the smart-generic script finds no data for some disks dumped by the cron script, it should not expose them at all. If someone (like me) decides not to monitor some of the drives and modifies the cron script not to dump smartctl output for them, Cacti will fail to create proper data sources in an utterly incomprehensible way.

Glen Pitt-Pladdy Image  2013-06-18 06:33 :: Glen Pitt-Pladdy

I'm not sure the problem is Cacti in this case. I certainly wouldn't bet on the snmpd extension script behaving as expected without valid input from the cron job. The aim is that the cron job collects (and caches) the info needed, then you choose which disks you monitor (with info from the cached data) within Cacti, but if you start modifying components of the system then other parts may not get their expected inputs and behave unpredictably. Essentially, the whole system has to hang together.

Szymon Image  2013-06-18 07:46 :: Szymon

What you say about the cron job is correct when you have an low shelf entry level server. If the disks are behind a RAID controller, there are many different ways to access SMART, depending on the controller (various tricks with -d for HP SmartArray, 3ware etc.). For Adaptec controllers it is pretty straighforward - you use /dev/sg[1-9][0-9]+ devices, but only some of them are the real physical disks. The rest represent the logical arrays, the controller itself or the hot-swap chassis. That is why I chose not to dump SMART for those (it ends up with error anyway). And it appears that Cacti is compeletly lost if there are duplicated values ("U"s) in the index fields. You would have to try it for yourself to see what I mean - it fails with the latest version as well.

Mind you for SSD's R241 may be worth graphing as well. That is actually the only one I needed and scripted based on your work. Great job, thanks :-)

paul Image  2013-10-31 01:09 :: paul

This is something I wish I had figured out how to do. Couple of problems I need to figure out. The first of which is that the smart-generic script doesn't return anything on the command line. The data files are there.

/usr/local/bin/ R194

ls -l /usr/local/etc/smart/snmp/
total 40
-rw-r--r--  1 root  wheel   6244 Oct 30 18:00 smart-ad2
-rw-r--r--  1 root  wheel  11576 Oct 30 18:00 smart-ad3

grep /usr/local/etc/smart/snmp /usr/local/bin/
my $FILES = '/usr/local/etc/smart/snmp';

So all is good there. The templates are installed.

Walking the extended tree — snmpwalk -Os -c xxx shuttle NET-SNMP-EXTEND-MIB::nsExtendOutLine | grep smart — gives me:
nsExtendOutLine."smart1".1 = STRING:
and so on

This is on FreeBSD 8.4, if that matters.

paul Image  2013-10-31 02:25 :: paul

[sfx: hammering, sawing]

Well, there's a problem. The files are being saved in $FILES/smart-$drive in the cronjob but accessed as "$FILES-$drive"; Not sure why the dash or truncated name. Once I fixed that, it all works.

Here's a diff of what I needed to do to make it work.

< my $FILES = '/var/local/snmp/smart';
> my $FILES = '/usr/local/etc/smart/snmp';
<         if ( $drive !~ /^sd[a-z]+$/ ) { next; }        # skip non drives
<         push @drives, $drive
>         if ( $drive !~ /^ad[0-9]+$/ ) { next; }        # skip non drives
>         push @drives, $drive;
<         if ( ! -f "$FILES-$drive" ) {
<                 print "U\n";
>         if ( ! -f "$FILES/smart-$drive" ) {
>                 print "missing data file?\n";
<         open DR, "$FILES-$drive"
>         open DR, "$FILES/smart-$drive"

Glen Pitt-Pladdy Image  2013-10-31 19:17 :: Glen Pitt-Pladdy

Hi Paul - the thing I notice is that you have change the storage path and modified the $FILES which included the prefix to the file, and in your case you have removed the prefix part. Then to compensate for the removal of the prefix you have modified the rest of the script to re-add the prefix into the code. The original code was fine, just so long as you don't take out the prefix when you change any paths.

paul Image  2013-11-02 20:03 :: paul

Ah, so the last piece of "/var/local/snmp/smart" is a conflation of a file name prefix and a path, not just a path, as I expected? I usually don't mix paths and file names when I create a variable if I expect other people to use something I made so that's where that crept in. I make no assumptions about where something will be used or how other systems are organized. The device naming convention (sd[a-z] or hd[a-z]) are also non-portable. I assume those are linux-isms. Not much use to me.

Glen Pitt-Pladdy Image  2013-11-03 17:11 :: Glen Pitt-Pladdy

Yup - it is a bit inconsistent and something that is tidier in the development version. Portability isn't my aim - I'm satisfying my needs (primarily Debian), others are welcome to use this as a basis to build on for their needs, but I'm being paid to support everyone's particular preferences.

t.c Image  2014-07-06 07:59 :: t.c

This is happen on same machine
- I don't modify script just download into resources/snmp_queries directly.

-- snmpwalk
root@cacti-server:~# snmpwalk -v2c -c public snmpd-server 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: sda

-- verbose query
+ Running data query [11].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/usr/share/cacti/site/resource/snmp_queries/disk_smart.xml'
+ XML file parsed ok.
+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"' Index Count: 0
+ No SNMP data returned

I'm using cacti 0.8.8b on ubuntu 12.04

Glen Pitt-Pladdy Image  2014-07-06 09:07 :: Glen Pitt-Pladdy

This looks very much like there may be a problem with the SNMP with Cacti. I think the snmpwalk you did proves that the snmpd-server machine is correctly configured as far as SNMP, but Cacti gets "No SNMP data returned". Does the machine details at the top of the "device" page get properly returned for this machine?

t.c Image  2014-07-07 04:41 :: t.c

at first device detail are seem correct but uptime is wrong then I restart snmpd-server and query data is correct now.

Thank you for useful article.

Erik Logtenberg Image  2014-07-25 13:14 :: Erik Logtenberg

I made a small addition to your script. It checks the exit code of smartctl and doesn't keep the file if smartctl returned an error. I have several /dev/sd* devices that are not actually hard disks (but unrecognized usb devices or iscsi shares), so they were cluttering the stats. Now things are tidy and clean:


# where to keep the files

# update smart parameters
for devfull in /dev/sd?; do
    dev=`basename $devfull`
    if /usr/sbin/smartctl -n idle -a $devfull >$STORE/smart-$dev.TMP; then
        mv $STORE/smart-$dev.TMP $STORE/smart-$dev
        rm -f $STORE/smart-$dev.TMP

Topper Harley Image  2015-10-10 11:01 :: Topper Harley

Here's my status:
- snmp conf: OK
- snmpd conf: OK
- smartctl to files: OK
- smart files to SNMP: OK
- smart SNMP to cacti: KO

From the shell:
# snmpwalk -v1 -c duffezerie dikkenek.duffez 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"'
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".1 = STRING: sda
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".2 = STRING: sdb
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".3 = STRING: sdc
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices".4 = STRING: sdd

From cacti:
+ Running data query [10].
+ Found type = '3' [SNMP Query].
+ Found data query XML file at '/opt/cacti-0.8.8f/resource/snmp_queries/disk_smart.xml'
+ XML file parsed ok.
+ <oid_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting oid_index entries
+ Executing SNMP walk for list of indexes @ 'NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartdevices"' Index Count: 0
+ No SNMP data returned

How come?

Topper Harley Image  2015-10-10 11:36 :: Topper Harley

Reading my question led me to the answer: somehow, I forgot to set the community and SNMP version to use for that host.
Both comments can be removed/ignored now.

Glen Pitt-Pladdy Image  2015-10-10 11:57 :: Glen Pitt-Pladdy

Yup - I do that also. Putting your thoughts into words makes me think about them more clearly and that often leads to answers.

Anon Image  2016-09-06 18:04 :: Anon

Didn't see any reason why this shouldn't work with (at least my) 3ware 9690 (SATA Drives, others may differ) sitting in my homeserver (others....) - they're just disks behind the Ctrl reporting their SMART data anyway.
The quick'n'dirty addition can be admired below ;); it gave me temperature/health-readings for all 8 disks.

Short Info (there's really not much to it):
$SMARTY is where you smartctl lives
$RAIDCTRL the used controller (for other manufacturers change the "--device"-string, see Help/Manpage)
$RAIDDRV represents the Port#, here you can customize which Ports get queried
The name for your graphs can be customized by fumbling with >> (TMP.)$PREFIX"3ware-Disk_"$RDISK <<;

RAIDDRV="0 1 2 3 4 5 6 7"

for RDISK in $RAIDDRV; do
<------>"$SMARTY" -n idle -a --device=3ware,$RDISK /dev/$RAIDCTRL  > $STORE/TMP.$PREFIX"3ware-Disk_"$RDISK
<------>mv $STORE/TMP.$PREFIX"3ware-Disk_"$RDISK $STORE/$PREFIX"3ware-Disk_"$RDISK

Georgios Michalopoulos Image  2016-12-08 00:16 :: Georgios Michalopoulos

while trying to import template i get an
Error: XML parse error

Glen Pitt-Pladdy Image  2016-12-08 07:04 :: Glen Pitt-Pladdy

What version of Cacti are you using?

Georgios Michalopoulos Image  2016-12-08 18:14 :: Georgios Michalopoulos


while asking snmp, i get manu U answers.. like these..
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartR190".1 = STRING: U
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartR190".2 = STRING: U
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartR190".3 = STRING: U
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartR190".4 = STRING: U
NET-SNMP-EXTEND-MIB::nsExtendOutLine."smartR190".5 = STRING: U

Glen Pitt-Pladdy Image  2016-12-09 07:33 :: Glen Pitt-Pladdy

That version should be fine. There is a chance of some incompatibility due to the template being exported a long time ago and likely from a different version, so when I get a chance I'll re-export it again when I get some time.

Not all drives report all metrics. I have many that don't report 190 so this would be normal. The output suggests something is being read so if there was problems with other metrics that are reported you'd have to trace them through and see when they fail (eg. something missing may be causing files to be empty or a permissions problem).

Georgios Michalopoulos Image  2016-12-11 15:02 :: Georgios Michalopoulos

i tried to import the new one, but still "Error: XML parse error.".
is there any way to debug the import process ?

Glen Pitt-Pladdy Image  2016-12-14 19:41 :: Glen Pitt-Pladdy

I think it's worth manually checking the file to ensure there's no corruptions on it's way to Cacti. Beyond that it's probably something to be asking a Cacti forum since I'm no expert on debugging those sorts of things within Cacti.

Andika Triwidada Image  2017-01-04 06:52 :: Andika Triwidada

I wonder if it is worth to merge smartctl result from SAS disks. They have very different output detail like this:

# smartctl -a -d megaraid,0 /dev/sda

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-4.4.0-57-generic] (local build)

Vendor:               SEAGATE
Product:              ST9500620SS
Revision:             AS0B
User Capacity:        500,107,862,016 bytes [500 GB]
Logical block size:   512 bytes
Rotation Rate:        7200 rpm
Form Factor:          2.5 inches
Logical Unit id:      0x5000c50085022b0b
Serial number:        9XF4nnnn
Device type:          disk
Transport protocol:   SAS
Local Time is:        Wed Jan  4 13:12:54 2017 WIB
SMART support is:     Available - device has SMART capability.

(complete dump at http://pastbin<DOT>com/T6Qj7ZiE)

Glen Pitt-Pladdy Image  2017-01-05 07:28 :: Glen Pitt-Pladdy

The current code could certainly be adapted to parse a different format like this, but supporting both in the same scripts (especially when I don't have any SAS drives to test against) is going to be an enormous pain.

You are welcome to fork the project on GitHub and run a parallel project for this format of data.

VadymUA Image  2017-04-22 17:38 :: VadymUA

This line in 'disk_smart.xml' may help:


It helps me and now I able to see the statistics from my HDDs.

Debian 9 / cacti 0.8.8h+ds1-9 / snmp 5.7.3+dfsg-1.7

Glen Pitt-Pladdy Image  2017-04-23 08:40 :: Glen Pitt-Pladdy

I've looked that up and it's specific to Compaq/HP (RAID controllers?) which could break things for a lot of other people. I do agree that having an index count is probably the best way of detecting changes with disks where the default uptime method won't detect any hot changes.

I'll look at adding a count when I get some time.

Glen Pitt-Pladdy Image  2017-04-23 09:18 :: Glen Pitt-Pladdy

Actually, having thought about this some more, this is not ideal either way. It's common for some devices to get re-ordered on boot, hence the "Uptime Goes Backwards" method makes most sense for these devices. Device count is likely to ignore re-ordering of devices on boot which is going to mess things up.

The only sure way is to do a complete re-validation every time. During setup, th e best way to get things working though is the click the green circle to manually refresh until your setup is working right and you can rely on automatic methods.

Rosco Image  2020-05-13 00:09 :: Rosco

Hi Glen,

In smart-cron, there would seem to be an easier way to determine the list of devices to gather data for, based on:

$ for DRIVE in `smartctl --scan | grep ^\/dev\/sd | cut -f1 -d' '`; do smartctl -n idle -a ${DRIVE}; done

When substituting your defined variables, this would look like:

for DRIVE in `smartctl --scan | grep -v ^\/dev\/bus | grep ^\/dev\/ | cut -f1 -d' '`; do

   smartctl -n idle -a ${DRIVE} > >${STORE}/TMP.${PREFIX}`basename ${DRIVE}`


This would reduce the need for 'manual' methods for filtering device names & silently ignores (eg. USB devices) by not discovering them in the first place.  It also allows for device names prefixed by something other than 'sd'.



Glen Pitt-Pladdy Image  2020-05-13 19:43 :: Glen Pitt-Pladdy

Yeah, that's a neat solution. The one problem I've hit in the past with this approach is on devices where drives may be removable you can end up with missing files until a drive is added again causing changing index. Not a problem impacting everyone so this could definitely work well for lots of people. If you have any ideas of how to handle all the different dynamic scenarios in a tidier way that would be good.

For now I'm faking it with empty files for missing devices, or you can define your own fixed order based on /dev/disk/by-id/* based links.

Rosco Image  2020-05-20 00:28 :: Rosco

Hi Glen,

Some further thought - there's no "one size fits all" solution.

There is, however, a property that doesn't change on each device - the concatenated "Product+Serial number" string, eg.: "ST300MM0008_S423487G", derived from smartctl.  I guess we're interested in knowing about the potential failures per *physical device*, so that string concat could be used as a handle.

In larger environments, device presentations change per host and their SD numbers along with their presented LUNs, so that various subsets of devices are seen at various device IDs depending on LUN numbers, etc. etc., especially in fibre FC-AL SAN or iSCSI NAS environments.  WWNs are a possible alternative in such environments, although they can refer to either physical or logical devices and lead to some confusion.

Using the "Product+Serial number" approach would also enable devices removed from a rack enclosure to be removed and re-inserted into another rack slot and its SMART history traced across the move(s).


Glen Pitt-Pladdy Image  2020-05-20 19:15 :: Glen Pitt-Pladdy

I think of this depends on the particular way you use rives, so perhaps treating the script as more of an example makes sense. I've got situations where there's a mix of drives grouped for different purposes, or just different generations of a product line.

I prefer the way the drives are grouped to be representative of their use. For me some combinations of controllers manage to keep things in a consistent order always while in other cases it gets complicated. eg. generally, when I replace a failed drive I want to keep the same order of graphs (position in an array) but then I also use a lot of large drives in removable slots for backups and archival which rotate all the time. In these cases I've customised the script to keep the permanent arrays in a consistent "slot" order as I replace drives while keeping backup/archival disks that come and go in the same order even when they are not available. This ties the script very specifically to a single hardware setup.

Note: Identity details will be stored in a cookie. Posts may not appear immediately