When I run as a sysadmin on my server, this runs fine.
exec master.dbo.xp_servicecontrol 'QUERYSTATE', 'SQLServerAgent'
If I run it with a non-sysadmin account, I get the following message:
The EXECUTE permission was denied on the object 'xp_servicecontrol', database 'mssqlsystemresource', schema 'sys'.
Then, if for the non-sysadmin I run
GRANT EXECUTE on master.dbo.xp_servicecontrol to [Domain\StandardUser] and rerun the original command it returns:
Error executing 'xp_servicecontrol': Permission denied. User must be a member of 'sysadmin' server role.
So that is the root of the problem. The permission is denied to anyone not a sysadmin.
Usually when using SSMS you can see the icon for SQL Server Agent and that will tell you whether it is up or down. That is not the same as a programmatic check, but it is a way for you to know.
Also, if your issue is that the SQL Agent might have failed, then the SQL Server Agent can be configured on the Properties form of the General tab to restart if it stops unexpectedly.