Search code examples
zabbix

How does the zabbix agent calculate swap usage?


How does the zabbix agent calculate swap usage? I've looked at the zabbix config file for system.swap.size[,pfree] but it doesnt show it. It only shows for other metrics.


Solution

  • It's built-in function and it depends on OS. For example Linux: https://www.zabbix.org/websvn/wsvn/zabbix.com/trunk/src/libs/zbxsysinfo/linux/swap.c

       else if (0 == strcmp(mode, "pfree"))
                SET_DBL_RESULT(result, info.totalswap ? 100.0 * (info.freeswap / (double)info.totalswap) : 0.0);
    

    info variable is initialized by sysinfo function: http://man7.org/linux/man-pages/man2/sysinfo.2.html