Hi,
I have some SNMP tables I would like to delete rows from. Looks like I should use the deleteRow function for that.
Unfortunately I can't get it to work.
I have attached a CSV with actual data from one of the tables. The script I am using is below:
sub main()
{
	idxStatus = $1->getColumnIndex("Status");
	for (i = 0; i < $1->rowCount; i++)
	{
		trace(0,$1->get(i,idxStatus));
		if ( $1->get(i,idxStatus) == "Unavailable" )
		{
			trace(0,"Deleting Row");
			$1->deleteRow(i);
		}
	}
}
As you can see, I added some debugging output already.
Here's the result from the logs. Based on that I would have expected the "Unavailable" rows to disappear from the table:
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.892] [INFO ] Healthy
[29-Jan-2016 21:21:27.893] [INFO ] Healthy
[29-Jan-2016 21:21:27.893] [INFO ] Healthy
[29-Jan-2016 21:21:27.893] [INFO ] Healthy
[29-Jan-2016 21:21:27.893] [INFO ] Healthy
[29-Jan-2016 21:21:27.893] [INFO ] Healthy
[29-Jan-2016 21:21:27.893] [INFO ] Unavailable
[29-Jan-2016 21:21:27.893] [INFO ] Deleting Row
[29-Jan-2016 21:21:27.893] [INFO ] Unavailable
[29-Jan-2016 21:21:27.893] [INFO ] Deleting Row
Yet, they are not deleted. Am I using the deleteRow function incorrectly?
I also found some other oddity in that sometimes the logs return rather strange results:
[29-Jan-2016 21:51:44.313] [INFO ] ??althy
[29-Jan-2016 21:51:44.313] [INFO ] ??althy
[29-Jan-2016 21:51:44.313] [INFO ] w?althy
[29-Jan-2016 21:51:44.313] [INFO ] ??available
[29-Jan-2016 21:51:44.313] [INFO ] V?available
Is that an indication of the SNMP packets coming back with corrupt data?
			
			
			
				Hi,
Answering my own question here, as it turned out to be a rather obvious bug in my script.
Deleting a row changes the row count, so whenever I delete a row, I also have to decrease "i" again, i.e. run an i--.
The other issue appears to indeed just be some broken SNMP agent producing rubbish data for that particular set that I was testing my code with. Even without any transformation applied, that particular DCI still produces nonsense more often than not - while all other DCIs on the same system work perfectly fine. Unlucky coincidence. :|
Anyway, works as expected now.