/*
 * Copyright 2026 Austin Lehman
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

include app;

/**
 * Module JAR loader class.
 */
static class sysmon_module {
    public sysmon_module() {
        app.loadJar("sysmon/aussom-sysmon.jar");
        app.loadJar("sysmon/sigar.jar");
    }
}

/**
 * Enum fsType defines file system types.
 */
enum fsType {
	cdrom;
	localDisk;
	network;
	none;
	ramDisk;
	swap;
	unknown;
}

/**
 * The sysmon class implements system information and
 * monitoring support.
 */
extern class sysmon : com.lehman.aussom.Sysmon {
	/**
	 * Constructor instantiates a new sysmon object. This will throw an exception
	 * if the host OS/Arch isn't supported.
	 * @r This object.
	 */
	public sysmon() {
		this.newSysmon();
	}
	private extern newSysmon();

	/**
	 * Returns an int with the number of bytes in a KB.
	 * @r An int with the number of bytes in a KB.
	 */
	public extern kilobyte();

	/**
	 * Returns an int with the number of bytes in a MB.
	 * @r An int with the number of bytes in a MB.
	 */
	public extern megabyte();

	/**
	 * Returns an int with the number of bytes in a GB.
	 * @r An int with the number of bytes in a GB.
	 */
	public extern gigabyte();

	/**
	 * Returns a string formatted as a percent.
	 * @p Val is a double with the value to be formatted.
	 * @r A string formatted as a percent.
	 */
	public extern formatPerc(double Val);


    /*
	 * CPU functions.
	 */
	/**
	 * Returns a map with CPU info.
	 * @r A map with the CPU info.
	 */
	public extern getCpuInfo();
	/* Note: When calling this function back to back you need to put in a sleep
	   for some period of time or else the subsequent calls will be inaccurate. */

	/**
	 * Returns a map with cpu percent values.
	 * Note: When calling this function back to back you need to put in a sleep
	 * for some period of time or else the subsequent calls will be inaccurate.
	 *
	 */
	public extern getCpuPerc();

	/**
	 * Returns a map with CPU percent formatted strings.
	 * Note: When calling this function back to back you need to put in a sleep
	 * for some period of time or else the subsequent calls will be inaccurate.
	 * @r A map with the CPU percent formatted strings.
	 */
	public extern getCpuPercFormatted();

	/**
	 * Returns a list of maps with CPU percent values by core.
	 * Note: When calling this function back to back you need to put in a sleep
	 * for some period of time or else the subsequent calls will be inaccurate.
	 * @r A list of maps with the CPU percent.
	 */
	public extern getCpuPercByCore();

	/**
	 * Returns a list of maps with CPU percent values by core formatted strings.
	 * Note: When calling this function back to back you need to put in a sleep
	 * for some period of time or else the subsequent calls will be inaccurate.
	 * @r A list of maps with the CPU percent values by core.
	 */
	public extern getCpuPercByCoreFormatted();

	/*
	 * Mem functions.
	 */
	/**
	 * Returns a map with memory usage information.
	 * @r A map with the memory usage.
	 */
	public extern getMem();

	/*
	 * File system functions.
	 */
	/**
	 * Gets basic file system information.
	 * @r A list of maps with the file system information.
	 */
	public extern getFsInfo();

	/**
	 * Gets the file system usage for the provided file system name.
	 * @r A map with the file system usage.
	 */
	public extern getFsUsage(string FsName);

	/**
	 * Gets all file system information including usage.
	 * @r A list of maps with the file system information including usage.
	 */
	public extern getAllFsInfo();

	/*
	 * Network functions.
	 */
	/**
	 * Returns a map with general network information.
	 * @r A map with the general network info.
	 */
	public extern getNetInfo();

	/**
	 * Returns a list of network interfaces.
	 * @r A list of network interfaces.
	 */
	public extern getNetIntInfo();

	/**
	 * Returns a map with usage information for the provided interface.
	 * @p IntName is a string with the interface name to get.
	 * @r A map with the usage information.
	 */
	public extern getNetIntUsage(string IntName);

	/**
	 * Returns a list of network interfaces.
	 * @r A list of network interfaces.
	 */
	public extern getAllNetIntInfo();

	/**
	 * Returns a map with TCP stats.
	 * @r A map with the TCP stats.
	 */
	public extern getTcpInfo();
}
