abel5405 Absent Member.
Absent Member.
2360 views

Question on how Object Status works

Greetings All,
A quick question on Object Status. When I put a server into Maintenance Mode and I do a query on it's "status" in the QDB I see that the status changes to reflect that it is indeed in Maintenance Mode, i.e. 268451844. If that server is a SQL server and I do a query to see what the status is of the database objects is they show on-line, i.e. 301989888. I would have thought that the status of all the objects in the Object Table would reflect the server being in Maintenance Mode. Reason I am asking about it is that I have an SSRS page with the status of the agents of a group of SQL servers. I was hoping to use the status of the Databases instead of the actual agent, if that makes sense. What would cause the status of the discovered database object to change outside of the object being deleted? Hope this question makes sense.

v/r
Chris
0 Likes
3 Replies
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Question on how Object Status works

Hi Chris

Maintenance mode applies only to the root server object, not its child objects, hence why only the server object changes status. however, it's pretty straightforward to take into account the parent/child relationship of objects so you can show that a child object is effectively in maintenance because its parent is. Here is an example query. Of course it could be extended for other object types or indeed the entire object tree. this is for AM 8.x

Declare @InMaintenance int
Set @InMaintenance = 0x00004000

Select o2.Name as [Agent], o1.Name as [Instance], Convert(varbinary, o2.Status) as [status]
from Object o1 inner join Object o2 on o1.RootMachineObjID = o2.ObjID
inner join ObjectType t on o1.TypeID = t.TypeID
where t.Name = 'SQLT_Server'
and o2.status & @InMaintenance > 0
0 Likes
andy_doran Absent Member.
Absent Member.

Re: Question on how Object Status works

In most places you see a Status - including the Object table - that is a bitwise setting. So looking at the integer value never helps. As Alain says, firstly most settings apply to the root machine rather than the child objects when looking at the Object table. and also - to see the bitwise representation of a value you use CONVERT(VARBINARY, value). For example

select convert(varbinary, Status), * from Object

To see if a bitwise value is set or not you use a logical AND (in SQL that's "&"). Again as Alain shows, the bitwise setting for "in maintenance" is 0x00004000. So to see what objects have that you would do something like:-

select * from Object where Status & 0x00004000 !=0

(!= is "not equal to") - so here you are looking for any onbject which has that bitwise setting "on". If you changed that to =0 then you would be looking for any object that does not have this setting "on" (though as pointed out this by itself is not much help as the setting does not apply to all objects, only machines so you would end up here with lots of child objects unless you filtered on the machines).

FYI some of the "important" bitwise values are:-

0x00000002 - The machine is an MS
0x00000004 - The machine has an agent
0x00000020 - The machine is an offline MS
0x00000040 - The machine is an offline agent (ie shows up as greyed out in the UI)
0x00000100 - The machine is in Scheduled maint (at the machine - or * - level)
0x00000200 - The machine is in Scheduled maint (at the server - ie Application like "SQL" - level)
0x00001000 - A "ping machine" request has been issued
0x00002000 - A request to put the machine in ad-hoc maint has been issued
0x00004000 - The machine is in ad-hoc maint
0x00008000 - A request to bring the machine out of ad-hoc maint has been issued
0x04000000 - The MS should not attempt to "ping" this machine (usually set for proxy objects)
0x08000000 - The object has been soft deleted (applies to all objects)

These bitwise settings can be added together when an object has multiple of them set. Which is why an MS has an Object Status of 6 (assuming no other bitwise settings) since that is 0x00000002 + 0x00000004. But if that machine is in maintenance the bitwise setting would be 0x00004006 (0x00004000 + 0x00000004 + 0x00000002). Which in decimal is 16390... which isn't particularly helpful, so that's why the hex value gives more of a clue

The query from Alain works on any AM version, not just 8.x
0 Likes
abel5405 Absent Member.
Absent Member.

Re: Question on how Object Status works

GOLD, PURE GOLD LOL. Many thanks, this is exactly what I am looking for! Many thanks to the both of you big time!

v/r
Chris
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.