PHP SDK Documentation
Collapse AllExpand All

    Class MAgent

    MApi MAgent

    Required files

    require_once('monitis/utils/Request.class.php')
    require_once('monitis/MApi.class.php')
    require_once('monitis/MAgent.class.php')

    Constructor Summary

    MAgent::__construct(string $apiKey = null, string $secretKey = null, string $authToken = null, unsigned int $version = null, string $apiUrl = null, string $publicKey = null)

    Method Summary

    Return Name
    array requestAgents(string $keyRegExp = null)
    array requestAgentInfo(unsigned int $agentId, bool $isLoadMonitors = null)
    array requestAllAgentsSnapshot(string $key, string $platform, int $timezone)
    array requestAgentSnapshot(string $agentKey, int $timezone)
    array deleteAgents(unsigned int $agentIds, string $keyRegExp)

    Methods inherited from class MApi

    Return Name
    array MApi::makeGetRequest(string $action, array $params = null)
    array MApi::makePostRequest(string $action, array $params = null)
    array MApi::requestApiKey(string $userName, string $password)
    array MApi::requestAuthToken()
    array MApi::requestPublicKeys()
    array MApi::addPublicKey(array $params = null)
    array MApi::updatePublicKey(string $publicKey, array $params = null)
    array MApi::deletePublicKeys(string|array $publicKeys)
    string MApi::getApiKey()
    string MApi::getSecretKey()
    string MApi::getAuthToken()
    string MApi::getVersion()
    string MApi::getApiUrl()
    string MApi::getPublicKey()
    string MApi::getLastRequest()
    string MApi::setApiKey(string $apiKey)
    string MApi::setSecretKey(string $secretKey)
    array MApi::setAuthToken(string $authToken)s
    string MApi::setVersion(unsigned int $version)
    string MApi::setApiUrl(string $apiUrl)
    string MApi::setPublicKey(string $publicKey)

    Constructor Detail

    __construct

    public __construct(string $apiKey = null, string $secretKey = null, string $authToken = null, unsigned int $version = null, string $apiUrl = null, string $publicKey = null);

    Parameters:

    • $apiKey — is public API key with you can get from Monitis dashboard (Account → API Key).
    • $secretKey — need for getting authentication token and checksum calculation.
    • $authToken — need for POST requests
    • $version — actual versions is 2 and 3. Version 2 use $authToken and checksum for authenticaton, version 3 — use the $publicKey
    • $apiUrl — is URL for requests. Default value located in MApi::URL_DEFAULT constant, value for custom monitors located in MApi::URL_CUSTOM.
    • $publicKey — key for requests in version 3 protocol.

    Method Detail

    requestAgentsapi

    array MAgent::requestAgents(string $keyRegExp = null);

    Parameters:

    • $keyRegExp — key of the agents to include in the results list represented as a Java RegEx

    Response structure:

    [
        [
            id,
            key,
            platform,
            status,
            processes => [],
            drives => []
        ],
        ...
    ]
    										

    requestAgentInfoapi

    array MAgent::requestAgentInfo(unsigned int $agentId, bool $isLoadMonitors = null);

    Parameters:

    • $agentId — agent ID
    • $isLoadMonitors — if true response will contain information about monitors of this agent. The default value is false.

    Response structure:

    [
        id,
        key,
        platform,
        status,
        drives => [
            [
                id,
                name,
                tag,
                letter,
                checkInterval,
                totalMemory,
                freeLimit
            ],
            ...
        ],
        processes => [
            [
                id,
                name,
                tag,
                processName,
                memoryLimit,
                cpuLimit,
                virtMemoryLimit
            ],
            ...
        ],
        httpTests => [
            [
                id,
                name,
                tag,
                url,
                port,
                timeout,
                httpmethod,
                postData,
                passwordAuth,
                loadFullPage,
                doRedirect,
                matchFlag,
                matchText,
                useSSL
            ],
            ...
        ],
        pingTests => [
            [
                id,
                name,
                tag,
                url,
                timeout,
                packetCount,
                packetSize,
                packetTimeout
            ],
            ...
        ],
        cpu => [
            [
                id,
                name,
                tag,
                iowaitMax,
                kernaelMax,
                userMax,
                idleMin,
                niceMax
            ],
            ...
        ],
        memory => [
            [
                id,
                name,
                ip,
                checkInterval,
                totalMemory,
                freeLimit,
                freeVirtualLimit,
                freeSwapLimit
            ],
            ...
        ],
        loadAvg => [
            [
                id,
                name,
                tag,
                ip,
                maxLimit1,
                maxLimit5,
                maxLimit15
            ],
            ...
        ]
    ]
    										

    requestAllAgentsSnapshotapi

    array MAgent::requestAllAgentsSnapshot(string $key, string $platform, int $timezone);

    Parameters:

    • $key — agent ID
    • $platform — one of MApi::PLATFORM_* constants.
    • $timezone — offset relative to GMT (Ex. 300).

    Response structure:

    [
    agents => [
            [
                id,
                key,
                platform,
                status,
                cpu => [
                    id,
                    name,
                    status,
                    idle,
                    time,
                    nice,
                    iowait,
                    kernel,
                    used
                ],
                devices => [
                    [
                        id,
                        name,
                        status,
                        freeSpace,
                        time,
                        usedSpace
                    ],
                    ...
                ],
                memory => [
                    [
                        id,
                        name,
                        status,
                        buffered,
                        total,
                        cached,
                        freeswap,
                        freeVirtual,
                        free,
                        time,
                        status,
                        totalswap,
                        totalVirtual
                    ],
                    ...
                ]
            ],
            ...
        ]
    ]
    										

    requestAgentSnapshotapi

    array MAgent::requestAgentSnapshot(string $agentKey, int $timezone);

    Parameters:

    • $agentKey — agent key
    • $timezone — offset relative to GMT (Ex. 300).

    Response structure:

    [
        agents => [
            [
                id,
                key,
                platform,
                status,
                cpu => [
                    id,
                    idle,
                    time,
                    status,
                    name,
                    nice,
                    iowait,
                    kernel,
                    used
                ],
                drives => [
                    [
                        id,
                        freeSpace,
                        time,
                        usedSpace,
                        status,
                        name
                    ],
                    ...
                ],
                memory => [
                    id,
                    buffered,
                    total,
                    cached,
                    freeswap,
                    freeVirtual,
                    free,
                    time,
                    status,
                    name,
                    totalswap,
                    totalVirtual
                ]
            ],
        ...
        ]
    ]
    										

    deleteAgentsapi

    array MAgent::deleteAgents(unsigned int $agentIds, string $keyRegExp);

    Parameters:

    • $agentIds — agent ID or array of agent IDs
    • $keyRegExp — key of the agents to remove represented as a Java RegEx

    Response structure:

    [
        status
    ]